46 #include "llvm/Support/ConvertUTF.h"
47 using namespace clang;
54 if (ParsingInitForAutoVars.count(D))
64 if (getLangOpts().CPlusPlus14 && FD->getReturnType()->isUndeducedType() &&
70 if (TreatUnavailableAsInvalid && D->getAvailability() ==
AR_Unavailable &&
79 if (
const auto *A = D->getAttr<UnusedAttr>()) {
82 if (A->getSemanticSpelling() != UnusedAttr::CXX11_maybe_unused) {
84 if (DC && !DC->hasAttr<UnusedAttr>())
100 Cat->getMethod(OMD->getSelector(), OMD->isInstanceMethod()))
101 if (!CatMeth->hasAttr<AvailabilityAttr>())
109 bool ObjCPropertyAccess) {
120 Result = D->getAvailability(&Message);
129 if (IDecl->getDefinition()) {
130 D = IDecl->getDefinition();
131 Result = D->getAvailability(&Message);
138 if (
const EnumDecl *TheEnumDecl = dyn_cast<EnumDecl>(DC))
139 Result = TheEnumDecl->getAvailability(&Message);
148 if (PDeclResult == Result)
161 D, Message, Loc, UnknownObjCClass, ObjCPDecl,
167 if (isa<EnumConstantDecl>(D) || isa<EnumDecl>(D))
170 bool Warn = !D->getAttr<AvailabilityAttr>()->isInherited();
179 if (Warn && isa<ObjCInterfaceDecl>(D))
181 Redecl = Redecl->getPreviousDecl())
182 if (!Redecl->hasAttr<AvailabilityAttr>() ||
183 Redecl->getAttr<AvailabilityAttr>()->isInherited())
188 UnknownObjCClass, ObjCPDecl,
196 D, Message, Loc, UnknownObjCClass, ObjCPDecl,
210 if (Method && Method->isDeleted() && Method->isDefaulted()) {
212 if (!Method->isImplicit())
213 Diag(Decl->getLocation(), diag::note_implicitly_deleted);
218 if (CSM != CXXInvalid)
219 ShouldDeleteSpecialMember(Method, CSM,
nullptr,
true);
225 if (Ctor && Ctor->isInheritingConstructor())
226 return NoteDeletedInheritingConstructor(Ctor);
228 Diag(Decl->getLocation(), diag::note_availability_specified_here)
236 if (
I->getStorageClass() !=
SC_None)
281 if (!DowngradeWarning && UsedFn)
282 DowngradeWarning = UsedFn->
isInlined() || UsedFn->hasAttr<ConstAttr>();
284 S.
Diag(Loc, DowngradeWarning ? diag::ext_internal_in_extern_inline_quiet
285 : diag::ext_internal_in_extern_inline)
290 S.
Diag(D->getCanonicalDecl()->getLocation(), diag::note_entity_declared_at)
300 Diag(DeclBegin, diag::note_convert_inline_to_static)
319 bool ObjCPropertyAccess) {
320 if (getLangOpts().
CPlusPlus && isa<FunctionDecl>(D)) {
323 auto Pos = SuppressedDiagnostics.find(D->getCanonicalDecl());
324 if (Pos != SuppressedDiagnostics.end()) {
326 Diag(Suppressed.first, Suppressed.second);
337 if (cast<FunctionDecl>(D)->isMain())
338 Diag(Loc, diag::ext_main_used);
342 if (ParsingInitForAutoVars.count(D)) {
345 Diag(Loc, diag::err_auto_variable_cannot_appear_in_own_initializer)
352 if (FD->isDeleted()) {
354 if (Ctor && Ctor->isInheritingConstructor())
355 Diag(Loc, diag::err_deleted_inherited_ctor_use)
357 << Ctor->getInheritedConstructor().getConstructor()->getParent();
359 Diag(Loc, diag::err_deleted_function_use);
360 NoteDeletedFunction(FD);
366 if (getLangOpts().
CPlusPlus14 && FD->getReturnType()->isUndeducedType() &&
367 DeduceReturnType(FD, Loc))
376 if (LangOpts.OpenMP && DRD && !CurContext->containsDecl(D) &&
378 Diag(Loc, diag::err_omp_wrong_var_in_declare_reduction)
379 << getCurFunction()->HasOMPDeclareReductionCombiner;
380 Diag(D->getLocation(), diag::note_entity_declared_at) << D;
398 if (FD->getAvailability(&Message))
399 return ": " + Message;
401 return std::string();
410 const SentinelAttr *attr = D->getAttr<SentinelAttr>();
415 unsigned numFormalParams;
419 enum CalleeType { CT_Function, CT_Method, CT_Block } calleeType;
422 numFormalParams = MD->param_size();
423 calleeType = CT_Method;
424 }
else if (
FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
425 numFormalParams = FD->param_size();
426 calleeType = CT_Function;
427 }
else if (isa<VarDecl>(D)) {
433 calleeType = CT_Function;
436 calleeType = CT_Block;
442 numFormalParams = proto->getNumParams();
454 unsigned nullPos = attr->getNullPos();
455 assert((nullPos == 0 || nullPos == 1) &&
"invalid null position on sentinel");
456 numFormalParams = (nullPos > numFormalParams ? 0 : numFormalParams - nullPos);
459 unsigned numArgsAfterSentinel = attr->getSentinel();
463 if (Args.size() < numFormalParams + numArgsAfterSentinel + 1) {
465 Diag(D->getLocation(), diag::note_sentinel_here) <<
int(calleeType);
470 Expr *sentinelExpr = Args[Args.size() - numArgsAfterSentinel - 1];
471 if (!sentinelExpr)
return;
480 = getLocForEndOfToken(sentinelExpr->getLocEnd());
481 std::string NullValue;
482 if (calleeType == CT_Method && PP.isMacroDefined(
"nil"))
484 else if (getLangOpts().CPlusPlus11)
485 NullValue =
"nullptr";
486 else if (PP.isMacroDefined(
"NULL"))
489 NullValue =
"(void*) 0";
492 Diag(Loc, diag::warn_missing_sentinel) << int(calleeType);
494 Diag(MissingNilLoc, diag::warn_missing_sentinel)
497 Diag(D->getLocation(), diag::note_sentinel_here) <<
int(calleeType);
518 assert(!Ty.
isNull() &&
"DefaultFunctionArrayConversion - missing type");
523 if (getLangOpts().OpenCL) {
530 if (
auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl()))
535 CK_FunctionToPointerDecay).
get();
548 if (getLangOpts().C99 || getLangOpts().CPlusPlus || E->
isLValue())
550 CK_ArrayToPointerDecay).
get();
562 if (UO->getOpcode() == UO_Deref &&
563 UO->getSubExpr()->IgnoreParenCasts()->
565 !UO->getType().isVolatileQualified()) {
567 S.
PDiag(diag::warn_indirection_through_null)
568 << UO->getSubExpr()->getSourceRange());
570 S.
PDiag(diag::note_indirection_through_null));
583 if (!Member || !Member->
isStr(
"isa"))
593 ObjCIvarDecl *IV = IDecl->lookupInstanceVariable(Member, ClassDeclared);
601 if (ObjectSetClass) {
625 S.
Diag(IV->getLocation(), diag::note_ivar_decl);
644 assert(!T.
isNull() &&
"r-value conversion on typeless expression?");
648 if (getLangOpts().CPlusPlus &&
663 if (getLangOpts().OpenCL && !getOpenCLOptions().cl_khr_fp16 &&
672 NamedDecl *ObjectGetClass = LookupSingleName(TUScope,
679 SourceRange(OISA->getOpLoc(), OISA->getIsaMemberLoc()),
")");
704 UpdateMarkingForLValueToRValue(E);
708 if (getLangOpts().ObjCAutoRefCount &&
710 Cleanup.setExprNeedsCleanups(
true);
719 T = Atomic->getValueType().getUnqualifiedType();
728 ExprResult Res = DefaultFunctionArrayConversion(E, Diagnose);
731 Res = DefaultLvalueConversion(Res.
get());
746 CK_FunctionToPointerDecay).
get();
750 Res = DefaultLvalueConversion(Res.
get());
763 ExprResult Res = DefaultFunctionArrayLvalueConversion(E);
769 assert(!Ty.
isNull() &&
"UsualUnaryConversions - missing type");
772 if (Ty->
isHalfType() && !getLangOpts().NativeHalfType)
794 E = ImpCastExprToType(E, PTy, CK_IntegralCast).get();
799 E = ImpCastExprToType(E, PT, CK_IntegralCast).get();
812 assert(!Ty.
isNull() &&
"DefaultArgumentPromotion - missing type");
822 if (BTy && (BTy->
getKind() == BuiltinType::Half ||
823 BTy->
getKind() == BuiltinType::Float))
880 if (!Record->hasNonTrivialCopyConstructor() &&
881 !Record->hasNonTrivialMoveConstructor() &&
882 !Record->hasNonTrivialDestructor())
883 return VAK_ValidInCXX11;
891 if (getLangOpts().MSVCCompat)
892 return VAK_MSVCUndefined;
896 return VAK_Undefined;
906 case VAK_ValidInCXX11:
908 E->getLocStart(),
nullptr,
909 PDiag(diag::warn_cxx98_compat_pass_non_pod_arg_to_vararg)
916 DiagRuntimeBehavior(E->getLocStart(),
nullptr,
917 PDiag(diag::warn_pass_class_arg_to_vararg)
918 << Ty << CT << hasCStrMethod(E) <<
".c_str()");
923 case VAK_MSVCUndefined:
925 E->getLocStart(),
nullptr,
926 PDiag(diag::warn_cannot_pass_non_pod_arg_to_vararg)
927 << getLangOpts().CPlusPlus11 << Ty << CT);
933 E->getLocStart(),
nullptr,
934 PDiag(diag::err_cannot_pass_objc_interface_to_vararg)
937 Diag(E->getLocStart(), diag::err_cannot_pass_to_vararg)
938 << isa<InitListExpr>(E) << Ty << CT;
949 if (PlaceholderTy->getKind() == BuiltinType::ARCUnbridgedCast &&
950 (CT == VariadicMethod ||
951 (FDecl && FDecl->hasAttr<CFAuditedTransferAttr>()))) {
952 E = stripARCUnbridgedCast(E);
963 ExprResult ExprRes = DefaultArgumentPromotion(E);
970 if (isValidVarArgType(E->
getType()) == VAK_Undefined) {
977 ExprResult TrapFn = ActOnIdExpression(TUScope, SS, TemplateKWLoc,
983 E->getLocStart(),
None,
997 diag::err_call_incomplete_argument))
1014 if (SkipCast)
return false;
1016 QualType fpTy = cast<ComplexType>(ComplexTy)->getElementType();
1019 CK_FloatingRealToComplex);
1023 CK_IntegralComplexToFloatingComplex);
1033 bool IsCompAssign) {
1056 auto *LHSComplexType = dyn_cast<
ComplexType>(LHSType);
1057 auto *RHSComplexType = dyn_cast<
ComplexType>(RHSType);
1059 LHSComplexType ? LHSComplexType->getElementType() : LHSType;
1061 RHSComplexType ? RHSComplexType->getElementType() : RHSType;
1067 if (!IsCompAssign) {
1074 }
else if (Order > 0) {
1089 bool ConvertFloat,
bool ConvertInt) {
1094 CK_IntegralToFloating);
1105 CK_IntegralComplexToFloatingComplex);
1110 CK_FloatingRealToComplex);
1119 QualType RHSType,
bool IsCompAssign) {
1125 if (LHSFloat && RHSFloat) {
1132 assert(order < 0 &&
"illegal float comparison");
1166 "The remaining types must be floating point types.");
1171 QualType LHSElemType = LHSComplex ?
1172 LHSComplex->getElementType() : LHSType;
1173 QualType RHSElemType = RHSComplex ?
1190 return Float128AndLongDouble &&
1192 &llvm::APFloat::IEEEdouble);
1206 CK_IntegralComplexCast);
1212 template <PerformCastFn doLHSCast, PerformCastFn doRHSCast>
1215 QualType RHSType,
bool IsCompAssign) {
1220 if (LHSSigned == RHSSigned) {
1223 RHS = (*doRHSCast)(
S, RHS.
get(), LHSType);
1225 }
else if (!IsCompAssign)
1226 LHS = (*doLHSCast)(
S, LHS.
get(), RHSType);
1228 }
else if (order != (LHSSigned ? 1 : -1)) {
1232 RHS = (*doRHSCast)(
S, RHS.
get(), LHSType);
1234 }
else if (!IsCompAssign)
1235 LHS = (*doLHSCast)(
S, LHS.
get(), RHSType);
1242 RHS = (*doRHSCast)(
S, RHS.
get(), LHSType);
1244 }
else if (!IsCompAssign)
1245 LHS = (*doLHSCast)(
S, LHS.
get(), RHSType);
1254 RHS = (*doRHSCast)(
S, RHS.
get(), result);
1256 LHS = (*doLHSCast)(
S, LHS.
get(), result);
1266 bool IsCompAssign) {
1270 if (LHSComplexInt && RHSComplexInt) {
1274 handleIntegerConversion<doComplexIntegralCast, doComplexIntegralCast>
1275 (
S, LHS, RHS, LHSEltType, RHSEltType, IsCompAssign);
1277 return S.Context.getComplexType(ScalarType);
1280 if (LHSComplexInt) {
1283 handleIntegerConversion<doComplexIntegralCast, doIntegralCast>
1284 (
S, LHS, RHS, LHSEltType, RHSType, IsCompAssign);
1286 RHS = S.ImpCastExprToType(RHS.get(), ComplexType,
1287 CK_IntegralRealToComplex);
1292 assert(RHSComplexInt);
1296 handleIntegerConversion<doIntegralCast, doComplexIntegralCast>
1297 (
S, LHS, RHS, LHSType, RHSEltType, IsCompAssign);
1301 LHS = S.ImpCastExprToType(LHS.get(), ComplexType,
1302 CK_IntegralRealToComplex);
1311 bool IsCompAssign) {
1312 if (!IsCompAssign) {
1313 LHS = UsualUnaryConversions(LHS.
get());
1318 RHS = UsualUnaryConversions(RHS.
get());
1331 LHSType = AtomicLHS->getValueType();
1334 if (LHSType == RHSType)
1343 QualType LHSUnpromotedType = LHSType;
1347 if (!LHSBitfieldPromoteTy.
isNull())
1348 LHSType = LHSBitfieldPromoteTy;
1349 if (LHSType != LHSUnpromotedType && !IsCompAssign)
1350 LHS = ImpCastExprToType(LHS.
get(), LHSType, CK_IntegralCast);
1353 if (LHSType == RHSType)
1379 return handleIntegerConversion<doIntegralCast, doIntegralCast>
1380 (*
this, LHS, RHS, LHSType, RHSType, IsCompAssign);
1393 Expr *ControllingExpr,
1396 unsigned NumAssocs = ArgTypes.size();
1397 assert(NumAssocs == ArgExprs.size());
1400 for (
unsigned i = 0; i < NumAssocs; ++i) {
1402 (void) GetTypeFromParser(ArgTypes[i], &Types[i]);
1407 ExprResult ER = CreateGenericSelectionExpr(KeyLoc, DefaultLoc, RParenLoc,
1409 llvm::makeArrayRef(Types, NumAssocs),
1419 Expr *ControllingExpr,
1422 unsigned NumAssocs = Types.size();
1423 assert(NumAssocs == Exprs.size());
1429 ExprResult R = DefaultFunctionArrayLvalueConversion(ControllingExpr);
1432 ControllingExpr = R.
get();
1437 if (ActiveTemplateInstantiations.empty() &&
1440 diag::warn_side_effects_unevaluated_context);
1442 bool TypeErrorFound =
false,
1444 ContainsUnexpandedParameterPack
1447 for (
unsigned i = 0; i < NumAssocs; ++i) {
1448 if (Exprs[i]->containsUnexpandedParameterPack())
1449 ContainsUnexpandedParameterPack =
true;
1452 if (Types[i]->getType()->containsUnexpandedParameterPack())
1453 ContainsUnexpandedParameterPack =
true;
1455 if (Types[i]->getType()->isDependentType()) {
1456 IsResultDependent =
true;
1461 if (Types[i]->getType()->isIncompleteType())
1462 D = diag::err_assoc_type_incomplete;
1463 else if (!Types[i]->getType()->isObjectType())
1464 D = diag::err_assoc_type_nonobject;
1465 else if (Types[i]->getType()->isVariablyModifiedType())
1466 D = diag::err_assoc_type_variably_modified;
1469 Diag(Types[i]->getTypeLoc().getBeginLoc(), D)
1470 << Types[i]->getTypeLoc().getSourceRange()
1471 << Types[i]->getType();
1472 TypeErrorFound =
true;
1477 for (
unsigned j = i+1; j < NumAssocs; ++j)
1478 if (Types[j] && !Types[j]->getType()->isDependentType() &&
1480 Types[j]->getType())) {
1481 Diag(Types[j]->getTypeLoc().getBeginLoc(),
1482 diag::err_assoc_compatible_types)
1483 << Types[j]->getTypeLoc().getSourceRange()
1484 << Types[j]->getType()
1485 << Types[i]->getType();
1486 Diag(Types[i]->getTypeLoc().getBeginLoc(),
1487 diag::note_compat_assoc)
1488 << Types[i]->getTypeLoc().getSourceRange()
1489 << Types[i]->getType();
1490 TypeErrorFound =
true;
1500 if (IsResultDependent)
1502 Context, KeyLoc, ControllingExpr, Types, Exprs, DefaultLoc, RParenLoc,
1503 ContainsUnexpandedParameterPack);
1506 unsigned DefaultIndex = -1U;
1507 for (
unsigned i = 0; i < NumAssocs; ++i) {
1511 Types[i]->getType()))
1512 CompatIndices.push_back(i);
1518 if (CompatIndices.size() > 1) {
1522 Diag(ControllingExpr->getLocStart(), diag::err_generic_sel_multi_match)
1523 << ControllingExpr->getSourceRange() << ControllingExpr->
getType()
1524 << (
unsigned) CompatIndices.size();
1525 for (
unsigned I : CompatIndices) {
1526 Diag(Types[
I]->getTypeLoc().getBeginLoc(),
1527 diag::note_compat_assoc)
1528 << Types[
I]->getTypeLoc().getSourceRange()
1529 << Types[
I]->getType();
1537 if (DefaultIndex == -1U && CompatIndices.size() == 0) {
1541 Diag(ControllingExpr->getLocStart(), diag::err_generic_sel_no_match)
1542 << ControllingExpr->getSourceRange() << ControllingExpr->
getType();
1551 unsigned ResultIndex =
1552 CompatIndices.size() ? CompatIndices[0] : DefaultIndex;
1555 Context, KeyLoc, ControllingExpr, Types, Exprs, DefaultLoc, RParenLoc,
1556 ContainsUnexpandedParameterPack, ResultIndex);
1574 assert(Args.size() <= 2 &&
"too many arguments for literal operator");
1577 for (
unsigned ArgIdx = 0; ArgIdx != Args.size(); ++ArgIdx) {
1578 ArgTy[ArgIdx] = Args[ArgIdx]->getType();
1579 if (ArgTy[ArgIdx]->isArrayType())
1605 assert(!StringToks.empty() &&
"Must have at least one string!");
1608 if (Literal.hadError)
1612 for (
const Token &Tok : StringToks)
1613 StringTokLocs.push_back(Tok.getLocation());
1617 if (Literal.isWide()) {
1620 }
else if (Literal.isUTF8()) {
1622 }
else if (Literal.isUTF16()) {
1625 }
else if (Literal.isUTF32()) {
1628 }
else if (Literal.isPascal()) {
1634 if (getLangOpts().CPlusPlus || getLangOpts().ConstStrings)
1641 llvm::APInt(32, Literal.GetNumStringChars()+1),
1645 if (getLangOpts().OpenCL) {
1651 Kind, Literal.Pascal, StrTy,
1653 StringTokLocs.size());
1654 if (Literal.getUDSuffix().empty())
1661 Literal.getUDSuffixOffset());
1665 return ExprError(
Diag(UDSuffixLoc, diag::err_invalid_string_udl));
1680 LookupResult R(*
this, OpName, UDSuffixLoc, LookupOrdinaryName);
1681 switch (LookupLiteralOperator(UDLScope, R, ArgTy,
1689 Expr *Args[] = { Lit, LenArg };
1691 return BuildLiteralOperatorCall(R, OpNameInfo, Args, StringTokLocs.back());
1694 case LOLR_StringTemplate: {
1699 llvm::APSInt
Value(CharBits, CharIsUnsigned);
1705 for (
unsigned I = 0, N = Lit->
getLength();
I != N; ++
I) {
1711 return BuildLiteralOperatorCall(R, OpNameInfo,
None, StringTokLocs.back(),
1716 llvm_unreachable(
"unexpected literal operator lookup result");
1720 llvm_unreachable(
"unexpected literal operator lookup result");
1728 return BuildDeclRefExpr(D, Ty, VK, NameInfo, SS);
1738 if (getLangOpts().CUDA)
1739 if (
const FunctionDecl *Caller = dyn_cast<FunctionDecl>(CurContext))
1740 if (
const FunctionDecl *Callee = dyn_cast<FunctionDecl>(D)) {
1741 if (CheckCUDATarget(Caller, Callee)) {
1742 Diag(NameInfo.
getLoc(), diag::err_ref_bad_target)
1744 << IdentifyCUDATarget(Caller);
1745 Diag(D->getLocation(), diag::note_previous_decl)
1751 bool RefersToCapturedVariable =
1753 NeedToCaptureVariable(cast<VarDecl>(D), NameInfo.
getLoc());
1756 if (isa<VarTemplateSpecializationDecl>(D)) {
1758 cast<VarTemplateSpecializationDecl>(D);
1763 RefersToCapturedVariable, NameInfo.
getLoc(), Ty, VK,
1764 FoundD, TemplateArgs);
1766 assert(!TemplateArgs &&
"No template arguments for non-variable"
1767 " template specialization references");
1771 NameInfo, Ty, VK, FoundD);
1774 MarkDeclRefReferenced(E);
1776 if (getLangOpts().ObjCWeak && isa<VarDecl>(D) &&
1778 !Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, E->getLocStart()))
1779 recordUseOfEvaluatedWeak(E);
1781 if (
FieldDecl *FD = dyn_cast<FieldDecl>(D)) {
1782 UnusedPrivateFields.remove(FD);
1784 if (FD->isBitField())
1811 translateTemplateArguments(TemplateArgsPtr, Buffer);
1818 NameInfo = GetNameFromUnqualifiedId(Id);
1819 TemplateArgs =
nullptr;
1826 unsigned DiagnosticID,
unsigned DiagnosticSuggestID) {
1833 SemaRef.
Diag(TypoLoc, diag::err_no_member) << Typo << Ctx
1836 SemaRef.
Diag(TypoLoc, DiagnosticID) <<
Typo;
1841 bool DroppedSpecifier =
1844 ? diag::note_implicit_param_decl
1845 : diag::note_previous_decl;
1848 SemaRef.
PDiag(NoteID));
1851 << Typo << Ctx << DroppedSpecifier
1853 SemaRef.
PDiag(NoteID));
1861 std::unique_ptr<CorrectionCandidateCallback> CCC,
1866 unsigned diagnostic = diag::err_undeclared_var_use;
1867 unsigned diagnostic_suggest = diag::err_undeclared_var_use_suggest;
1871 diagnostic = diag::err_undeclared_use;
1872 diagnostic_suggest = diag::err_undeclared_use_suggest;
1881 if (isa<CXXRecordDecl>(DC)) {
1882 LookupQualifiedName(R, DC);
1891 bool isDefaultArgument = !ActiveTemplateInstantiations.empty() &&
1892 ActiveTemplateInstantiations.back().Kind ==
1893 ActiveTemplateInstantiation::DefaultFunctionArgumentInstantiation;
1895 bool isInstance = CurMethod &&
1897 DC == CurMethod->
getParent() && !isDefaultArgument;
1902 if (getLangOpts().MSVCCompat)
1903 diagnostic = diag::ext_found_via_dependent_bases_lookup;
1914 Diag(D->getLocation(), diag::note_dependent_var_use);
1920 if (isDefaultArgument && ((*R.begin())->isCXXInstanceMember())) {
1921 Diag(R.getNameLoc(), diag::err_member_call_without_object);
1936 if (getLangOpts().MSVCCompat && isa<FunctionDecl>(DC) &&
1937 cast<FunctionDecl>(DC)->getFriendObjectKind() &&
1948 assert(!ExplicitTemplateArgs &&
1949 "Diagnosing an empty lookup with explicit template args!");
1950 *Out = CorrectTypoDelayed(
1954 diagnostic, diagnostic_suggest);
1956 nullptr, CTK_ErrorRecovery);
1959 }
else if (S && (Corrected =
1961 &SS, std::move(CCC), CTK_ErrorRecovery))) {
1962 std::string CorrectedStr(Corrected.
getAsString(getLangOpts()));
1963 bool DroppedSpecifier =
1967 bool AcceptableWithRecovery =
false;
1968 bool AcceptableWithoutRecovery =
false;
1977 dyn_cast<FunctionTemplateDecl>(CD))
1978 AddTemplateOverloadCandidate(
1981 else if (
FunctionDecl *FD = dyn_cast<FunctionDecl>(CD))
1982 if (!ExplicitTemplateArgs || ExplicitTemplateArgs->
size() == 0)
1986 switch (OCS.BestViableFunction(*
this, R.
getNameLoc(), Best)) {
1988 ND = Best->FoundDecl;
1989 Corrected.setCorrectionDecl(ND);
1993 Corrected.setCorrectionDecl(ND);
2005 Record = cast<CXXRecordDecl>(
2006 ND->getDeclContext()->getRedeclContext());
2011 AcceptableWithRecovery = isa<ValueDecl>(UnderlyingND) ||
2012 isa<FunctionTemplateDecl>(UnderlyingND);
2018 AcceptableWithoutRecovery =
2019 isa<TypeDecl>(UnderlyingND) || isa<ObjCInterfaceDecl>(UnderlyingND);
2023 AcceptableWithoutRecovery =
true;
2026 if (AcceptableWithRecovery || AcceptableWithoutRecovery) {
2028 ? diag::note_implicit_param_decl
2029 : diag::note_previous_decl;
2031 diagnoseTypo(Corrected, PDiag(diagnostic_suggest) <<
Name,
2032 PDiag(NoteID), AcceptableWithRecovery);
2034 diagnoseTypo(Corrected, PDiag(diag::err_no_member_suggest)
2035 << Name << computeDeclContext(SS,
false)
2036 << DroppedSpecifier << SS.getRange(),
2037 PDiag(NoteID), AcceptableWithRecovery);
2040 return !AcceptableWithRecovery;
2047 if (!SS.isEmpty()) {
2049 << Name << computeDeclContext(SS,
false)
2076 else if (
auto *MD = dyn_cast<CXXMethodDecl>(S.
CurContext))
2084 auto DB = S.
Diag(Loc, diag::ext_undeclared_unqual_id_with_dependent_base);
2085 DB << NameInfo.
getName() << RD;
2087 if (!ThisType.
isNull()) {
2090 Context,
nullptr, ThisType,
true,
2092 nullptr, NameInfo, TemplateArgs);
2109 bool HasTrailingLParen,
bool IsAddressOfOperand,
2110 std::unique_ptr<CorrectionCandidateCallback> CCC,
2111 bool IsInlineAsmIdentifier,
Token *KeywordReplacement) {
2112 assert(!(IsAddressOfOperand && HasTrailingLParen) &&
2113 "cannot be direct & operand and have a trailing lparen");
2122 DecomposeUnqualifiedId(Id, TemplateArgsBuffer, NameInfo, TemplateArgs);
2139 bool DependentID =
false;
2143 }
else if (SS.
isSet()) {
2144 if (
DeclContext *DC = computeDeclContext(SS,
false)) {
2145 if (RequireCompleteDeclContext(SS, DC))
2153 return ActOnDependentIdExpression(SS, TemplateKWLoc, NameInfo,
2154 IsAddressOfOperand, TemplateArgs);
2159 ? LookupObjCImplicitSelfParam : LookupOrdinaryName);
2166 bool MemberOfUnknownSpecialization;
2167 LookupTemplateName(R, S, SS,
QualType(),
false,
2168 MemberOfUnknownSpecialization);
2170 if (MemberOfUnknownSpecialization ||
2172 return ActOnDependentIdExpression(SS, TemplateKWLoc, NameInfo,
2173 IsAddressOfOperand, TemplateArgs);
2175 bool IvarLookupFollowUp = II && !SS.
isSet() && getCurMethodDecl();
2176 LookupParsedName(R, S, &SS, !IvarLookupFollowUp);
2181 return ActOnDependentIdExpression(SS, TemplateKWLoc, NameInfo,
2182 IsAddressOfOperand, TemplateArgs);
2186 if (IvarLookupFollowUp) {
2201 if (R.
empty() && HasTrailingLParen && II && !getLangOpts().CPlusPlus) {
2202 NamedDecl *D = ImplicitlyDefineFunction(NameLoc, *II, S);
2208 bool ADL = UseArgumentDependentLookup(SS, R, HasTrailingLParen);
2210 if (R.
empty() && !ADL) {
2211 if (SS.
isEmpty() && getLangOpts().MSVCCompat) {
2213 TemplateKWLoc, TemplateArgs))
2218 if (IsInlineAsmIdentifier)
2224 auto DefaultValidator = llvm::make_unique<CorrectionCandidateCallback>(
2226 DefaultValidator->IsAddressOfOperand = IsAddressOfOperand;
2227 assert((!CCC || CCC->IsAddressOfOperand == IsAddressOfOperand) &&
2228 "Typo correction callback misconfigured");
2231 CCC->setTypoName(II);
2235 if (DiagnoseEmptyLookup(S, SS, R,
2236 CCC ? std::move(CCC) : std::move(DefaultValidator),
2237 nullptr,
None, &TE)) {
2238 if (TE && KeywordReplacement) {
2239 auto &
State = getTypoExprState(TE);
2240 auto BestTC =
State.Consumer->getNextCorrection();
2241 if (BestTC.isKeyword()) {
2242 auto *II = BestTC.getCorrectionAsIdentifierInfo();
2243 if (
State.DiagHandler)
2244 State.DiagHandler(BestTC);
2246 KeywordReplacement->
setKind(II->getTokenID());
2248 KeywordReplacement->
setLocation(BestTC.getCorrectionRange().getBegin());
2251 clearDelayedTypo(TE);
2254 return (
Expr*)
nullptr;
2256 State.Consumer->resetCorrectionStream();
2261 assert(!R.
empty() &&
2262 "DiagnoseEmptyLookup returned false but added no results");
2269 ExprResult E(LookupInObjCMethod(R, S, Ivar->getIdentifier()));
2279 assert(!R.
empty() || ADL);
2305 if (!R.
empty() && (*R.
begin())->isCXXClassMember()) {
2306 bool MightBeImplicitMember;
2307 if (!IsAddressOfOperand)
2308 MightBeImplicitMember =
true;
2310 MightBeImplicitMember =
false;
2312 MightBeImplicitMember =
false;
2314 MightBeImplicitMember =
true;
2316 MightBeImplicitMember = isa<FieldDecl>(R.
getFoundDecl()) ||
2320 if (MightBeImplicitMember)
2321 return BuildPossibleImplicitMemberExpr(SS, TemplateKWLoc,
2322 R, TemplateArgs, S);
2325 if (TemplateArgs || TemplateKWLoc.
isValid()) {
2333 "There should only be one declaration found.");
2336 return BuildTemplateIdExpr(SS, TemplateKWLoc, R, ADL, TemplateArgs);
2339 return BuildDeclarationNameExpr(SS, R, ADL);
2354 if (RequireCompleteDeclContext(SS, DC))
2358 LookupQualifiedName(R, DC);
2377 unsigned DiagID = diag::err_typename_missing;
2378 if (RecoveryTSI && getLangOpts().MSVCCompat)
2379 DiagID = diag::ext_typename_missing;
2381 auto D =
Diag(Loc, DiagID);
2412 if (!R.
empty() && (*R.
begin())->isCXXClassMember() && !IsAddressOfOperand)
2413 return BuildPossibleImplicitMemberExpr(SS,
2417 return BuildDeclarationNameExpr(SS, R,
false);
2451 LookForIvars =
true;
2452 else if (IsClassMethod)
2453 LookForIvars =
false;
2456 Lookup.
getFoundDecl()->isDefinedOutsideFunctionOrMethod());
2465 return ExprError(
Diag(Loc, diag::error_ivar_use_in_class_method)
2470 if (IV->isInvalidDecl())
2474 if (DiagnoseUseOfDecl(IV, Loc))
2480 !getLangOpts().DebuggerSupport)
2491 ExprResult SelfExpr = ActOnIdExpression(S, SelfScopeSpec, TemplateKWLoc,
2492 SelfName,
false,
false);
2496 SelfExpr = DefaultLvalueConversion(SelfExpr.
get());
2500 MarkAnyDeclReferenced(Loc, IV,
true);
2504 !IvarBacksCurrentMethodAccessor(IFace, CurMethod, IV))
2509 IV->getLocation(), SelfExpr.
get(),
true,
true);
2511 if (getLangOpts().ObjCAutoRefCount) {
2513 if (!Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, Loc))
2514 recordUseOfEvaluatedWeak(Result);
2516 if (CurContext->isClosure())
2517 Diag(Loc, diag::warn_implicitly_retains_self)
2530 Diag(Loc, diag::warn_ivar_use_hidden) << IV->getDeclName();
2534 Lookup.
getFoundDecl()->isDefinedOutsideFunctionOrMethod()) {
2537 return ExprError(
Diag(Loc, diag::error_ivar_use_in_class_method)
2538 << IV->getDeclName());
2541 if (Lookup.
empty() && II && AllowBuiltinCreation) {
2587 bool PointerConversions =
false;
2588 if (isa<FieldDecl>(Member)) {
2594 PointerConversions =
true;
2596 DestType = DestRecordType;
2597 FromRecordType = FromType;
2599 }
else if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Member)) {
2600 if (Method->isStatic())
2603 DestType = Method->getThisType(
Context);
2608 PointerConversions =
true;
2610 FromRecordType = FromType;
2611 DestType = DestRecordType;
2648 if (Qualifier && Qualifier->
getAsType()) {
2650 assert(QType->
isRecordType() &&
"lookup done with non-record type");
2657 if (IsDerivedFrom(FromLoc, FromRecordType, QRecordType)) {
2659 if (CheckDerivedToBaseConversion(FromRecordType, QRecordType,
2660 FromLoc, FromRange, &BasePath))
2663 if (PointerConversions)
2665 From = ImpCastExprToType(From, QType, CK_UncheckedDerivedToBase,
2666 VK, &BasePath).get();
2669 FromRecordType = QRecordType;
2678 bool IgnoreAccess =
false;
2685 if (FoundDecl->getDeclContext() != Member->getDeclContext()) {
2686 assert(isa<UsingShadowDecl>(FoundDecl));
2688 cast<CXXRecordDecl>(FoundDecl->getDeclContext()));
2693 assert(IsDerivedFrom(FromLoc, FromRecordType, URecordType));
2695 if (CheckDerivedToBaseConversion(FromRecordType, URecordType,
2696 FromLoc, FromRange, &BasePath))
2700 if (PointerConversions)
2702 From = ImpCastExprToType(From, UType, CK_UncheckedDerivedToBase,
2703 VK, &BasePath).get();
2705 FromRecordType = URecordType;
2710 IgnoreAccess =
true;
2714 if (CheckDerivedToBaseConversion(FromRecordType, DestRecordType,
2715 FromLoc, FromRange, &BasePath,
2719 return ImpCastExprToType(From, DestType, CK_UncheckedDerivedToBase,
2725 bool HasTrailingLParen) {
2727 if (!HasTrailingLParen)
2735 if (!getLangOpts().CPlusPlus)
2745 if (D->isCXXClassMember())
2754 if (isa<UsingShadowDecl>(D))
2755 D = cast<UsingShadowDecl>(D)->getTargetDecl();
2756 else if (D->getLexicalDeclContext()->isFunctionOrMethod())
2763 if (isa<FunctionDecl>(D)) {
2769 }
else if (!isa<FunctionTemplateDecl>(D))
2782 if (isa<TypedefNameDecl>(D)) {
2787 if (isa<ObjCInterfaceDecl>(D)) {
2792 if (isa<NamespaceDecl>(D)) {
2802 bool AcceptInvalidDecl) {
2836 bool AcceptInvalidDecl) {
2837 assert(D &&
"Cannot refer to a NULL declaration");
2838 assert(!isa<FunctionTemplateDecl>(D) &&
2839 "Cannot refer unambiguously to a function template");
2845 if (
TemplateDecl *Template = dyn_cast<TemplateDecl>(D)) {
2848 Diag(Loc, diag::err_template_decl_ref) << (isa<VarTemplateDecl>(D) ? 1 : 0)
2850 Diag(Template->getLocation(), diag::note_template_decl_here);
2857 Diag(Loc, diag::err_ref_non_value)
2859 Diag(D->getLocation(), diag::note_declared_at);
2867 if (DiagnoseUseOfDecl(VD, Loc))
2871 if (VD->isInvalidDecl() && !AcceptInvalidDecl)
2878 if (!indirectField->isCXXClassMember())
2879 return BuildAnonymousStructUnionMemberReference(SS, NameInfo.
getLoc(),
2886 switch (D->getKind()) {
2888 #define ABSTRACT_DECL(kind)
2889 #define VALUE(type, base)
2890 #define DECL(type, base) \
2892 #include "clang/AST/DeclNodes.inc"
2893 llvm_unreachable(
"invalid value decl kind");
2896 case Decl::ObjCAtDefsField:
2897 case Decl::ObjCIvar:
2898 llvm_unreachable(
"forming non-member reference to ivar?");
2902 case Decl::EnumConstant:
2903 case Decl::UnresolvedUsingValue:
2904 case Decl::OMPDeclareReduction:
2913 case Decl::IndirectField:
2915 "building reference to field in C?");
2925 case Decl::NonTypeTemplateParm: {
2940 case Decl::VarTemplateSpecialization:
2941 case Decl::VarTemplatePartialSpecialization:
2942 case Decl::OMPCapturedExpr:
2952 case Decl::ImplicitParam:
2953 case Decl::ParmVar: {
2961 if (!isUnevaluatedContext()) {
2962 QualType CapturedType = getCapturedDeclRefType(cast<VarDecl>(VD), Loc);
2963 if (!CapturedType.
isNull())
2964 type = CapturedType;
2970 case Decl::Function: {
2971 if (
unsigned BID = cast<FunctionDecl>(VD)->getBuiltinID()) {
2990 if (getLangOpts().CPlusPlus) {
3000 if (!cast<FunctionDecl>(VD)->hasPrototype() &&
3001 isa<FunctionProtoType>(fty))
3010 case Decl::MSProperty:
3014 case Decl::CXXMethod:
3019 = dyn_cast<FunctionProtoType>(VD->
getType()))
3027 if (cast<CXXMethodDecl>(VD)->isStatic()) {
3033 case Decl::CXXConversion:
3034 case Decl::CXXDestructor:
3035 case Decl::CXXConstructor:
3040 return BuildDeclRefExpr(VD, type, valueKind, NameInfo, &SS, FoundD,
3047 Target.resize(CharByteWidth * (Source.size() + 1));
3048 char *ResultPtr = &Target[0];
3049 const UTF8 *ErrorPtr;
3050 bool success = ConvertUTF8toWide(CharByteWidth, Source, ResultPtr, ErrorPtr);
3053 Target.resize(ResultPtr - &Target[0]);
3059 Decl *currentDecl =
nullptr;
3061 currentDecl = BSI->TheDecl;
3063 currentDecl = LSI->CallOperator;
3065 currentDecl = CSI->TheCapturedDecl;
3067 currentDecl = getCurFunctionOrMethodDecl();
3070 Diag(Loc, diag::ext_predef_outside_function);
3076 if (cast<DeclContext>(currentDecl)->isDependentContext())
3082 unsigned Length = Str.length();
3084 llvm::APInt LengthI(32, Length + 1);
3110 default: llvm_unreachable(
"Unknown simple primary expr!");
3119 return BuildPredefinedExpr(Loc, IT);
3124 bool Invalid =
false;
3125 StringRef ThisTok = PP.getSpelling(Tok, CharBuffer, &Invalid);
3131 if (Literal.hadError())
3135 if (Literal.isWide())
3137 else if (Literal.isUTF16())
3139 else if (Literal.isUTF32())
3141 else if (!getLangOpts().CPlusPlus || Literal.isMultiChar())
3147 if (Literal.isWide())
3149 else if (Literal.isUTF16())
3151 else if (Literal.isUTF32())
3153 else if (Literal.isUTF8())
3159 if (Literal.getUDSuffix().empty())
3169 return ExprError(
Diag(UDSuffixLoc, diag::err_invalid_character_udl));
3187 using llvm::APFloat;
3188 APFloat Val(Format);
3194 if ((result & APFloat::opOverflow) ||
3195 ((result & APFloat::opUnderflow) && Val.isZero())) {
3196 unsigned diagnostic;
3198 if (result & APFloat::opOverflow) {
3199 diagnostic = diag::warn_float_overflow;
3200 APFloat::getLargest(Format).toString(buffer);
3202 diagnostic = diag::warn_float_underflow;
3203 APFloat::getSmallest(Format).toString(buffer);
3206 S.
Diag(Loc, diagnostic)
3208 << StringRef(buffer.data(), buffer.size());
3211 bool isExact = (result == APFloat::opOK);
3216 assert(E &&
"Invalid expression");
3223 Diag(E->
getExprLoc(), diag::err_pragma_loop_invalid_argument_type) << QT;
3227 llvm::APSInt ValueAPS;
3228 ExprResult R = VerifyIntegerConstantExpression(E, &ValueAPS);
3233 bool ValueIsPositive = ValueAPS.isStrictlyPositive();
3234 if (!ValueIsPositive || ValueAPS.getActiveBits() > 31) {
3235 Diag(E->
getExprLoc(), diag::err_pragma_loop_invalid_argument_value)
3236 << ValueAPS.toString(10) << ValueIsPositive;
3247 const char Val = PP.getSpellingOfSingleCharacterNumericConstant(Tok);
3248 return ActOnIntegerConstant(Tok.
getLocation(), Val-
'0');
3256 SpellingBuffer.resize(Tok.
getLength() + 1);
3259 bool Invalid =
false;
3260 StringRef TokSpelling = PP.getSpelling(Tok, SpellingBuffer, &Invalid);
3265 if (Literal.hadError)
3268 if (Literal.hasUDSuffix()) {
3276 return ExprError(
Diag(UDSuffixLoc, diag::err_invalid_numeric_udl));
3279 if (Literal.isFloatingLiteral()) {
3300 LookupResult R(*
this, OpName, UDSuffixLoc, LookupOrdinaryName);
3301 switch (LookupLiteralOperator(UDLScope, R, CookedTy,
3309 if (Literal.isFloatingLiteral()) {
3313 if (Literal.GetIntegerValue(ResultVal))
3319 return BuildLiteralOperatorCall(R, OpNameInfo, Lit, TokLoc);
3326 unsigned Length = Literal.getUDSuffixOffset();
3332 false, StrTy, &TokLoc, 1);
3333 return BuildLiteralOperatorCall(R, OpNameInfo, Lit, TokLoc);
3336 case LOLR_Template: {
3343 bool CharIsUnsigned =
Context.
CharTy->isUnsignedIntegerType();
3344 llvm::APSInt
Value(CharBits, CharIsUnsigned);
3345 for (
unsigned I = 0, N = Literal.getUDSuffixOffset();
I != N; ++
I) {
3346 Value = TokSpelling[
I];
3351 return BuildLiteralOperatorCall(R, OpNameInfo,
None, TokLoc,
3354 case LOLR_StringTemplate:
3355 llvm_unreachable(
"unexpected literal operator lookup result");
3361 if (Literal.isFloatingLiteral()) {
3363 if (Literal.isHalf){
3364 if (getOpenCLOptions().cl_khr_fp16)
3370 }
else if (Literal.isFloat)
3372 else if (Literal.isLong)
3374 else if (Literal.isFloat128)
3382 if (getLangOpts().SinglePrecisionConstants) {
3383 Res = ImpCastExprToType(Res,
Context.
FloatTy, CK_FloatingCast).get();
3384 }
else if (getLangOpts().OpenCL &&
3385 !((getLangOpts().OpenCLVersion >= 120) ||
3386 getOpenCLOptions().cl_khr_fp64)) {
3388 Res = ImpCastExprToType(Res,
Context.
FloatTy, CK_FloatingCast).get();
3391 }
else if (!Literal.isIntegerLiteral()) {
3397 if (!getLangOpts().
C99 && Literal.isLongLong) {
3399 Diag(Tok.getLocation(),
3400 getLangOpts().CPlusPlus11 ?
3401 diag::warn_cxx98_compat_longlong : diag::ext_cxx11_longlong);
3403 Diag(Tok.getLocation(), diag::ext_c99_longlong);
3408 llvm::APInt ResultVal(MaxWidth, 0);
3410 if (Literal.GetIntegerValue(ResultVal)) {
3412 Diag(Tok.getLocation(), diag::err_integer_literal_too_large)
3416 "long long is not intmax_t?");
3423 bool AllowUnsigned = Literal.isUnsigned || Literal.getRadix() != 10;
3429 if (Literal.MicrosoftInteger) {
3430 if (Literal.MicrosoftInteger == 8 && !Literal.isUnsigned) {
3434 Width = Literal.MicrosoftInteger;
3436 !Literal.isUnsigned);
3440 if (Ty.isNull() && !Literal.isLong && !Literal.isLongLong) {
3445 if (ResultVal.isIntN(IntSize)) {
3447 if (!Literal.isUnsigned && ResultVal[IntSize-1] == 0)
3449 else if (AllowUnsigned)
3456 if (Ty.isNull() && !Literal.isLongLong) {
3460 if (ResultVal.isIntN(LongSize)) {
3462 if (!Literal.isUnsigned && ResultVal[LongSize-1] == 0)
3464 else if (AllowUnsigned)
3468 else if (!getLangOpts().C99 && !getLangOpts().CPlusPlus11) {
3469 const unsigned LongLongSize =
3471 Diag(Tok.getLocation(),
3472 getLangOpts().CPlusPlus
3474 ? diag::warn_old_implicitly_unsigned_long_cxx
3476 ext_old_implicitly_unsigned_long_cxx
3477 : diag::warn_old_implicitly_unsigned_long)
3478 << (LongLongSize > LongSize ? 0
3491 if (ResultVal.isIntN(LongLongSize)) {
3495 if (!Literal.isUnsigned && (ResultVal[LongLongSize-1] == 0 ||
3496 (getLangOpts().MicrosoftExt && Literal.isLongLong)))
3498 else if (AllowUnsigned)
3500 Width = LongLongSize;
3507 Diag(Tok.getLocation(), diag::ext_integer_literal_too_large_for_signed);
3512 if (ResultVal.getBitWidth() != Width)
3513 ResultVal = ResultVal.trunc(Width);
3519 if (Literal.isImaginary)
3527 assert(E &&
"ActOnParenExpr() missing expr");
3539 S.
Diag(Loc, diag::err_vecstep_non_scalar_vector_type)
3545 "Scalar types should always be complete");
3561 S.
Diag(Loc, diag::ext_sizeof_alignof_function_type)
3562 << TraitKind << ArgRange;
3569 unsigned DiagID = S.
LangOpts.OpenCL ? diag::err_opencl_sizeof_alignof_type
3570 : diag::ext_sizeof_alignof_void_type;
3571 S.
Diag(Loc, DiagID) << TraitKind << ArgRange;
3585 S.
Diag(Loc, diag::err_sizeof_nonfragile_interface)
3604 if (!ICE || ICE->
getCastKind() != CK_ArrayToPointerDecay)
3607 S.
Diag(Loc, diag::warn_sizeof_array_decay) << ICE->getSourceRange()
3626 E->getSourceRange());
3630 E->getSourceRange(), ExprKind))
3640 diag::err_sizeof_alignof_incomplete_type, ExprKind,
3641 E->getSourceRange()))
3645 ExprKind, E->getSourceRange()))
3655 << ExprKind << E->getSourceRange();
3663 Diag(E->
getExprLoc(), diag::warn_side_effects_unevaluated_context);
3666 E->getSourceRange(), ExprKind))
3671 if (
ParmVarDecl *PVD = dyn_cast<ParmVarDecl>(DeclRef->getFoundDecl())) {
3672 QualType OType = PVD->getOriginalType();
3677 Diag(PVD->getLocation(), diag::note_declared_at);
3742 diag::err_sizeof_alignof_incomplete_type,
3743 ExprKind, ExprRange))
3747 Diag(OpLoc, diag::err_sizeof_alignof_function_type)
3748 << ExprKind << ExprRange;
3767 S.
Diag(E->
getExprLoc(), diag::err_sizeof_alignof_typeof_bitfield)
3768 << 1 << E->getSourceRange();
3773 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
3775 }
else if (
MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
3776 D = ME->getMemberDecl();
3796 if (
FieldDecl *FD = dyn_cast_or_null<FieldDecl>(D)) {
3799 if (!FD->getParent()->isCompleteDefinition()) {
3800 S.
Diag(E->
getExprLoc(), diag::err_alignof_member_of_incomplete_type)
3801 << E->getSourceRange();
3809 if (!FD->getType()->isReferenceType())
3829 assert(CSI !=
nullptr);
3835 #define TYPE(Class, Base)
3836 #define ABSTRACT_TYPE(Class, Base)
3837 #define NON_CANONICAL_TYPE(Class, Base)
3838 #define DEPENDENT_TYPE(Class, Base) case Type::Class:
3839 #define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base)
3840 #include "clang/AST/TypeNodes.def"
3847 case Type::ExtVector:
3850 case Type::Elaborated:
3851 case Type::TemplateSpecialization:
3852 case Type::ObjCObject:
3853 case Type::ObjCInterface:
3854 case Type::ObjCObjectPointer:
3856 llvm_unreachable(
"type class is never variably-modified!");
3857 case Type::Adjusted:
3858 T = cast<AdjustedType>(Ty)->getOriginalType();
3861 T = cast<DecayedType>(Ty)->getPointeeType();
3864 T = cast<PointerType>(Ty)->getPointeeType();
3866 case Type::BlockPointer:
3867 T = cast<BlockPointerType>(Ty)->getPointeeType();
3869 case Type::LValueReference:
3870 case Type::RValueReference:
3871 T = cast<ReferenceType>(Ty)->getPointeeType();
3873 case Type::MemberPointer:
3874 T = cast<MemberPointerType>(Ty)->getPointeeType();
3876 case Type::ConstantArray:
3877 case Type::IncompleteArray:
3879 T = cast<ArrayType>(Ty)->getElementType();
3881 case Type::VariableArray: {
3890 if (
auto LSI = dyn_cast<LambdaScopeInfo>(CSI)) {
3891 CapRecord = LSI->Lambda;
3892 }
else if (
auto CRSI = dyn_cast<CapturedRegionScopeInfo>(CSI)) {
3893 CapRecord = CRSI->TheRecordDecl;
3896 auto ExprLoc = Size->getExprLoc();
3901 nullptr, SizeType,
nullptr,
3904 Field->setImplicit(
true);
3906 Field->setCapturedVLAType(VAT);
3916 case Type::FunctionProto:
3917 case Type::FunctionNoProto:
3918 T = cast<FunctionType>(Ty)->getReturnType();
3922 case Type::UnaryTransform:
3923 case Type::Attributed:
3924 case Type::SubstTemplateTypeParm:
3925 case Type::PackExpansion:
3930 T = cast<TypedefType>(Ty)->
desugar();
3932 case Type::Decltype:
3933 T = cast<DecltypeType>(Ty)->
desugar();
3936 T = cast<AutoType>(Ty)->getDeducedType();
3938 case Type::TypeOfExpr:
3939 T = cast<TypeOfExprType>(Ty)->getUnderlyingExpr()->getType();
3942 T = cast<AtomicType>(Ty)->getValueType();
3972 if (
auto *LSI = dyn_cast<LambdaScopeInfo>(CSI))
3973 DC = LSI->CallOperator;
3974 else if (
auto *CRSI = dyn_cast<CapturedRegionScopeInfo>(CSI))
3975 DC = CRSI->TheCapturedDecl;
3976 else if (
auto *BSI = dyn_cast<BlockScopeInfo>(CSI))
4015 Diag(E->
getExprLoc(), diag::err_sizeof_alignof_typeof_bitfield) << 0;
4058 if (V.
get()->isTypeDependent())
4070 return CT->getElementType();
4073 if (V.
get()->getType()->isArithmeticType())
4074 return V.
get()->getType();
4079 if (PR.
get() != V.
get()) {
4085 S.
Diag(Loc, diag::err_realimag_invalid_type) << V.
get()->getType()
4086 << (IsReal ?
"__real" :
"__imag");
4097 default: llvm_unreachable(
"Unknown unary op!");
4098 case tok::plusplus: Opc = UO_PostInc;
break;
4099 case tok::minusminus: Opc = UO_PostDec;
break;
4105 Input = Result.
get();
4118 !S.
LangOpts.ObjCSubscriptingLegacyRuntime)
4121 S.
Diag(opLoc, diag::err_arithmetic_nonfragile_interface)
4123 << op->getSourceRange();
4129 if (
auto *MSProp = dyn_cast<MSPropertyRefExpr>(BaseNoParens))
4131 return isa<MSPropertySubscriptExpr>(BaseNoParens);
4143 if (isa<ParenListExpr>(base)) {
4146 base = result.
get();
4154 bool IsMSPropertySubscript =
false;
4157 if (!IsMSPropertySubscript) {
4161 base = result.
get();
4185 if (IsMSPropertySubscript) {
4216 BuiltinType::OMPArraySection)) {
4220 Base = Result.
get();
4229 LowerBound = Result.
get();
4238 Length = Result.
get();
4261 << Base->getSourceRange());
4267 if (Res.isInvalid())
4269 diag::err_omp_typecheck_section_not_integer)
4270 << 0 << LowerBound->getSourceRange());
4271 LowerBound = Res.get();
4276 << 0 << LowerBound->getSourceRange();
4281 if (Res.isInvalid())
4283 diag::err_omp_typecheck_section_not_integer)
4284 << 1 << Length->getSourceRange());
4290 << 1 << Length->getSourceRange();
4299 << ResultTy << Base->getSourceRange();
4304 diag::err_omp_section_incomplete_type, Base))
4308 llvm::APSInt LowerBoundValue;
4312 if (LowerBoundValue.isNegative()) {
4314 << 0 << LowerBoundValue.toString(10,
true)
4315 << LowerBound->getSourceRange();
4322 llvm::APSInt LengthValue;
4326 if (LengthValue.isNegative()) {
4328 << 1 << LengthValue.toString(10,
true)
4329 << Length->getSourceRange();
4333 }
else if (ColonLoc.
isValid() &&
4339 Diag(ColonLoc, diag::err_omp_section_length_undefined)
4345 BuiltinType::OMPArraySection)) {
4349 Base = Result.
get();
4359 Expr *LHSExp = Base;
4367 LHSExp = Result.
get();
4372 RHSExp = Result.
get();
4382 Expr *BaseExpr, *IndexExpr;
4416 Diag(LLoc, diag::err_subscript_nonfragile_interface)
4417 << ResultType << BaseExpr->getSourceRange();
4428 ResultType = VTy->getElementType();
4435 Diag(LHSExp->getLocStart(), diag::ext_subscript_non_lvalue) <<
4436 LHSExp->getSourceRange();
4438 CK_ArrayToPointerDecay).
get();
4444 }
else if (RHSTy->isArrayType()) {
4446 Diag(RHSExp->getLocStart(), diag::ext_subscript_non_lvalue) <<
4447 RHSExp->getSourceRange();
4449 CK_ArrayToPointerDecay).
get();
4456 return ExprError(
Diag(LLoc, diag::err_typecheck_subscript_value)
4457 << LHSExp->getSourceRange() << RHSExp->getSourceRange());
4461 return ExprError(
Diag(LLoc, diag::err_typecheck_subscript_not_integer)
4462 << IndexExpr->getSourceRange());
4467 Diag(LLoc, diag::warn_subscript_is_char) << IndexExpr->getSourceRange();
4474 Diag(BaseExpr->getLocStart(), diag::err_subscript_function_type)
4475 << ResultType << BaseExpr->getSourceRange();
4481 Diag(LLoc, diag::ext_gnu_subscript_void_type)
4482 << BaseExpr->getSourceRange();
4489 diag::err_subscript_incomplete_type, BaseExpr))
4504 diag::err_use_of_default_argument_to_function_declared_later) <<
4505 FD << cast<CXXRecordDecl>(FD->getDeclContext())->getDeclName();
4507 diag::note_default_argument_declared_here);
4523 if (Inst.isInvalid())
4534 Result =
SubstExpr(UninstExpr, MutiLevelArgList);
4544 UninstExpr->getLocStart());
4548 Result = InitSeq.Perform(*
this, Entity, Kind, ResultE);
4560 L->DefaultArgumentInstantiated(Param);
4566 Diag(Param->
getLocStart(), diag::err_recursive_default_argument) << FD;
4567 Param->setInvalidDecl();
4578 if (
auto Init = dyn_cast<ExprWithCleanups>(Param->
getInit())) {
4586 assert(!Init->getNumObjects() &&
4587 "default argument expression has capturing blocks?");
4603 if (dyn_cast_or_null<CXXConstructorDecl>(FDecl))
4608 if (
CXXMethodDecl *Method = dyn_cast_or_null<CXXMethodDecl>(FDecl))
4609 if (Method->isInstance())
4624 FunctionName(FuncName) {}
4626 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
4650 llvm::make_unique<FunctionCallCCC>(
S, FuncName.getAsIdentifierInfo(),
4653 if (
NamedDecl *ND = Corrected.getFoundDecl()) {
4654 if (Corrected.isOverloaded()) {
4664 ND = Best->FoundDecl;
4665 Corrected.setCorrectionDecl(ND);
4671 ND = ND->getUnderlyingDecl();
4672 if (isa<ValueDecl>(ND) || isa<FunctionTemplateDecl>(ND))
4691 bool IsExecConfig) {
4701 bool Invalid =
false;
4710 if (Args.size() < NumParams) {
4711 if (Args.size() < MinArgs) {
4716 ? diag::err_typecheck_call_too_few_args_suggest
4717 : diag::err_typecheck_call_too_few_args_at_least_suggest;
4719 << static_cast<unsigned>(Args.size())
4724 ? diag::err_typecheck_call_too_few_args_one
4725 : diag::err_typecheck_call_too_few_args_at_least_one)
4726 << FnKind << FDecl->
getParamDecl(0) << Fn->getSourceRange();
4729 ? diag::err_typecheck_call_too_few_args
4730 : diag::err_typecheck_call_too_few_args_at_least)
4731 << FnKind << MinArgs << static_cast<unsigned>(Args.size())
4732 << Fn->getSourceRange();
4735 if (!TC && FDecl && !FDecl->
getBuiltinID() && !IsExecConfig)
4746 if (Args.size() > NumParams) {
4752 ? diag::err_typecheck_call_too_many_args_suggest
4753 : diag::err_typecheck_call_too_many_args_at_most_suggest;
4755 << static_cast<unsigned>(Args.size())
4757 }
else if (NumParams == 1 && FDecl &&
4759 Diag(Args[NumParams]->getLocStart(),
4760 MinArgs == NumParams
4761 ? diag::err_typecheck_call_too_many_args_one
4762 : diag::err_typecheck_call_too_many_args_at_most_one)
4764 <<
static_cast<unsigned>(Args.size()) << Fn->getSourceRange()
4766 Args.back()->getLocEnd());
4768 Diag(Args[NumParams]->getLocStart(),
4769 MinArgs == NumParams
4770 ? diag::err_typecheck_call_too_many_args
4771 : diag::err_typecheck_call_too_many_args_at_most)
4772 << FnKind << NumParams << static_cast<unsigned>(Args.size())
4773 << Fn->getSourceRange()
4775 Args.back()->getLocEnd());
4778 if (!TC && FDecl && !FDecl->
getBuiltinID() && !IsExecConfig)
4791 Proto, 0, Args, AllArgs, CallType);
4794 unsigned TotalNumArgs = AllArgs.size();
4795 for (
unsigned i = 0; i < TotalNumArgs; ++i)
4796 Call->
setArg(i, AllArgs[i]);
4806 bool IsListInitialization) {
4808 bool Invalid =
false;
4811 for (
unsigned i = FirstParam; i < NumParams; i++) {
4816 if (ArgIx < Args.size()) {
4817 Arg = Args[ArgIx++];
4821 diag::err_call_incomplete_argument, Arg))
4825 bool CFAudited =
false;
4827 FDecl && FDecl->hasAttr<CFAuditedTransferAttr>() &&
4828 (!Param || !Param->hasAttr<CFConsumedAttr>()))
4831 FDecl && FDecl->hasAttr<CFAuditedTransferAttr>() &&
4832 (!Param || !Param->hasAttr<CFConsumedAttr>()))
4846 Entity,
SourceLocation(), Arg, IsListInitialization, AllowExplicit);
4852 assert(Param &&
"can't use default arguments without a known callee");
4865 CheckArrayAccess(Arg);
4870 AllArgs.push_back(Arg);
4879 for (
Expr *A : Args.slice(ArgIx)) {
4883 AllArgs.push_back(arg.
get());
4888 for (
Expr *A : Args.slice(ArgIx)) {
4891 AllArgs.push_back(Arg.
get());
4896 for (
Expr *A : Args.slice(ArgIx))
4897 CheckArrayAccess(A);
4905 TL = DTL.getOriginalLoc();
4907 S.
Diag(PVD->getLocation(), diag::note_callee_static_array)
4908 << ATL.getLocalSourceRange();
4922 const Expr *ArgExpr) {
4935 Diag(CallLoc, diag::warn_null_arg) << ArgExpr->getSourceRange();
4950 Diag(CallLoc, diag::warn_static_array_too_small)
4951 << ArgExpr->getSourceRange()
4967 if (!placeholder)
return false;
4969 switch (placeholder->
getKind()) {
4971 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
4972 case BuiltinType::Id:
4973 #include "clang/Basic/OpenCLImageTypes.def"
4974 #define PLACEHOLDER_TYPE(ID, SINGLETON_ID)
4975 #define BUILTIN_TYPE(ID, SINGLETON_ID) case BuiltinType::ID:
4976 #include "clang/AST/BuiltinTypes.def"
4981 case BuiltinType::Overload:
4986 case BuiltinType::ARCUnbridgedCast:
4990 case BuiltinType::PseudoObject:
4995 case BuiltinType::UnknownAny:
4999 case BuiltinType::BoundMember:
5000 case BuiltinType::BuiltinFn:
5001 case BuiltinType::OMPArraySection:
5005 llvm_unreachable(
"bad builtin type kind");
5013 bool hasInvalid =
false;
5014 for (
size_t i = 0, e = args.size(); i != e; i++) {
5017 if (result.
isInvalid()) hasInvalid =
true;
5018 else args[i] = result.
get();
5019 }
else if (hasInvalid) {
5048 bool NeedsNewDecl =
false;
5057 if (!ParamType->isPointerType() ||
5058 ParamType.getQualifiers().hasAddressSpace() ||
5061 OverloadParams.push_back(ParamType);
5065 NeedsNewDecl =
true;
5078 OverloadParams, EPI);
5081 FDecl->getLocation(),
5082 FDecl->getLocation(),
5089 FT = cast<FunctionProtoType>(OverloadTy);
5090 for (
unsigned i = 0, e = FT->
getNumParams(); i != e; ++i) {
5097 Params.push_back(Parm);
5099 OverloadDecl->setParams(Params);
5100 return OverloadDecl;
5117 Expr *ExecConfig,
bool IsExecConfig) {
5128 if (isa<CXXPseudoDestructorExpr>(Fn)) {
5129 if (!ArgExprs.empty()) {
5131 Diag(Fn->getLocStart(), diag::err_pseudo_dtor_call_with_args)
5134 ArgExprs.back()->getLocEnd()));
5148 bool Dependent =
false;
5157 Context, Fn, cast<CallExpr>(ExecConfig), ArgExprs,
5190 RParenLoc, ExecConfig,
5206 bool CallingNDeclIndirectly =
false;
5208 if (
UnaryOperator *UnOp = dyn_cast<UnaryOperator>(NakedFn)) {
5209 if (UnOp->getOpcode() == UO_AddrOf) {
5210 CallingNDeclIndirectly =
true;
5215 if (isa<DeclRefExpr>(NakedFn)) {
5216 NDecl = cast<DeclRefExpr>(NakedFn)->getDecl();
5231 }
else if (isa<MemberExpr>(NakedFn))
5232 NDecl = cast<MemberExpr>(NakedFn)->getMemberDecl();
5234 if (
FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(NDecl)) {
5235 if (CallingNDeclIndirectly &&
5246 if (FD->hasAttr<EnableIfAttr>() &&
5249 Diag(Fn->getLocStart(),
5250 isa<CXXMethodDecl>(FD) ?
5251 diag::err_ovl_no_viable_member_function_in_call :
5252 diag::err_ovl_no_viable_function_in_call)
5253 << FD << FD->getSourceRange();
5254 Diag(FD->getLocation(),
5255 diag::note_ovl_candidate_disabled_by_enable_if_attr)
5256 <<
Attr->getCond()->getSourceRange() <<
Attr->getMessage();
5262 ExecConfig, IsExecConfig);
5278 diag::err_invalid_astype_of_different_size)
5281 << E->getSourceRange());
5309 Expr *Config,
bool IsExecConfig) {
5310 FunctionDecl *FDecl = dyn_cast_or_null<FunctionDecl>(NDecl);
5311 unsigned BuiltinID = (FDecl ? FDecl->
getBuiltinID() : 0);
5314 if (FDecl && FDecl->hasAttr<AnyX86InterruptAttr>()) {
5326 CK_BuiltinFnToFnPtr).
get();
5339 cast<CallExpr>(Config), Args,
5354 if (!TheCall)
return Result;
5360 return CheckBuiltinFunctionCall(FDecl, BuiltinID, TheCall);
5369 return ExprError(
Diag(LParenLoc, diag::err_typecheck_call_not_function)
5370 << Fn->
getType() << Fn->getSourceRange());
5384 return ExprError(
Diag(LParenLoc, diag::err_typecheck_call_not_function)
5385 << Fn->
getType() << Fn->getSourceRange());
5391 if (FDecl && !FDecl->hasAttr<CUDAGlobalAttr>())
5392 return ExprError(
Diag(LParenLoc,diag::err_kern_call_not_global_function)
5393 << FDecl->
getName() << Fn->getSourceRange());
5397 return ExprError(
Diag(LParenLoc, diag::err_kern_type_not_void_return)
5398 << Fn->
getType() << Fn->getSourceRange());
5401 if (FDecl && FDecl->hasAttr<CUDAGlobalAttr>())
5402 return ExprError(
Diag(LParenLoc, diag::err_global_call_not_config)
5403 << FDecl->
getName() << Fn->getSourceRange());
5422 assert(isa<FunctionNoProtoType>(FuncT) &&
"Unknown FunctionType!");
5431 Diag(RParenLoc, diag::warn_call_wrong_number_of_arguments)
5432 << (Args.size() > Def->
param_size()) << FDecl << Fn->getSourceRange();
5442 for (
unsigned i = 0, e = Args.size(); i != e; i++) {
5443 Expr *Arg = Args[i];
5445 if (Proto && i < Proto->getNumParams()) {
5450 if (ArgE.isInvalid())
5453 Arg = ArgE.getAs<
Expr>();
5466 diag::err_call_incomplete_argument, Arg))
5473 if (
CXXMethodDecl *Method = dyn_cast_or_null<CXXMethodDecl>(FDecl))
5474 if (!Method->isStatic())
5475 return ExprError(
Diag(LParenLoc, diag::err_member_call_without_object)
5476 << Fn->getSourceRange());
5484 if (CheckFunctionCall(FDecl, TheCall, Proto))
5488 return CheckBuiltinFunctionCall(FDecl, BuiltinID, TheCall);
5490 if (CheckPointerCall(NDecl, TheCall, Proto))
5493 if (CheckOtherCall(TheCall, Proto))
5503 assert(Ty &&
"ActOnCompoundLiteral(): missing type");
5504 assert(InitExpr &&
"ActOnCompoundLiteral(): missing expression");
5521 diag::err_illegal_decl_array_incomplete_type,
5523 LiteralExpr->getSourceRange().getEnd())))
5526 return ExprError(
Diag(LParenLoc, diag::err_variable_object_no_init)
5527 <<
SourceRange(LParenLoc, LiteralExpr->getSourceRange().getEnd()));
5530 diag::err_typecheck_decl_incomplete_type,
5531 SourceRange(LParenLoc, LiteralExpr->getSourceRange().getEnd())))
5545 LiteralExpr = Result.
get();
5561 VK, LiteralExpr, isFileScope));
5569 for (
unsigned I = 0,
E = InitArgList.size();
I !=
E; ++
I) {
5570 if (InitArgList[
I]->getType()->isNonOverloadPlaceholderType()) {
5577 InitArgList[
I] = result.
get();
5599 CK_ARCExtendBlockObject, E.
get(),
5612 return CK_BlockPointerToObjCPointerCast;
5615 return CK_CPointerToObjCPointerCast;
5632 llvm_unreachable(
"member pointer type in C");
5641 if (SrcAS != DestAS)
5642 return CK_AddressSpaceConversion;
5647 ? CK_BitCast : CK_AnyPointerToBlockPointerCast);
5652 return CK_CPointerToObjCPointerCast;
5654 return CK_BlockPointerToObjCPointerCast;
5656 return CK_PointerToBoolean;
5658 return CK_PointerToIntegral;
5663 llvm_unreachable(
"illegal cast from pointer");
5665 llvm_unreachable(
"Should have returned before this");
5675 return CK_NullToPointer;
5676 return CK_IntegralToPointer;
5678 return CK_IntegralToBoolean;
5680 return CK_IntegralCast;
5682 return CK_IntegralToFloating;
5687 return CK_IntegralRealToComplex;
5691 CK_IntegralToFloating);
5692 return CK_FloatingRealToComplex;
5694 llvm_unreachable(
"member pointer type in C");
5696 llvm_unreachable(
"Should have returned before this");
5701 return CK_FloatingCast;
5703 return CK_FloatingToBoolean;
5705 return CK_FloatingToIntegral;
5710 return CK_FloatingRealToComplex;
5714 CK_FloatingToIntegral);
5715 return CK_IntegralRealToComplex;
5719 llvm_unreachable(
"valid float->pointer cast?");
5721 llvm_unreachable(
"member pointer type in C");
5723 llvm_unreachable(
"Should have returned before this");
5728 return CK_FloatingComplexCast;
5730 return CK_FloatingComplexToIntegralComplex;
5734 return CK_FloatingComplexToReal;
5736 return CK_FloatingCast;
5739 return CK_FloatingComplexToBoolean;
5743 CK_FloatingComplexToReal);
5744 return CK_FloatingToIntegral;
5748 llvm_unreachable(
"valid complex float->pointer cast?");
5750 llvm_unreachable(
"member pointer type in C");
5752 llvm_unreachable(
"Should have returned before this");
5757 return CK_IntegralComplexToFloatingComplex;
5759 return CK_IntegralComplexCast;
5763 return CK_IntegralComplexToReal;
5765 return CK_IntegralCast;
5768 return CK_IntegralComplexToBoolean;
5772 CK_IntegralComplexToReal);
5773 return CK_IntegralToFloating;
5777 llvm_unreachable(
"valid complex int->pointer cast?");
5779 llvm_unreachable(
"member pointer type in C");
5781 llvm_unreachable(
"Should have returned before this");
5784 llvm_unreachable(
"Unhandled scalar cast");
5791 len = vecType->getNumElements();
5792 eltType = vecType->getElementType();
5824 uint64_t srcLen, destLen;
5835 return (srcLen * srcEltSize == destLen * destEltSize);
5850 assert(VectorTy->
isVectorType() &&
"Not a vector type!");
5856 diag::err_invalid_conversion_between_vectors :
5857 diag::err_invalid_conversion_between_vector_and_integer)
5858 << VectorTy << Ty << R;
5861 diag::err_invalid_conversion_between_vector_and_scalar)
5862 << VectorTy << Ty << R;
5871 if (DestElemTy == SplattedExpr->
getType())
5872 return SplattedExpr;
5885 CK_BooleanToSignedIntegral);
5886 SplattedExpr = CastExprRes.
get();
5887 CK = CK_IntegralToFloating;
5889 CK = CK_BooleanToSignedIntegral;
5896 SplattedExpr = CastExprRes.
get();
5911 if (SrcTy->isVectorType()) {
5915 Diag(R.
getBegin(),diag::err_invalid_conversion_between_ext_vectors)
5916 << DestTy << SrcTy << R;
5926 if (SrcTy->isPointerType())
5928 diag::err_invalid_conversion_between_vector_and_scalar)
5929 << DestTy << SrcTy << R;
5931 Kind = CK_VectorSplat;
5940 "ActOnCastExpr(): missing type or expr");
5954 CastExpr = Res.
get();
5962 bool isVectorLiteral =
false;
5970 if (PLE && PLE->getNumExprs() == 0) {
5971 Diag(PLE->getExprLoc(), diag::err_altivec_empty_initializer);
5974 if (PE || PLE->getNumExprs() == 1) {
5977 isVectorLiteral =
true;
5980 isVectorLiteral =
true;
5985 if (isVectorLiteral)
5991 if (isa<ParenListExpr>(CastExpr)) {
5994 CastExpr = Result.
get();
5999 Diag(LParenLoc, diag::warn_old_style_cast) << CastExpr->getSourceRange();
6011 assert((isa<ParenListExpr>(E) || isa<ParenExpr>(E)) &&
6012 "Expected paren or paren list expression");
6019 LiteralLParenLoc = PE->getLParenLoc();
6020 LiteralRParenLoc = PE->getRParenLoc();
6021 exprs = PE->getExprs();
6022 numExprs = PE->getNumExprs();
6024 LiteralLParenLoc = cast<ParenExpr>(
E)->getLParen();
6025 LiteralRParenLoc = cast<ParenExpr>(
E)->getRParen();
6026 subExpr = cast<ParenExpr>(
E)->getSubExpr();
6046 if (numExprs == 1) {
6055 else if (numExprs < numElems) {
6057 diag::err_incorrect_number_of_vector_initializers);
6061 initExprs.append(exprs, exprs + numExprs);
6078 initExprs.append(exprs, exprs + numExprs);
6083 initExprs, LiteralRParenLoc);
6119 Expr *NullExpr = LHSExpr;
6120 Expr *NonPointerExpr = RHSExpr;
6127 NonPointerExpr = LHSExpr;
6149 Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands_null)
6150 << NonPointerExpr->
getType() << DiagType
6151 << NonPointerExpr->getSourceRange();
6161 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_nonfloat)
6162 << CondTy << Cond->getSourceRange();
6169 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_scalar)
6170 << CondTy << Cond->getSourceRange();
6181 S.
Diag(RHSExpr->getLocStart(), diag::ext_typecheck_cond_one_void)
6182 << RHSExpr->getSourceRange();
6184 S.
Diag(LHSExpr->getLocStart(), diag::ext_typecheck_cond_one_void)
6185 << LHSExpr->getSourceRange();
6196 !NullExpr.
get()->isNullPointerConstant(S.
Context,
6220 bool IsBlockPointer =
false;
6224 IsBlockPointer =
true;
6263 if (CompositeTy.
isNull()) {
6271 unsigned ResultAddrSpace;
6281 diag::err_typecheck_op_on_nonoverlapping_address_space_pointers)
6282 << LHSTy << RHSTy << 2 << LHS.
get()->getSourceRange()
6283 << RHS.
get()->getSourceRange();
6292 ? CK_AddressSpaceConversion
6296 ? CK_AddressSpaceConversion
6299 S.
Diag(Loc, diag::ext_typecheck_cond_incompatible_pointers)
6300 << LHSTy << RHSTy << LHS.
get()->getSourceRange()
6301 << RHS.
get()->getSourceRange();
6311 auto LHSCastKind = CK_BitCast, RHSCastKind = CK_BitCast;
6319 : CK_AddressSpaceConversion ;
6322 : CK_AddressSpaceConversion ;
6348 S.
Diag(Loc, diag::err_typecheck_cond_incompatible_operands)
6349 << LHSTy << RHSTy << LHS.
get()->getSourceRange()
6350 << RHS.
get()->getSourceRange();
6401 bool IsIntFirstExpr) {
6403 !Int.
get()->getType()->isIntegerType())
6406 Expr *Expr1 = IsIntFirstExpr ? Int.
get() : PointerExpr;
6407 Expr *Expr2 = IsIntFirstExpr ? PointerExpr : Int.
get();
6409 S.
Diag(Loc, diag::ext_typecheck_cond_pointer_integer_mismatch)
6411 << Expr1->getSourceRange() << Expr2->getSourceRange();
6413 CK_IntegralToPointer);
6447 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_int_float)
6448 << LHSType << LHS.
get()->getSourceRange();
6453 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_int_float)
6454 << RHSType << RHS.
get()->getSourceRange();
6459 if (LHSType == RHSType)
6468 return handleIntegerConversion<doIntegralCast, doIntegralCast>
6469 (
S, LHS, RHS, LHSType, RHSType,
false);
6503 llvm::raw_svector_ostream OS(Str);
6504 OS <<
"(vector of " << NumElements <<
" '" << EleTyName <<
"' values)";
6505 S.
Diag(QuestionLoc, diag::err_conditional_vector_element_size)
6506 << CondTy << OS.str();
6527 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_nonfloat)
6528 << Cond->
getType() << Cond->getSourceRange();
6545 S.
Diag(QuestionLoc, diag::err_conditional_vector_size)
6546 << CondTy << VecResTy;
6551 QualType RVE = RV->getElementType();
6554 S.
Diag(QuestionLoc, diag::err_conditional_vector_element_size)
6555 << CondTy << VecResTy;
6579 if (LHS.
get()->getType()->isVectorType() ||
6580 RHS.
get()->getType()->isVectorType()) {
6599 if (
const CallExpr *CE = dyn_cast<CallExpr>(E)) {
6600 QualType Ty = CE->getCallee()->getType();
6662 diag::err_typecheck_cond_incompatible_operands) << LHSTy << RHSTy
6663 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
6687 if (LHSRT->getDecl() == RHSRT->getDecl())
6710 if (!compositeType.
isNull())
6711 return compositeType;
6740 Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands)
6741 << LHSTy << RHSTy << LHS.
get()->getSourceRange()
6742 << RHS.
get()->getSourceRange();
6812 if (!(compositeType =
6830 Diag(QuestionLoc, diag::ext_typecheck_cond_incompatible_operands)
6832 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
6841 return compositeType;
6848 Diag(QuestionLoc, diag::err_cond_voidptr_arc) << LHSTy << RHSTy
6849 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
6868 Diag(QuestionLoc, diag::err_cond_voidptr_arc) << LHSTy << RHSTy
6869 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
6895 Self.
Diag(Loc, Note)
6900 Self.
Diag(Loc, Note) << ParenRange;
6924 *Opcode = OP->getOpcode();
6925 *RHSExprs = OP->getRHS();
6932 if (Call->getNumArgs() != 2)
6938 if (OO < OO_Plus || OO > OO_Arrow ||
6939 OO == OO_PlusPlus || OO == OO_MinusMinus)
6945 *RHSExprs = Call->getArg(1);
6962 return OP->isComparisonOp() || OP->isLogicalOp();
6964 return OP->getOpcode() == UO_LNot;
6991 Self.
Diag(OpLoc, diag::warn_precedence_conditional)
6992 << Condition->getSourceRange()
6996 Self.
PDiag(diag::note_precedence_silence)
6998 SourceRange(Condition->getLocStart(), Condition->getLocEnd()));
7001 Self.
PDiag(diag::note_precedence_conditional_first),
7002 SourceRange(CondRHS->getLocStart(), RHSExpr->getLocEnd()));
7030 CondExpr = CondResult.
get();
7031 LHSExpr = LHSResult.
get();
7032 RHSExpr = RHSResult.
get();
7038 Expr *commonExpr =
nullptr;
7040 commonExpr = CondExpr;
7047 commonExpr = result.
get();
7061 commonExpr = commonRes.
get();
7069 LHSExpr = CondExpr = opaqueValue;
7074 ExprResult Cond = CondExpr, LHS = LHSExpr, RHS = RHSExpr;
7076 VK, OK, QuestionLoc);
7084 CheckBoolLikeConversion(Cond.
get(), QuestionLoc);
7089 RHS.get(), result, VK, OK);
7092 commonExpr, opaqueValue, Cond.
get(), LHS.get(), RHS.get(), QuestionLoc,
7103 assert(LHSType.
isCanonical() &&
"LHS not canonicalized!");
7104 assert(RHSType.
isCanonical() &&
"RHS not canonicalized!");
7107 const Type *lhptee, *rhptee;
7109 std::tie(lhptee, lhq) =
7110 cast<PointerType>(LHSType)->getPointeeType().split().asPair();
7111 std::tie(rhptee, rhq) =
7112 cast<PointerType>(RHSType)->getPointeeType().split().asPair();
7138 && (lhptee->isVoidType() || rhptee->isVoidType()))
7153 if (lhptee->isVoidType()) {
7154 if (rhptee->isIncompleteOrObjectType())
7158 assert(rhptee->isFunctionType());
7162 if (rhptee->isVoidType()) {
7163 if (lhptee->isIncompleteOrObjectType())
7167 assert(lhptee->isFunctionType());
7178 if (lhptee->isCharType())
7180 else if (lhptee->hasSignedIntegerRepresentation())
7183 if (rhptee->isCharType())
7185 else if (rhptee->hasSignedIntegerRepresentation())
7188 if (ltrans == rtrans) {
7202 if (isa<PointerType>(lhptee) && isa<PointerType>(rhptee)) {
7204 lhptee = cast<PointerType>(lhptee)->getPointeeType().getTypePtr();
7205 rhptee = cast<PointerType>(rhptee)->getPointeeType().getTypePtr();
7206 }
while (isa<PointerType>(lhptee) && isa<PointerType>(rhptee));
7208 if (lhptee == rhptee)
7228 assert(LHSType.
isCanonical() &&
"LHS not canonicalized!");
7229 assert(RHSType.
isCanonical() &&
"RHS not canonicalized!");
7234 lhptee = cast<BlockPointerType>(LHSType)->getPointeeType();
7235 rhptee = cast<BlockPointerType>(RHSType)->getPointeeType();
7244 if (lhptee.getLocalQualifiers() != rhptee.getLocalQualifiers())
7258 assert(LHSType.
isCanonical() &&
"LHS was not canonicalized!");
7259 assert(RHSType.
isCanonical() &&
"RHS was not canonicalized!");
7332 if (LHSType == RHSType) {
7339 if (
const AtomicType *AtomicTy = dyn_cast<AtomicType>(LHSType)) {
7344 if (Kind != CK_NoOp && ConvertRHS)
7346 Kind = CK_NonAtomicToAtomic;
7359 Kind = CK_LValueBitCast;
7374 Kind = CK_VectorSplat;
7430 if (
const PointerType *LHSPointer = dyn_cast<PointerType>(LHSType)) {
7432 if (isa<PointerType>(RHSType)) {
7433 unsigned AddrSpaceL = LHSPointer->getPointeeType().getAddressSpace();
7435 Kind = AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion : CK_BitCast;
7441 Kind = CK_IntegralToPointer;
7447 if (isa<ObjCObjectPointerType>(RHSType)) {
7449 if (LHSPointer->getPointeeType()->isVoidType()) {
7468 if (LHSPointer->getPointeeType()->isVoidType()) {
7478 if (isa<BlockPointerType>(LHSType)) {
7487 Kind = CK_IntegralToPointer;
7493 Kind = CK_AnyPointerToBlockPointerCast;
7499 if (RHSPT->getPointeeType()->isVoidType()) {
7500 Kind = CK_AnyPointerToBlockPointerCast;
7508 if (isa<ObjCObjectPointerType>(LHSType)) {
7523 Kind = CK_IntegralToPointer;
7529 if (isa<PointerType>(RHSType)) {
7530 Kind = CK_CPointerToObjCPointerCast;
7552 Kind = CK_BlockPointerToObjCPointerCast;
7560 if (isa<PointerType>(RHSType)) {
7563 Kind = CK_PointerToBoolean;
7569 Kind = CK_PointerToIntegral;
7577 if (isa<ObjCObjectPointerType>(RHSType)) {
7580 Kind = CK_PointerToBoolean;
7586 Kind = CK_PointerToIntegral;
7594 if (isa<TagType>(LHSType) && isa<TagType>(RHSType)) {
7614 Initializer->
setType(UnionType);
7632 if (!UT || !UT->
getDecl()->hasAttr<TransparentUnionAttr>())
7639 for (
auto *it : UD->
fields()) {
7640 if (it->getType()->isPointerType()) {
7679 bool DiagnoseCFAudited,
7685 ExprResult &RHS = ConvertRHS ? CallerRHS : LocalRHS;
7729 RHS.
get(), LHSType,
false, DAP))
7741 if (Diagnose || ConvertRHS) {
7766 if (Diagnose && isa<ObjCProtocolExpr>(PRE)) {
7770 Diag(PDecl->getLocation(), diag::note_entity_declared_at) << PDecl;
7793 Diagnose, DiagnoseCFAudited) !=
ACR_okay) {
7817 Diag(Loc, diag::err_typecheck_invalid_operands)
7819 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
7845 scalarCast = CK_IntegralCast;
7851 scalarCast = CK_FloatingCast;
7854 scalarCast = CK_IntegralToFloating;
7873 bool AllowBoolConversions) {
7874 if (!IsCompAssign) {
7890 assert(LHSVecType || RHSVecType);
7894 if (!AllowBothBool &&
7904 if (LHSVecType && RHSVecType &&
7906 if (isa<ExtVectorType>(LHSVecType)) {
7919 if (AllowBoolConversions && LHSVecType && RHSVecType &&
7929 if (!IsCompAssign &&
7932 RHSVecType->getElementType()->isIntegerType()) {
7940 if (!RHSVecType && isa<ExtVectorType>(LHSVecType)) {
7945 if (!LHSVecType && isa<ExtVectorType>(RHSVecType)) {
7947 LHSType, RHSVecType->getElementType(),
7955 QualType VecType = LHSVecType ? LHSType : RHSType;
7956 QualType ScalarType = LHSVecType ? RHSType : LHSType;
7957 ExprResult *ScalarExpr = LHSVecType ? &RHS : &LHS;
7967 if ((!RHSVecType && !RHSType->
isRealType()) ||
7969 Diag(Loc, diag::err_typecheck_vector_not_convertable_non_scalar)
7970 << LHSType << RHSType
7971 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
7980 RHSVecType && isa<ExtVectorType>(RHSVecType) &&
7981 LHSVecType && isa<ExtVectorType>(LHSVecType)) {
7982 Diag(Loc, diag::err_opencl_implicit_vector_conversion) << LHSType
7988 Diag(Loc, diag::err_typecheck_vector_not_convertable)
7989 << LHSType << RHSType
7990 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
8002 bool LHSNull = isa<GNUNullExpr>(LHS.
get()->IgnoreParenImpCasts());
8003 bool RHSNull = isa<GNUNullExpr>(RHS.
get()->IgnoreParenImpCasts());
8005 QualType NonNullType = LHSNull ? RHS.
get()->getType() : LHS.
get()->getType();
8009 if ((!LHSNull && !RHSNull) || NonNullType->isBlockPointerType() ||
8010 NonNullType->isMemberPointerType() || NonNullType->isFunctionType())
8016 S.
Diag(Loc, diag::warn_null_in_arithmetic_operation)
8024 if (LHSNull == RHSNull || NonNullType->isAnyPointerType() ||
8025 NonNullType->canDecayToPointerType())
8028 S.
Diag(Loc, diag::warn_null_in_comparison_operation)
8029 << LHSNull << NonNullType
8030 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
8037 llvm::APSInt RHSValue;
8038 if (!RHS.
get()->isValueDependent() &&
8039 RHS.
get()->EvaluateAsInt(RHSValue, S.
Context) && RHSValue == 0)
8041 S.
PDiag(diag::warn_remainder_division_by_zero)
8042 << IsDiv << RHS.
get()->getSourceRange());
8047 bool IsCompAssign,
bool IsDiv) {
8096 ? diag::err_typecheck_pointer_arith_void_type
8097 : diag::ext_gnu_void_ptr)
8098 << 1 << LHSExpr->getSourceRange()
8099 << RHSExpr->getSourceRange();
8106 ? diag::err_typecheck_pointer_arith_void_type
8107 : diag::ext_gnu_void_ptr)
8108 << 0 << Pointer->getSourceRange();
8117 ? diag::err_typecheck_pointer_arith_function_type
8118 : diag::ext_gnu_ptr_func_arith)
8124 << LHS->getSourceRange() << RHS->getSourceRange();
8132 ? diag::err_typecheck_pointer_arith_function_type
8133 : diag::ext_gnu_ptr_func_arith)
8136 << Pointer->getSourceRange();
8146 ResType = ResAtomicType->getValueType();
8151 diag::err_typecheck_arithmetic_incomplete_type,
8152 PointeeTy, Operand->getSourceRange());
8167 ResType = ResAtomicType->getValueType();
8199 if (!isLHSPointer && !isRHSPointer)
return true;
8201 QualType LHSPointeeTy, RHSPointeeTy;
8206 if (S.
getLangOpts().OpenCL && isLHSPointer && isRHSPointer) {
8211 diag::err_typecheck_op_on_nonoverlapping_address_space_pointers)
8213 << LHSExpr->getSourceRange() << RHSExpr->getSourceRange();
8219 bool isLHSVoidPtr = isLHSPointer && LHSPointeeTy->
isVoidType();
8220 bool isRHSVoidPtr = isRHSPointer && RHSPointeeTy->
isVoidType();
8221 if (isLHSVoidPtr || isRHSVoidPtr) {
8229 bool isLHSFuncPtr = isLHSPointer && LHSPointeeTy->
isFunctionType();
8230 bool isRHSFuncPtr = isRHSPointer && RHSPointeeTy->
isFunctionType();
8231 if (isLHSFuncPtr || isRHSFuncPtr) {
8253 Expr* IndexExpr = RHSExpr;
8256 IndexExpr = LHSExpr;
8259 bool IsStringPlusInt = StrExpr &&
8261 if (!IsStringPlusInt || IndexExpr->isValueDependent())
8265 if (IndexExpr->EvaluateAsInt(index, Self.
getASTContext())) {
8266 unsigned StrLenWithNull = StrExpr->
getLength() + 1;
8267 if (index.isNonNegative() &&
8268 index <= llvm::APSInt(llvm::APInt(index.getBitWidth(), StrLenWithNull),
8269 index.isUnsigned()))
8273 SourceRange DiagRange(LHSExpr->getLocStart(), RHSExpr->getLocEnd());
8274 Self.
Diag(OpLoc, diag::warn_string_plus_int)
8275 << DiagRange << IndexExpr->IgnoreImpCasts()->getType();
8278 if (IndexExpr == RHSExpr) {
8280 Self.
Diag(OpLoc, diag::note_string_plus_scalar_silence)
8285 Self.
Diag(OpLoc, diag::note_string_plus_scalar_silence);
8291 const Expr *StringRefExpr = LHSExpr;
8297 StringRefExpr = RHSExpr;
8300 if (!CharExpr || !StringRefExpr)
8314 SourceRange DiagRange(LHSExpr->getLocStart(), RHSExpr->getLocEnd());
8317 if (!CharType->isAnyCharacterType() &&
8318 CharType->isIntegerType() &&
8320 Self.
Diag(OpLoc, diag::warn_string_plus_char)
8321 << DiagRange << Ctx.
CharTy;
8323 Self.
Diag(OpLoc, diag::warn_string_plus_char)
8324 << DiagRange << CharExpr->
getType();
8330 Self.
Diag(OpLoc, diag::note_string_plus_scalar_silence)
8335 Self.
Diag(OpLoc, diag::note_string_plus_scalar_silence);
8344 S.
Diag(Loc, diag::err_typecheck_sub_ptr_compatible)
8345 << LHSExpr->
getType() << RHSExpr->
getType() << LHSExpr->getSourceRange()
8346 << RHSExpr->getSourceRange();
8358 LHS, RHS, Loc, CompLHSTy,
8361 if (CompLHSTy) *CompLHSTy = compType;
8370 if (Opc == BO_Add) {
8377 if (CompLHSTy) *CompLHSTy = compType;
8387 isObjCPointer =
false;
8389 isObjCPointer =
true;
8391 std::swap(PExp, IExp);
8393 isObjCPointer =
false;
8395 isObjCPointer =
true;
8402 if (!IExp->getType()->isIntegerType())
8412 CheckArrayAccess(PExp, IExp);
8436 LHS, RHS, Loc, CompLHSTy,
8439 if (CompLHSTy) *CompLHSTy = compType;
8451 if (CompLHSTy) *CompLHSTy = compType;
8470 CheckArrayAccess(LHS.
get(), RHS.
get(),
nullptr,
8473 if (CompLHSTy) *CompLHSTy = LHS.
get()->
getType();
8506 if (ElementSize.
isZero()) {
8507 Diag(Loc,diag::warn_sub_ptr_zero_size_types)
8509 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
8513 if (CompLHSTy) *CompLHSTy = LHS.
get()->
getType();
8523 return ET->getDecl()->isScoped();
8537 if (RHS.
get()->isValueDependent() ||
8541 if (Right.isNegative()) {
8543 S.
PDiag(diag::warn_shift_negative)
8544 << RHS.
get()->getSourceRange());
8547 llvm::APInt LeftBits(Right.getBitWidth(),
8549 if (Right.uge(LeftBits)) {
8551 S.
PDiag(diag::warn_shift_gt_typewidth)
8552 << RHS.
get()->getSourceRange());
8563 if (LHS.
get()->isValueDependent() ||
8572 S.
PDiag(diag::warn_shift_lhs_negative)
8573 << LHS.
get()->getSourceRange());
8577 llvm::APInt ResultBits =
8578 static_cast<llvm::APInt&
>(Right) + Left.getMinSignedBits();
8579 if (LeftBits.uge(ResultBits))
8581 llvm::APSInt
Result = Left.extend(ResultBits.getLimitedValue());
8582 Result = Result.shl(Right);
8587 Result.toString(HexResult, 16,
false,
true);
8593 if (LeftBits == ResultBits - 1) {
8594 S.
Diag(Loc, diag::warn_shift_result_sets_sign_bit)
8595 << HexResult << LHSType
8596 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
8600 S.
Diag(Loc, diag::warn_shift_result_gt_typewidth)
8601 << HexResult.str() << Result.getMinSignedBits() << LHSType
8602 << Left.getBitWidth() << LHS.
get()->getSourceRange()
8603 << RHS.
get()->getSourceRange();
8612 if (!LHS.
get()->getType()->isVectorType()) {
8613 S.
Diag(Loc, diag::err_shift_rhs_only_vector)
8614 << RHS.
get()->getType() << LHS.
get()->getType()
8615 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
8619 if (!IsCompAssign) {
8637 if (!LHSEleType->isIntegerType()) {
8638 S.
Diag(Loc, diag::err_typecheck_expect_int)
8639 << LHS.
get()->getType() << LHS.
get()->getSourceRange();
8643 if (!RHSEleType->isIntegerType()) {
8644 S.
Diag(Loc, diag::err_typecheck_expect_int)
8645 << RHS.
get()->getType() << RHS.
get()->getSourceRange();
8654 S.
Diag(Loc, diag::err_typecheck_vector_lengths_not_equal)
8655 << LHS.
get()->getType() << RHS.
get()->getType()
8656 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
8672 bool IsCompAssign) {
8707 if (IsCompAssign) LHS = OldLHS;
8735 if (isa<ClassTemplateSpecializationDecl>(DC))
8738 return FD->isFunctionTemplateSpecialization();
8765 S.
Diag(Loc, diag::warn_comparison_of_mixed_enum_types)
8766 << LHSStrippedType << RHSStrippedType
8767 << LHS->getSourceRange() << RHS->getSourceRange();
8774 S.
Diag(Loc, IsError ? diag::err_typecheck_comparison_of_distinct_pointers
8775 : diag::ext_typecheck_comparison_of_distinct_pointers)
8776 << LHS.
get()->getType() << RHS.
get()->getType()
8777 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
8809 bool NonStandardCompositeType =
false;
8810 bool *BoolPtr = S.
isSFINAEContext() ?
nullptr : &NonStandardCompositeType;
8817 if (NonStandardCompositeType)
8818 S.
Diag(Loc, diag::ext_typecheck_comparison_of_distinct_pointers_nonstandard)
8819 << LHSType << RHSType << T << LHS.
get()->getSourceRange()
8820 << RHS.
get()->getSourceRange();
8831 S.
Diag(Loc, IsError ? diag::err_typecheck_comparison_of_fptr_to_void
8832 : diag::ext_typecheck_comparison_of_fptr_to_void)
8833 << LHS.
get()->getType() << RHS.
get()->getType()
8834 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
8838 switch (E.
get()->IgnoreParenImpCasts()->getStmtClass()) {
8839 case Stmt::ObjCArrayLiteralClass:
8840 case Stmt::ObjCDictionaryLiteralClass:
8841 case Stmt::ObjCStringLiteralClass:
8842 case Stmt::ObjCBoxedExprClass:
8898 switch (FromE->getStmtClass()) {
8901 case Stmt::ObjCStringLiteralClass:
8904 case Stmt::ObjCArrayLiteralClass:
8907 case Stmt::ObjCDictionaryLiteralClass:
8910 case Stmt::BlockExprClass:
8912 case Stmt::ObjCBoxedExprClass: {
8914 switch (Inner->getStmtClass()) {
8915 case Stmt::IntegerLiteralClass:
8916 case Stmt::FloatingLiteralClass:
8917 case Stmt::CharacterLiteralClass:
8918 case Stmt::ObjCBoolLiteralExprClass:
8919 case Stmt::CXXBoolLiteralExprClass:
8922 case Stmt::ImplicitCastExprClass: {
8923 CastKind CK = cast<CastExpr>(Inner)->getCastKind();
8925 if (CK == CK_IntegralToBoolean || CK == CK_IntegralCast)
8944 Literal = LHS.
get();
8947 Literal = RHS.
get();
8963 llvm_unreachable(
"Unknown Objective-C object literal kind");
8967 S.
Diag(Loc, diag::warn_objc_string_literal_comparison)
8968 << Literal->getSourceRange();
8970 S.
Diag(Loc, diag::warn_objc_literal_comparison)
8971 << LiteralKind << Literal->getSourceRange();
8980 S.
Diag(Loc, diag::note_objc_literal_comparison_isequal)
8993 if (!UO || UO->
getOpcode() != UO_LNot)
return;
8996 if (RHS.
get()->isKnownToHaveBooleanValue())
return;
9031 return DR->getDecl();
9033 if (Ivar->isFreeIvar())
9034 return Ivar->getDecl();
9036 if (
MemberExpr* Mem = dyn_cast<MemberExpr>(E)) {
9037 if (Mem->isImplicitAccess())
9038 return Mem->getMemberDecl();
9046 bool IsRelational) {
9065 !LHS.
get()->getLocStart().isMacroID() &&
9066 !RHS.
get()->getLocStart().isMacroID() &&
9090 char always_evals_to;
9093 always_evals_to = 0;
9096 always_evals_to = 1;
9100 always_evals_to = 2;
9105 << always_evals_to);
9108 if (isa<CastExpr>(LHSStripped))
9110 if (isa<CastExpr>(RHSStripped))
9115 Expr *literalString =
nullptr;
9116 Expr *literalStringStripped =
nullptr;
9117 if ((isa<StringLiteral>(LHSStripped) || isa<ObjCEncodeExpr>(LHSStripped)) &&
9120 literalString = LHS.
get();
9121 literalStringStripped = LHSStripped;
9122 }
else if ((isa<StringLiteral>(RHSStripped) ||
9123 isa<ObjCEncodeExpr>(RHSStripped)) &&
9126 literalString = RHS.
get();
9127 literalStringStripped = RHSStripped;
9130 if (literalString) {
9132 PDiag(diag::warn_stringcompare)
9133 << isa<ObjCEncodeExpr>(literalStringStripped)
9134 << literalString->getSourceRange());
9155 CheckFloatComparison(Loc, LHS.
get(), RHS.
get());
9168 if (!IsRelational && LHSIsNull != RHSIsNull) {
9169 bool IsEquality = Opc == BO_EQ;
9172 RHS.
get()->getSourceRange());
9175 LHS.
get()->getSourceRange());
9187 if (LCanPointeeTy == RCanPointeeTy)
9189 if (!IsRelational &&
9196 && !LHSIsNull && !RHSIsNull) {
9218 Diag(Loc, diag::ext_typecheck_ordered_comparison_of_function_pointers)
9219 << LHSType << RHSType << LHS.
get()->getSourceRange()
9220 << RHS.
get()->getSourceRange();
9222 }
else if (!IsRelational &&
9226 && !LHSIsNull && !RHSIsNull)
9233 if (LCanPointeeTy != RCanPointeeTy) {
9235 if (
getLangOpts().OpenCL && !LHSIsNull && !RHSIsNull) {
9239 diag::err_typecheck_op_on_nonoverlapping_address_space_pointers)
9240 << LHSType << RHSType << 0
9241 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
9246 CastKind Kind = AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion
9248 if (LHSIsNull && !RHSIsNull)
9269 ? CK_NullToMemberPointer
9270 : CK_NullToPointer);
9279 ? CK_NullToMemberPointer
9280 : CK_NullToPointer);
9285 if (!IsRelational &&
9307 if (!LHSIsNull && !RHSIsNull &&
9309 Diag(Loc, diag::err_typecheck_comparison_of_distinct_blocks)
9310 << LHSType << RHSType << LHS.
get()->getSourceRange()
9311 << RHS.
get()->getSourceRange();
9321 if (!LHSIsNull && !RHSIsNull) {
9326 Diag(Loc, diag::err_typecheck_comparison_of_distinct_blocks)
9327 << LHSType << RHSType << LHS.
get()->getSourceRange()
9328 << RHS.
get()->getSourceRange();
9330 if (LHSIsNull && !RHSIsNull)
9333 : CK_AnyPointerToBlockPointerCast);
9337 : CK_AnyPointerToBlockPointerCast);
9347 bool RPtrToVoid = RPT ? RPT->getPointeeType()->isVoidType() :
false;
9349 if (!LPtrToVoid && !RPtrToVoid &&
9354 if (LHSIsNull && !RHSIsNull) {
9359 RPT ? CK_BitCast :CK_CPointerToObjCPointerCast);
9368 LPT ? CK_BitCast :CK_CPointerToObjCPointerCast);
9380 if (LHSIsNull && !RHSIsNull)
9389 unsigned DiagID = 0;
9390 bool isError =
false;
9397 DiagID = diag::ext_typecheck_ordered_comparison_of_pointer_and_zero;
9398 }
else if (IsRelational && !
getLangOpts().CPlusPlus)
9399 DiagID = diag::ext_typecheck_ordered_comparison_of_pointer_integer;
9401 DiagID = diag::err_typecheck_comparison_of_pointer_integer;
9404 DiagID = diag::ext_typecheck_comparison_of_pointer_integer;
9408 << LHSType << RHSType << LHS.
get()->getSourceRange()
9409 << RHS.
get()->getSourceRange();
9416 LHSIsNull ? CK_NullToPointer : CK_IntegralToPointer);
9419 RHSIsNull ? CK_NullToPointer : CK_IntegralToPointer);
9424 if (!IsRelational && RHSIsNull
9429 if (!IsRelational && LHSIsNull
9454 "Unhandled vector element size in vector compare");
9464 bool IsRelational) {
9490 if (DRL->getDecl() == DRR->getDecl())
9492 PDiag(diag::warn_comparison_always)
9501 CheckFloatComparison(Loc, LHS.
get(), RHS.
get());
9541 if (LHSResult.
isInvalid() || RHSResult.isInvalid())
9543 LHS = LHSResult.
get();
9544 RHS = RHSResult.
get();
9575 (Result != 0 && Result != 1)) {
9576 Diag(Loc, diag::warn_logical_instead_of_bitwise)
9577 << RHS.
get()->getSourceRange()
9578 << (Opc == BO_LAnd ?
"&&" :
"||");
9580 Diag(Loc, diag::note_logical_instead_of_bitwise_change_operator)
9581 << (Opc == BO_LAnd ?
"&" :
"|")
9584 Opc == BO_LAnd ?
"&" :
"|");
9587 Diag(Loc, diag::note_logical_instead_of_bitwise_remove_constant)
9590 RHS.
get()->getLocEnd()));
9643 if (!ME)
return false;
9647 if (!Base)
return false;
9668 assert(var->
hasLocalStorage() &&
"capture added 'const' to non-local?");
9676 if (
auto *FD = dyn_cast<FunctionDecl>(DC))
9678 FD->getTemplateInstantiationPattern() == var->getDeclContext())
9680 if (DC == var->getDeclContext())
9718 bool DiagnosticEmitted =
false;
9722 bool IsDereference =
false;
9723 bool NextIsDereference =
false;
9727 IsDereference = NextIsDereference;
9728 NextIsDereference =
false;
9731 if (
const MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
9732 NextIsDereference = ME->isArrow();
9733 const ValueDecl *VD = ME->getMemberDecl();
9734 if (
const FieldDecl *Field = dyn_cast<FieldDecl>(VD)) {
9736 if (Field->isMutable()) {
9737 assert(DiagnosticEmitted &&
"Expected diagnostic not emitted.");
9742 if (!DiagnosticEmitted) {
9743 S.
Diag(Loc, diag::err_typecheck_assign_const)
9744 << ExprRange << ConstMember <<
false << Field
9745 << Field->getType();
9746 DiagnosticEmitted =
true;
9748 S.
Diag(VD->getLocation(), diag::note_typecheck_assign_const)
9749 << ConstMember <<
false << Field << Field->getType()
9750 << Field->getSourceRange();
9754 }
else if (
const VarDecl *VDecl = dyn_cast<VarDecl>(VD)) {
9755 if (VDecl->getType().isConstQualified()) {
9756 if (!DiagnosticEmitted) {
9757 S.
Diag(Loc, diag::err_typecheck_assign_const)
9758 << ExprRange << ConstMember <<
true << VDecl
9759 << VDecl->getType();
9760 DiagnosticEmitted =
true;
9762 S.
Diag(VD->getLocation(), diag::note_typecheck_assign_const)
9763 << ConstMember <<
true << VDecl << VDecl->getType()
9764 << VDecl->getSourceRange();
9774 if (
const CallExpr *CE = dyn_cast<CallExpr>(E)) {
9778 if (!DiagnosticEmitted) {
9779 S.
Diag(Loc, diag::err_typecheck_assign_const) << ExprRange
9780 << ConstFunction << FD;
9781 DiagnosticEmitted =
true;
9784 diag::note_typecheck_assign_const)
9788 }
else if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
9790 if (
const ValueDecl *VD = DRE->getDecl()) {
9792 if (!DiagnosticEmitted) {
9793 S.
Diag(Loc, diag::err_typecheck_assign_const)
9794 << ExprRange << ConstVariable << VD << VD->getType();
9795 DiagnosticEmitted =
true;
9797 S.
Diag(VD->getLocation(), diag::note_typecheck_assign_const)
9798 << ConstVariable << VD << VD->getType() << VD->getSourceRange();
9801 }
else if (isa<CXXThisExpr>(E)) {
9803 if (
const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(DC)) {
9804 if (MD->isConst()) {
9805 if (!DiagnosticEmitted) {
9806 S.
Diag(Loc, diag::err_typecheck_assign_const) << ExprRange
9807 << ConstMethod << MD;
9808 DiagnosticEmitted =
true;
9810 S.
Diag(MD->getLocation(), diag::note_typecheck_assign_const)
9811 << ConstMethod << MD << MD->getSourceRange();
9817 if (DiagnosticEmitted)
9821 S.
Diag(Loc, diag::err_typecheck_assign_const) << ExprRange << ConstUnknown;
9839 unsigned DiagID = 0;
9840 bool NeedType =
false;
9847 DiagID = diag::err_block_decl_ref_not_modifiable_lvalue;
9849 DiagID = diag::err_lambda_decl_ref_not_modifiable_lvalue;
9857 if (declRef && isa<VarDecl>(declRef->
getDecl())) {
9870 ? diag::err_typecheck_arc_assign_self_class_method
9871 : diag::err_typecheck_arc_assign_self;
9875 DiagID = diag::err_typecheck_arr_assign_enumeration;
9880 S.
Diag(Loc, DiagID) << E->getSourceRange() << Assign;
9901 DiagID = diag::err_typecheck_array_not_modifiable_lvalue;
9905 DiagID = diag::err_typecheck_non_object_not_modifiable_lvalue;
9909 DiagID = diag::err_typecheck_lvalue_casts_not_supported;
9912 llvm_unreachable(
"did not take early return for MLV_Valid");
9916 DiagID = diag::err_typecheck_expression_not_modifiable_lvalue;
9921 diag::err_typecheck_incomplete_type_not_modifiable_lvalue,
E);
9923 DiagID = diag::err_typecheck_duplicate_vector_components_not_mlvalue;
9926 llvm_unreachable(
"readonly properties should be processed differently");
9928 DiagID = diag::error_readonly_message_assignment;
9931 DiagID = diag::error_no_subobject_property_setting;
9939 S.
Diag(Loc, DiagID) << E->
getType() << E->getSourceRange() << Assign;
9941 S.
Diag(Loc, DiagID) << E->getSourceRange() << Assign;
9951 if (ML && MR && ML->
getMemberDecl() == MR->getMemberDecl()) {
9952 if (isa<CXXThisExpr>(ML->
getBase()) && isa<CXXThisExpr>(MR->getBase()))
9953 Sema.
Diag(Loc, diag::warn_identity_field_assign) << 0;
9959 if (OL && OR && OL->
getDecl() == OR->getDecl()) {
9962 if (RL && RR && RL->
getDecl() == RR->getDecl())
9963 Sema.
Diag(Loc, diag::warn_identity_field_assign) << 1;
9981 if (CompoundType.
isNull()) {
10000 Diag(Loc, diag::err_objc_object_assignment)
10007 RHSCheck = ICE->getSubExpr();
10008 if (
UnaryOperator *UO = dyn_cast<UnaryOperator>(RHSCheck)) {
10009 if ((UO->getOpcode() == UO_Plus ||
10010 UO->getOpcode() == UO_Minus) &&
10011 Loc.
isFileID() && UO->getOperatorLoc().isFileID() &&
10017 UO->getSubExpr()->getLocStart().
isFileID()) {
10018 Diag(Loc, diag::warn_not_compound_assign)
10019 << (UO->getOpcode() == UO_Plus ?
"+" :
"-")
10020 <<
SourceRange(UO->getOperatorLoc(), UO->getOperatorLoc());
10031 if (!DRE || DRE->
getDecl()->hasAttr<BlocksAttr>())
10042 RHS.
get()->getLocStart()))
10075 if (
const CastExpr *CE = dyn_cast<CastExpr>(E)) {
10076 if (CE->getCastKind() == CK_ToVoid) {
10102 const unsigned ForIncrementFlags =
10106 if ((ScopeFlags & ForIncrementFlags) == ForIncrementFlags ||
10107 (ScopeFlags & ForInitFlags) == ForInitFlags)
10112 while (
const BinaryOperator *BO = dyn_cast<BinaryOperator>(LHS)) {
10113 if (BO->getOpcode() != BO_Comma)
10115 LHS = BO->getRHS();
10122 Diag(Loc, diag::warn_comma_operator);
10123 Diag(LHS->getLocStart(), diag::note_cast_to_void)
10124 << LHS->getSourceRange()
10126 LangOpts.CPlusPlus ?
"static_cast<void>("
10156 if (!RHS.
get()->getType()->isVoidType())
10158 diag::err_incomplete_type);
10164 return RHS.
get()->getType();
10173 bool IsInc,
bool IsPrefix) {
10182 ResType = ResAtomicType->getValueType();
10184 assert(!ResType.isNull() &&
"no type for increment/decrement expression");
10186 if (S.
getLangOpts().CPlusPlus && ResType->isBooleanType()) {
10189 S.
Diag(OpLoc, diag::err_decrement_bool) << Op->getSourceRange();
10194 : diag::warn_increment_bool)
10195 << Op->getSourceRange();
10196 }
else if (S.
getLangOpts().CPlusPlus && ResType->isEnumeralType()) {
10198 S.
Diag(OpLoc, diag::err_increment_decrement_enum) << IsInc << ResType;
10200 }
else if (ResType->isRealType()) {
10202 }
else if (ResType->isPointerType()) {
10206 }
else if (ResType->isObjCObjectPointerType()) {
10212 }
else if (ResType->isAnyComplexType()) {
10214 S.
Diag(OpLoc, diag::ext_integer_increment_complex)
10215 << ResType << Op->getSourceRange();
10216 }
else if (ResType->isPlaceholderType()) {
10221 }
else if (S.
getLangOpts().AltiVec && ResType->isVectorType()) {
10223 }
else if (S.
getLangOpts().ZVector && ResType->isVectorType() &&
10224 (ResType->getAs<
VectorType>()->getVectorKind() !=
10227 }
else if(S.
getLangOpts().OpenCL && ResType->isVectorType() &&
10231 S.
Diag(OpLoc, diag::err_typecheck_illegal_increment_decrement)
10232 << ResType << int(IsInc) << Op->getSourceRange();
10248 return ResType.getUnqualifiedType();
10266 switch (E->getStmtClass()) {
10267 case Stmt::DeclRefExprClass:
10268 return cast<DeclRefExpr>(
E)->getDecl();
10269 case Stmt::MemberExprClass:
10273 if (cast<MemberExpr>(E)->isArrow())
10277 case Stmt::ArraySubscriptExprClass: {
10280 Expr*
Base = cast<ArraySubscriptExpr>(
E)->getBase();
10282 if (ICE->getSubExpr()->getType()->isArrayType())
10287 case Stmt::UnaryOperatorClass: {
10299 case Stmt::ParenExprClass:
10301 case Stmt::ImplicitCastExprClass:
10313 AO_Vector_Element = 1,
10314 AO_Property_Expansion = 2,
10315 AO_Register_Variable = 3,
10324 S.
Diag(Loc, diag::err_typecheck_address_of) << Type << E->getSourceRange();
10336 if (PTy->getKind() == BuiltinType::Overload) {
10338 if (!isa<OverloadExpr>(E)) {
10339 assert(cast<UnaryOperator>(E)->getOpcode() == UO_AddrOf);
10340 Diag(OpLoc, diag::err_typecheck_invalid_lvalue_addrof_addrof_function)
10341 << OrigOp.
get()->getSourceRange();
10346 if (isa<UnresolvedMemberExpr>(Ovl))
10348 Diag(OpLoc, diag::err_invalid_form_pointer_member_function)
10349 << OrigOp.
get()->getSourceRange();
10356 if (PTy->getKind() == BuiltinType::UnknownAny)
10359 if (PTy->getKind() == BuiltinType::BoundMember) {
10360 Diag(OpLoc, diag::err_invalid_form_pointer_member_function)
10361 << OrigOp.
get()->getSourceRange();
10379 Diag(op->
getExprLoc(), diag::err_opencl_taking_function_address);
10386 if (uOp->getOpcode() == UO_Deref)
10389 return uOp->getSubExpr()->getType();
10396 if (
auto *FD = dyn_cast_or_null<FunctionDecl>(dcl))
10398 op->getLocStart()))
10402 unsigned AddressOfError = AO_No_Error;
10407 : diag::ext_typecheck_addrof_temporary)
10408 << op->
getType() << op->getSourceRange();
10414 }
else if (isa<ObjCSelectorExpr>(op)) {
10421 if (!isa<DeclRefExpr>(op)) {
10422 Diag(OpLoc, diag::err_invalid_form_pointer_member_function)
10423 << OrigOp.
get()->getSourceRange();
10430 if (OrigOp.
get() != DRE) {
10431 Diag(OpLoc, diag::err_parens_pointer_member_function)
10432 << OrigOp.
get()->getSourceRange();
10436 if (MD->getParent()->getName().empty())
10437 Diag(OpLoc, diag::err_unqualified_pointer_member_function)
10438 << op->getSourceRange();
10441 StringRef Qual = (MD->getParent()->getName() +
"::").toStringRef(Str);
10442 Diag(OpLoc, diag::err_unqualified_pointer_member_function)
10443 << op->getSourceRange()
10449 if (isa<CXXDestructorDecl>(MD))
10450 Diag(OpLoc, diag::err_typecheck_addrof_dtor) << op->getSourceRange();
10463 if (isa<PseudoObjectExpr>(op)) {
10464 AddressOfError = AO_Property_Expansion;
10466 Diag(OpLoc, diag::err_typecheck_invalid_lvalue_addrof)
10467 << op->
getType() << op->getSourceRange();
10473 AddressOfError = AO_Bit_Field;
10476 AddressOfError = AO_Vector_Element;
10480 if (
const VarDecl *vd = dyn_cast<VarDecl>(dcl)) {
10485 AddressOfError = AO_Register_Variable;
10487 }
else if (isa<MSPropertyDecl>(dcl)) {
10488 AddressOfError = AO_Property_Expansion;
10489 }
else if (isa<FunctionTemplateDecl>(dcl)) {
10491 }
else if (isa<FieldDecl>(dcl) || isa<IndirectFieldDecl>(dcl)) {
10495 if (isa<DeclRefExpr>(op) && cast<DeclRefExpr>(op)->
getQualifier()) {
10500 diag::err_cannot_form_pointer_to_member_of_reference_type)
10505 while (cast<RecordDecl>(Ctx)->isAnonymousStructOrUnion())
10517 }
else if (!isa<FunctionDecl>(dcl) && !isa<NonTypeTemplateParmDecl>(dcl))
10518 llvm_unreachable(
"Unknown/unexpected decl type");
10521 if (AddressOfError != AO_No_Error) {
10530 Diag(OpLoc, diag::ext_typecheck_addrof_void) << op->getSourceRange();
10550 if (
const FunctionDecl* FD = dyn_cast<FunctionDecl>(Param->getDeclContext()))
10551 if (!FD->hasAttr<NonNullAttr>() && !Param->hasAttr<NonNullAttr>())
10554 if (!FD->ModifiedNonNullParams.count(Param))
10555 FD->ModifiedNonNullParams.insert(Param);
10565 if (ConvResult.isInvalid())
10567 Op = ConvResult.get();
10571 if (isa<CXXReinterpretCastExpr>(Op)) {
10574 Op->getSourceRange());
10587 if (PR.
get() != Op)
10592 S.
Diag(OpLoc, diag::err_typecheck_indirection_requires_pointer)
10593 << OpTy << Op->getSourceRange();
10607 S.
Diag(OpLoc, diag::ext_typecheck_indirection_through_void_pointer)
10608 << OpTy << Op->getSourceRange();
10623 default: llvm_unreachable(
"Unknown binop!");
10624 case tok::periodstar: Opc = BO_PtrMemD;
break;
10625 case tok::arrowstar: Opc = BO_PtrMemI;
break;
10626 case tok::star: Opc = BO_Mul;
break;
10627 case tok::slash: Opc = BO_Div;
break;
10628 case tok::percent: Opc = BO_Rem;
break;
10629 case tok::plus: Opc = BO_Add;
break;
10630 case tok::minus: Opc = BO_Sub;
break;
10631 case tok::lessless: Opc = BO_Shl;
break;
10632 case tok::greatergreater: Opc = BO_Shr;
break;
10633 case tok::lessequal: Opc = BO_LE;
break;
10634 case tok::less: Opc = BO_LT;
break;
10635 case tok::greaterequal: Opc = BO_GE;
break;
10636 case tok::greater: Opc = BO_GT;
break;
10637 case tok::exclaimequal: Opc = BO_NE;
break;
10638 case tok::equalequal: Opc = BO_EQ;
break;
10639 case tok::amp: Opc = BO_And;
break;
10640 case tok::caret: Opc = BO_Xor;
break;
10641 case tok::pipe: Opc = BO_Or;
break;
10642 case tok::ampamp: Opc = BO_LAnd;
break;
10643 case tok::pipepipe: Opc = BO_LOr;
break;
10644 case tok::equal: Opc = BO_Assign;
break;
10645 case tok::starequal: Opc = BO_MulAssign;
break;
10646 case tok::slashequal: Opc = BO_DivAssign;
break;
10647 case tok::percentequal: Opc = BO_RemAssign;
break;
10648 case tok::plusequal: Opc = BO_AddAssign;
break;
10649 case tok::minusequal: Opc = BO_SubAssign;
break;
10650 case tok::lesslessequal: Opc = BO_ShlAssign;
break;
10651 case tok::greatergreaterequal: Opc = BO_ShrAssign;
break;
10652 case tok::ampequal: Opc = BO_AndAssign;
break;
10653 case tok::caretequal: Opc = BO_XorAssign;
break;
10654 case tok::pipeequal: Opc = BO_OrAssign;
break;
10655 case tok::comma: Opc = BO_Comma;
break;
10664 default: llvm_unreachable(
"Unknown unary op!");
10665 case tok::plusplus: Opc = UO_PreInc;
break;
10666 case tok::minusminus: Opc = UO_PreDec;
break;
10667 case tok::amp: Opc = UO_AddrOf;
break;
10668 case tok::star: Opc = UO_Deref;
break;
10669 case tok::plus: Opc = UO_Plus;
break;
10670 case tok::minus: Opc = UO_Minus;
break;
10671 case tok::tilde: Opc = UO_Not;
break;
10672 case tok::exclaim: Opc = UO_LNot;
break;
10673 case tok::kw___real: Opc = UO_Real;
break;
10674 case tok::kw___imag: Opc = UO_Imag;
break;
10675 case tok::kw___extension__: Opc = UO_Extension;
break;
10693 if (!LHSDeclRef || !RHSDeclRef ||
10695 RHSDeclRef->getLocation().isMacroID())
10698 cast<ValueDecl>(LHSDeclRef->
getDecl()->getCanonicalDecl());
10700 cast<ValueDecl>(RHSDeclRef->getDecl()->getCanonicalDecl());
10701 if (LHSDecl != RHSDecl)
10706 if (RefTy->getPointeeType().isVolatileQualified())
10709 S.
Diag(OpLoc, diag::warn_self_assignment)
10711 << LHSExpr->getSourceRange() << RHSExpr->getSourceRange();
10721 const Expr *ObjCPointerExpr =
nullptr, *OtherExpr =
nullptr;
10726 ObjCPointerExpr = LHS;
10730 ObjCPointerExpr = RHS;
10738 if (ObjCPointerExpr && isa<IntegerLiteral>(OtherExpr->IgnoreParenCasts())) {
10739 unsigned Diag = diag::warn_objc_pointer_masking;
10748 if (SelArg0.startswith(
"performSelector"))
10749 Diag = diag::warn_objc_pointer_masking_performSelector;
10752 S.
Diag(OpLoc, Diag)
10753 << ObjCPointerExpr->getSourceRange();
10760 if (
auto *DRE = dyn_cast<DeclRefExpr>(E))
10761 return DRE->getDecl();
10762 if (
auto *ME = dyn_cast<MemberExpr>(E))
10763 return ME->getMemberDecl();
10764 if (
auto *IRE = dyn_cast<ObjCIvarRefExpr>(E))
10765 return IRE->getDecl();
10787 ExprResult Init = InitSeq.Perform(*
this, Entity, Kind, RHSExpr);
10790 RHSExpr = Init.
get();
10807 if (Opc != BO_Assign)
10813 if (!LHS.
isUsable() || !RHS.isUsable())
10823 SourceRange SR(LHSExpr->getLocStart(), RHSExpr->getLocEnd());
10824 if (BO_Assign == Opc)
10825 Diag(OpLoc, diag::err_atomic_init_constant) << SR;
10850 if (!ResultTy.
isNull()) {
10859 Opc == BO_PtrMemI);
10902 Opc == BO_DivAssign);
10903 CompLHSTy = CompResultTy;
10909 CompLHSTy = CompResultTy;
10926 CompLHSTy = CompResultTy;
10935 CompLHSTy = CompResultTy;
10942 VK = RHS.get()->getValueKind();
10943 OK = RHS.get()->getObjectKind();
10951 CheckArrayAccess(LHS.
get());
10952 CheckArrayAccess(RHS.get());
10958 if (ObjectSetClass && isa<ObjCIsaExpr>(LHS.
get())) {
10972 if (CompResultTy.
isNull())
10981 LHS.
get(), RHS.get(), Opc, ResultTy, VK, OK, CompLHSTy, CompResultTy,
10997 bool isRightComp = RHSBO && RHSBO->isComparisonOp();
10998 if (isLeftComp == isRightComp)
11003 bool isLeftBitwise = LHSBO && LHSBO->
isBitwiseOp();
11004 bool isRightBitwise = RHSBO && RHSBO->isBitwiseOp();
11005 if (isLeftBitwise || isRightBitwise)
11011 StringRef OpStr = isLeftComp ? LHSBO->
getOpcodeStr() : RHSBO->getOpcodeStr();
11014 :
SourceRange(LHSExpr->getLocStart(), RHSBO->getLHS()->getLocEnd());
11016 Self.
Diag(OpLoc, diag::warn_precedence_bitwise_rel)
11019 Self.
PDiag(diag::note_precedence_silence) << OpStr,
11022 Self.
PDiag(diag::note_precedence_bitwise_first)
11035 << Bop->getSourceRange() << OpLoc;
11037 Self.
PDiag(diag::note_precedence_silence)
11039 Bop->getSourceRange());
11062 if (Bop->getOpcode() == BO_LAnd) {
11069 }
else if (Bop->getOpcode() == BO_LOr) {
11070 if (
BinaryOperator *RBop = dyn_cast<BinaryOperator>(Bop->getRHS())) {
11073 if (RBop->getOpcode() == BO_LAnd &&
EvaluatesAsTrue(S, RBop->getRHS()))
11084 if (Bop->getOpcode() == BO_LAnd) {
11101 if (Bop->isBitwiseOp() && Bop->getOpcode() < Opc) {
11102 S.
Diag(Bop->getOperatorLoc(), diag::warn_bitwise_op_in_bitwise_op)
11104 << Bop->getSourceRange() << OpLoc;
11106 S.
PDiag(diag::note_precedence_silence)
11107 << Bop->getOpcodeStr(),
11108 Bop->getSourceRange());
11116 if (Bop->getOpcode() == BO_Add || Bop->getOpcode() == BO_Sub) {
11117 StringRef Op = Bop->getOpcodeStr();
11118 S.
Diag(Bop->getOperatorLoc(), diag::warn_addition_in_bitshift)
11119 << Bop->getSourceRange() << OpLoc << Shift << Op;
11121 S.
PDiag(diag::note_precedence_silence) << Op,
11122 Bop->getSourceRange());
11138 if (Kind != OO_LessLess && Kind != OO_GreaterGreater)
11141 S.
Diag(OpLoc, diag::warn_overloaded_shift_in_comparison)
11142 << LHSExpr->getSourceRange() << RHSExpr->getSourceRange()
11143 << (Kind == OO_LessLess);
11145 S.
PDiag(diag::note_precedence_silence)
11146 << (Kind == OO_LessLess ?
"<<" :
">>"),
11149 S.
PDiag(diag::note_evaluate_comparison_first),
11151 RHSExpr->getLocEnd()));
11164 if ((Opc == BO_Or || Opc == BO_Xor) &&
11172 if (Opc == BO_LOr && !OpLoc.
isMacroID()) {
11178 || Opc == BO_Shr) {
11195 assert(LHSExpr &&
"ActOnBinOp(): missing left expression");
11196 assert(RHSExpr &&
"ActOnBinOp(): missing right expression");
11201 return BuildBinOp(S, TokLoc, Opc, LHSExpr, RHSExpr);
11215 if (Sc && OverOp !=
OO_None && OverOp != OO_Equal)
11236 if (pty->getKind() == BuiltinType::PseudoObject &&
11241 if (pty->getKind() == BuiltinType::Overload) {
11249 RHSExpr = resolvedRHS.
get();
11258 LHSExpr = LHS.
get();
11265 if (Opc == BO_Assign && pty->getKind() == BuiltinType::Overload) {
11276 if (pty->getKind() == BuiltinType::Overload &&
11282 RHSExpr = resolvedRHS.
get();
11317 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
11319 << Input.
get()->getSourceRange());
11329 Opc == UO_PreInc ||
11331 Opc == UO_PreInc ||
11364 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
11365 << resultType << Input.
get()->getSourceRange());
11377 Diag(OpLoc, diag::ext_integer_complement_complex)
11378 << resultType << Input.
get()->getSourceRange();
11387 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
11388 << resultType << Input.
get()->getSourceRange());
11392 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
11393 << resultType << Input.
get()->getSourceRange());
11423 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
11424 << resultType << Input.
get()->getSourceRange());
11433 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
11434 << resultType << Input.
get()->getSourceRange());
11440 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
11441 << resultType << Input.
get()->getSourceRange());
11477 if (Opc != UO_AddrOf && Opc != UO_Deref)
11478 CheckArrayAccess(Input.
get());
11488 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
11489 if (!DRE->getQualifier())
11496 if (isa<FieldDecl>(VD) || isa<IndirectFieldDecl>(VD))
11499 return Method->isInstance();
11505 if (!ULE->getQualifier())
11510 if (Method->isInstance())
11530 if (pty->getKind() == BuiltinType::PseudoObject &&
11535 if (Opc == UO_Extension)
11540 if (Opc == UO_AddrOf &&
11541 (pty->getKind() == BuiltinType::Overload ||
11542 pty->getKind() == BuiltinType::UnknownAny ||
11543 pty->getKind() == BuiltinType::BoundMember))
11549 Input = Result.
get();
11594 if (!cleanups)
return nullptr;
11597 if (!cast || cast->
getCastKind() != CK_ARCConsumeObject)
11624 assert(SubStmt && isa<CompoundStmt>(SubStmt) &&
"Invalid action invocation!");
11630 "cleanups within StmtExpr not correctly bound!");
11640 bool StmtExprMayBindToTemp =
false;
11645 while (
LabelStmt *Label = dyn_cast<LabelStmt>(LastStmt)) {
11646 LastLabelStmt = Label;
11647 LastStmt = Label->getSubStmt();
11650 if (
Expr *LastE = dyn_cast<Expr>(LastStmt)) {
11665 if (
Expr *rebuiltLastStmt
11667 LastExpr = rebuiltLastStmt;
11679 if (LastExpr.
get() !=
nullptr) {
11680 if (!LastLabelStmt)
11684 StmtExprMayBindToTemp =
true;
11693 if (StmtExprMayBindToTemp)
11695 return ResStmtExpr;
11710 return ExprError(
Diag(BuiltinLoc, diag::err_offsetof_record_type)
11711 << ArgTy << TypeRange);
11717 diag::err_offsetof_incomplete_type, TypeRange))
11724 if (Components.size() != 1)
11725 Diag(BuiltinLoc, diag::ext_offsetof_extended_field_designator)
11726 <<
SourceRange(Components[1].LocStart, Components.back().LocEnd);
11728 bool DidWarnAboutNonPOD =
false;
11733 if (OC.isBrackets) {
11738 return ExprError(
Diag(OC.LocEnd, diag::err_offsetof_array_type)
11754 diag::err_typecheck_subscript_not_integer)
11755 << Idx->getSourceRange());
11758 Comps.push_back(
OffsetOfNode(OC.LocStart, Exprs.size(), OC.LocEnd));
11759 Exprs.push_back(Idx);
11767 Comps.push_back(
OffsetOfNode(OC.LocStart, OC.U.IdentInfo, OC.LocEnd));
11774 diag::err_offsetof_incomplete_type))
11780 return ExprError(
Diag(OC.LocEnd, diag::err_offsetof_record_type)
11792 bool IsSafe =
LangOpts.CPlusPlus11? CRD->isStandardLayout() : CRD->isPOD();
11794 LangOpts.CPlusPlus11? diag::ext_offsetof_non_standardlayout_type
11795 : diag::ext_offsetof_non_pod_type;
11797 if (!IsSafe && !DidWarnAboutNonPOD &&
11800 <<
SourceRange(Components[0].LocStart, OC.LocEnd)
11802 DidWarnAboutNonPOD =
true;
11812 MemberDecl = IndirectMemberDecl->getAnonField();
11817 << OC.U.IdentInfo << RD <<
SourceRange(OC.LocStart,
11825 Diag(OC.LocEnd, diag::err_offsetof_bitfield)
11828 Diag(MemberDecl->getLocation(), diag::note_bitfield_decl);
11833 if (IndirectMemberDecl)
11834 Parent = cast<RecordDecl>(IndirectMemberDecl->getDeclContext());
11841 if (Paths.getDetectedVirtual()) {
11842 Diag(OC.LocEnd, diag::err_offsetof_field_of_virtual_base)
11853 if (IndirectMemberDecl) {
11854 for (
auto *FI : IndirectMemberDecl->chain()) {
11855 assert(isa<FieldDecl>(FI));
11857 cast<FieldDecl>(FI), OC.LocEnd));
11860 Comps.push_back(
OffsetOfNode(OC.LocStart, MemberDecl, OC.LocEnd));
11866 Comps, Exprs, RParenLoc);
11892 assert((CondExpr && LHSExpr && RHSExpr) &&
"Missing type argument(s)");
11897 bool ValueDependent =
false;
11898 bool CondIsTrue =
false;
11901 ValueDependent =
true;
11904 llvm::APSInt condEval(32);
11907 diag::err_typecheck_choose_expr_requires_constant,
false);
11910 CondExpr = CondICE.
get();
11911 CondIsTrue = condEval.getZExtValue();
11914 Expr *ActiveExpr = CondIsTrue ? LHSExpr : RHSExpr;
11916 resType = ActiveExpr->
getType();
11923 ChooseExpr(BuiltinLoc, CondExpr, LHSExpr, RHSExpr, resType, VK, OK, RPLoc,
11936 Decl *ManglingContextDecl;
11939 ManglingContextDecl)) {
11940 unsigned ManglingNumber = MCtx->getManglingNumber(Block);
11962 "block-id should have no identifier!");
11984 "GetTypeForDeclarator made a non-function block signature");
11995 if (ExplicitSignature.getLocalRangeBegin() ==
11996 ExplicitSignature.getLocalRangeEnd()) {
12008 CurBlock->TheDecl->setSignatureAsWritten(Sig);
12009 CurBlock->FunctionType = T;
12014 (isa<FunctionProtoType>(Fn) && cast<FunctionProtoType>(Fn)->isVariadic());
12016 CurBlock->TheDecl->setIsVariadic(isVariadic);
12023 CurBlock->ReturnType = RetTy;
12024 CurBlock->TheDecl->setBlockMissingReturnType(
false);
12025 CurBlock->HasImplicitReturnType =
false;
12030 if (ExplicitSignature) {
12031 for (
unsigned I = 0,
E = ExplicitSignature.getNumParams();
I !=
E; ++
I) {
12034 !Param->isImplicit() &&
12035 !Param->isInvalidDecl() &&
12037 Diag(Param->getLocation(), diag::err_parameter_name_omitted);
12038 Params.push_back(Param);
12044 for (
const auto &
I : Fn->param_types()) {
12047 Params.push_back(Param);
12052 if (!Params.empty()) {
12053 CurBlock->TheDecl->setParams(Params);
12062 for (
auto AI : CurBlock->TheDecl->parameters()) {
12063 AI->setOwningFunction(CurBlock->TheDecl);
12066 if (AI->getIdentifier()) {
12092 Diag(CaretLoc, diag::err_blocks_disable) <<
LangOpts.OpenCL;
12098 "cleanups within block not correctly bound!");
12112 bool NoReturn = BSI->
TheDecl->hasAttr<NoReturnAttr>();
12123 Captures.push_back(NewCap);
12132 if (NoReturn && !Ext.getNoReturn()) Ext = Ext.
withNoReturn(
true);
12135 if (isa<FunctionNoProtoType>(FTy)) {
12193 const VarDecl *var = CI.getVariable();
12214 Expr *OrigExpr =
E;
12222 return ExprError(
Diag(E->getLocStart(), diag::err_va_arg_in_device));
12258 if (Init.isInvalid())
12260 E = Init.getAs<
Expr>();
12273 diag::err_first_argument_to_va_arg_not_of_type_va_list)
12274 << OrigExpr->
getType() << E->getSourceRange());
12278 diag::err_second_parameter_to_va_arg_incomplete,
12284 diag::err_second_parameter_to_va_arg_abstract,
12291 ? diag::warn_second_parameter_to_va_arg_ownership_qualified
12292 : diag::warn_second_parameter_to_va_arg_not_pod)
12309 PDiag(diag::warn_second_parameter_to_va_arg_never_compatible)
12331 llvm_unreachable(
"I don't know size of pointer!");
12358 if (OV->getSourceExpr())
12373 const Expr *SrcExpr) {
12388 SrcExpr->getLocStart());
12395 bool *Complained) {
12397 *Complained =
false;
12400 bool CheckInferredResultType =
false;
12402 unsigned DiagKind = 0;
12405 bool MayHaveConvFixit =
false;
12406 bool MayHaveFunctionDiff =
false;
12416 DiagKind = diag::ext_typecheck_convert_pointer_int;
12418 MayHaveConvFixit =
true;
12421 DiagKind = diag::ext_typecheck_convert_int_pointer;
12423 MayHaveConvFixit =
true;
12428 diag::err_arc_typecheck_convert_incompatible_pointer :
12429 diag::ext_typecheck_convert_incompatible_pointer);
12432 if (Hint.
isNull() && !CheckInferredResultType) {
12435 else if (CheckInferredResultType) {
12439 MayHaveConvFixit =
true;
12442 DiagKind = diag::ext_typecheck_convert_incompatible_pointer_sign;
12445 DiagKind = diag::ext_typecheck_convert_pointer_void_func;
12454 DiagKind = diag::err_typecheck_incompatible_address_space;
12459 DiagKind = diag::err_typecheck_incompatible_ownership;
12463 llvm_unreachable(
"unknown error case for discarding qualifiers!");
12479 DiagKind = diag::ext_typecheck_convert_discards_qualifiers;
12482 DiagKind = diag::ext_nested_pointer_qualifier_mismatch;
12485 DiagKind = diag::err_int_to_block_pointer;
12488 DiagKind = diag::err_typecheck_convert_incompatible_block_pointer;
12494 for (
auto *srcProto : srcOPT->
quals()) {
12500 IFace = IFaceT->getDecl();
12505 for (
auto *dstProto : dstOPT->
quals()) {
12511 IFace = IFaceT->getDecl();
12513 DiagKind = diag::warn_incompatible_qualified_id;
12517 DiagKind = diag::warn_incompatible_vectors;
12520 DiagKind = diag::err_arc_weak_unavailable_assign;
12525 *Complained =
true;
12529 DiagKind = diag::err_typecheck_convert_incompatible;
12531 MayHaveConvFixit =
true;
12533 MayHaveFunctionDiff =
true;
12542 FirstType = DstType;
12543 SecondType = SrcType;
12553 FirstType = SrcType;
12554 SecondType = DstType;
12560 FDiag << FirstType << SecondType <<
AA_Passing << SrcExpr->getSourceRange();
12562 FDiag << FirstType << SecondType << Action << SrcExpr->getSourceRange();
12566 if (!ConvHints.
isNull()) {
12572 if (MayHaveConvFixit) { FDiag << (
unsigned) (ConvHints.
Kind); }
12574 if (MayHaveFunctionDiff)
12578 if (DiagKind == diag::warn_incompatible_qualified_id &&
12580 Diag(IFace->getLocation(), diag::not_incomplete_class_and_qualified_id)
12587 if (CheckInferredResultType)
12594 *Complained =
true;
12599 llvm::APSInt *Result) {
12603 S.
Diag(Loc, diag::err_expr_not_ice) << S.
LangOpts.CPlusPlus << SR;
12611 llvm::APSInt *Result,
12618 IDDiagnoser(
unsigned DiagID)
12622 S.
Diag(Loc, DiagID) << SR;
12624 } Diagnoser(DiagID);
12631 S.
Diag(Loc, diag::ext_expr_not_ice) << SR << S.
LangOpts.CPlusPlus;
12649 CXX11ConvertDiagnoser(
bool Silent)
12655 return S.
Diag(Loc, diag::err_ice_not_integral) << T;
12660 return S.
Diag(Loc, diag::err_ice_incomplete_type) << T;
12665 return S.
Diag(Loc, diag::err_ice_explicit_conversion) << T << ConvTy;
12670 return S.
Diag(Conv->getLocation(), diag::note_ice_conversion_here)
12676 return S.
Diag(Loc, diag::err_ice_ambiguous_conversion) << T;
12681 return S.
Diag(Conv->getLocation(), diag::note_ice_conversion_here)
12687 llvm_unreachable(
"conversion functions are permitted");
12689 } ConvertDiagnoser(Diagnoser.
Suppress);
12695 E = Converted.
get();
12715 EvalResult.
Diag = &Notes;
12734 if (Notes.size() == 1 && Notes[0].second.getDiagID() ==
12735 diag::note_invalid_subexpr_in_const_expr) {
12736 DiagLoc = Notes[0].first;
12740 if (!Folded || !AllowFold) {
12750 Diagnoser.
diagnoseFold(*
this, DiagLoc, E->getSourceRange());
12762 class TransformToPE :
public TreeTransform<TransformToPE> {
12766 TransformToPE(
Sema &SemaRef) : BaseTransform(SemaRef) { }
12769 bool AlwaysRebuild() {
return true; }
12776 return BaseTransform::TransformLabelStmt(S);
12787 if (isa<FieldDecl>(E->
getDecl()) &&
12788 !SemaRef.isUnevaluatedContext())
12790 diag::err_invalid_non_static_member_use)
12791 << E->
getDecl() << E->getSourceRange();
12793 return BaseTransform::TransformDeclRefExpr(E);
12801 return BaseTransform::TransformUnaryOperator(E);
12813 "Should only transform unevaluated expressions");
12818 return TransformToPE(*this).TransformExpr(E);
12823 Decl *LambdaContextDecl,
12826 LambdaContextDecl, IsDecltype);
12851 D = diag::err_lambda_unevaluated_operand;
12857 D = diag::err_lambda_in_constant_expression;
12859 for (
const auto *L : Rec.
Lambdas)
12860 Diag(L->getLocStart(), D);
12864 for (
auto *Lambda : Rec.
Lambdas) {
12865 for (
auto *C : Lambda->capture_inits())
12894 assert(NumTypos == 0 &&
"There are outstanding typos after popping the "
12895 "last ExpressionEvaluationContextRecord");
12944 llvm_unreachable(
"Invalid context");
12950 bool MightBeOdrUse) {
12951 assert(Func &&
"No function?");
12953 Func->setReferenced();
12989 bool NeedDefinition =
12998 if (NeedDefinition &&
13005 if ((Func->isUsed(
false) || !OdrUse) &&
13006 (!NeedDefinition || Func->
getBody()))
13011 Constructor = cast<CXXConstructorDecl>(Constructor->getFirstDecl());
13012 if (Constructor->isDefaulted() && !Constructor->isDeleted()) {
13013 if (Constructor->isDefaultConstructor()) {
13014 if (Constructor->isTrivial() && !Constructor->hasAttr<DLLExportAttr>())
13017 }
else if (Constructor->isCopyConstructor()) {
13019 }
else if (Constructor->isMoveConstructor()) {
13022 }
else if (Constructor->getInheritedConstructor()) {
13026 dyn_cast<CXXDestructorDecl>(Func)) {
13027 Destructor = cast<CXXDestructorDecl>(Destructor->getFirstDecl());
13028 if (Destructor->isDefaulted() && !Destructor->isDeleted()) {
13029 if (Destructor->isTrivial() && !Destructor->hasAttr<DLLExportAttr>())
13033 if (Destructor->isVirtual() &&
getLangOpts().AppleKext)
13035 }
else if (
CXXMethodDecl *MethodDecl = dyn_cast<CXXMethodDecl>(Func)) {
13036 if (MethodDecl->isOverloadedOperator() &&
13037 MethodDecl->getOverloadedOperator() == OO_Equal) {
13038 MethodDecl = cast<CXXMethodDecl>(MethodDecl->getFirstDecl());
13039 if (MethodDecl->isDefaulted() && !MethodDecl->isDeleted()) {
13040 if (MethodDecl->isCopyAssignmentOperator())
13042 else if (MethodDecl->isMoveAssignmentOperator())
13045 }
else if (isa<CXXConversionDecl>(MethodDecl) &&
13046 MethodDecl->getParent()->isLambda()) {
13048 cast<CXXConversionDecl>(MethodDecl->getFirstDecl());
13053 }
else if (MethodDecl->isVirtual() &&
getLangOpts().AppleKext)
13070 bool AlreadyInstantiated =
false;
13074 if (SpecInfo->getPointOfInstantiation().isInvalid())
13075 SpecInfo->setPointOfInstantiation(Loc);
13076 else if (SpecInfo->getTemplateSpecializationKind()
13078 AlreadyInstantiated =
true;
13079 PointOfInstantiation = SpecInfo->getPointOfInstantiation();
13083 if (MSInfo->getPointOfInstantiation().isInvalid())
13084 MSInfo->setPointOfInstantiation(Loc);
13085 else if (MSInfo->getTemplateSpecializationKind()
13087 AlreadyInstantiated =
true;
13088 PointOfInstantiation = MSInfo->getPointOfInstantiation();
13092 if (!AlreadyInstantiated || Func->
isConstexpr()) {
13093 if (isa<CXXRecordDecl>(Func->getDeclContext()) &&
13094 cast<CXXRecordDecl>(Func->getDeclContext())->isLocalClass() &&
13097 std::make_pair(Func, PointOfInstantiation));
13105 PointOfInstantiation));
13112 for (
auto i : Func->
redecls()) {
13113 if (!i->isUsed(
false) && i->isImplicitlyInstantiable())
13118 if (!OdrUse)
return;
13122 if (mightHaveNonExternalLinkage(Func))
13141 if (isa<ParmVarDecl>(var) &&
13142 isa<TranslationUnitDecl>(VarDC))
13155 if (isa<CXXMethodDecl>(VarDC) &&
13156 cast<CXXRecordDecl>(VarDC->
getParent())->isLambda()) {
13157 S.
Diag(loc, diag::err_reference_to_local_var_in_enclosing_lambda)
13159 }
else if (
FunctionDecl *fn = dyn_cast<FunctionDecl>(VarDC)) {
13160 S.
Diag(loc, diag::err_reference_to_local_var_in_enclosing_function)
13162 }
else if (isa<BlockDecl>(VarDC)) {
13163 S.
Diag(loc, diag::err_reference_to_local_var_in_enclosing_block)
13168 S.
Diag(loc, diag::err_reference_to_local_var_in_enclosing_context)
13172 S.
Diag(var->getLocation(), diag::note_entity_declared_at)
13181 bool &SubCapturesAreNested,
13187 SubCapturesAreNested =
true;
13200 !(isa<LambdaScopeInfo>(CSI) && cast<LambdaScopeInfo>(CSI)->Mutable) &&
13201 !(isa<CapturedRegionScopeInfo>(CSI) &&
13202 cast<CapturedRegionScopeInfo>(CSI)->CapRegionKind ==
CR_OpenMP))
13213 const bool Diagnose,
Sema &S) {
13228 const bool Diagnose,
Sema &S) {
13230 bool IsBlock = isa<BlockScopeInfo>(CSI);
13231 bool IsLambda = isa<LambdaScopeInfo>(CSI);
13239 S.
Diag(Loc, diag::err_lambda_capture_anonymous_var);
13240 S.
Diag(Var->getLocation(), diag::note_declared_at);
13248 S.
Diag(Loc, diag::err_ref_vm_type);
13249 S.
Diag(Var->getLocation(), diag::note_previous_decl)
13257 if (VTTy->getDecl()->hasFlexibleArrayMember()) {
13260 S.
Diag(Loc, diag::err_ref_flexarray_type);
13262 S.
Diag(Loc, diag::err_lambda_capture_flexarray_type)
13264 S.
Diag(Var->getLocation(), diag::note_previous_decl)
13270 const bool HasBlocksAttr = Var->hasAttr<BlocksAttr>();
13273 if (HasBlocksAttr && (IsLambda || isa<CapturedRegionScopeInfo>(CSI))) {
13275 S.
Diag(Loc, diag::err_capture_block_variable)
13277 S.
Diag(Var->getLocation(), diag::note_previous_decl)
13289 const bool BuildAndDiagnose,
13294 Expr *CopyExpr =
nullptr;
13295 bool ByRef =
false;
13299 if (BuildAndDiagnose) {
13300 S.
Diag(Loc, diag::err_ref_array_type);
13301 S.
Diag(Var->getLocation(), diag::note_previous_decl)
13309 if (BuildAndDiagnose) {
13310 S.
Diag(Loc, diag::err_arc_autoreleasing_capture)
13312 S.
Diag(Var->getLocation(), diag::note_previous_decl)
13317 const bool HasBlocksAttr = Var->hasAttr<BlocksAttr>();
13326 DeclRefType = CaptureType;
13328 if (S.
getLangOpts().CPlusPlus && BuildAndDiagnose) {
13335 if (isa<ParmVarDecl>(Var))
13352 CaptureType,
false),
13359 !cast<CXXConstructExpr>(Result.
get())->getConstructor()
13362 CopyExpr = Result.
get();
13369 if (BuildAndDiagnose)
13370 BSI->
addCapture(Var, HasBlocksAttr, ByRef, Nested, Loc,
13382 const bool BuildAndDiagnose,
13385 const bool RefersToCapturedVariable,
13399 CaptureType = DeclRefType;
13401 Expr *CopyExpr =
nullptr;
13402 if (BuildAndDiagnose) {
13412 Field->setImplicit(
true);
13418 Var->setReferenced(
true);
13423 if (BuildAndDiagnose)
13424 RSI->
addCapture(Var,
false, ByRef, RefersToCapturedVariable, Loc,
13436 bool RefersToCapturedVariable) {
13444 Field->setImplicit(
true);
13453 const bool BuildAndDiagnose,
13456 const bool RefersToCapturedVariable,
13459 const bool IsTopScope,
13463 bool ByRef =
false;
13497 if (!RefType->getPointeeType()->isFunctionType())
13503 if (BuildAndDiagnose) {
13504 S.
Diag(Loc, diag::err_arc_autoreleasing_capture) << 1;
13505 S.
Diag(Var->getLocation(), diag::note_previous_decl)
13512 if (BuildAndDiagnose) {
13515 diag::err_capture_of_incomplete_type,
13520 diag::err_capture_of_abstract_type))
13526 if (BuildAndDiagnose)
13528 RefersToCapturedVariable);
13545 if (BuildAndDiagnose)
13546 LSI->
addCapture(Var,
false, ByRef, RefersToCapturedVariable,
13547 Loc, EllipsisLoc, CaptureType,
nullptr);
13555 QualType &DeclRefType,
const unsigned *
const FunctionScopeIndexToStopAt) {
13563 const unsigned MaxFunctionScopesIndex = FunctionScopeIndexToStopAt
13567 if (FunctionScopeIndexToStopAt) {
13569 while (FSIndex != MaxFunctionScopesIndex) {
13578 if (VarDC == DC)
return true;
13594 CaptureType = Var->
getType();
13596 bool Nested =
false;
13598 unsigned FunctionScopesIndex = MaxFunctionScopesIndex;
13611 FunctionScopesIndex = MaxFunctionScopesIndex - 1;
13630 if (BuildAndDiagnose) {
13634 Diag(Var->getLocation(), diag::note_previous_decl)
13653 if (
ParmVarDecl *PVD = dyn_cast_or_null<ParmVarDecl>(Var))
13654 QTy = PVD->getOriginalType();
13659 if (
auto *RSI = dyn_cast<CapturedRegionScopeInfo>(CSI)) {
13669 FunctionScopesIndex--;
13672 Nested = !IsTargetCap;
13683 if (BuildAndDiagnose) {
13685 Diag(Var->getLocation(), diag::note_previous_decl)
13687 if (cast<LambdaScopeInfo>(CSI)->Lambda)
13688 Diag(cast<LambdaScopeInfo>(CSI)->Lambda->getLocStart(),
13689 diag::note_lambda_decl);
13705 FunctionScopesIndex--;
13708 }
while (!VarDC->
Equals(DC));
13715 for (
unsigned I = ++FunctionScopesIndex, N = MaxFunctionScopesIndex + 1;
I != N;
13721 BuildAndDiagnose, CaptureType,
13722 DeclRefType, Nested, *
this))
13727 BuildAndDiagnose, CaptureType,
13728 DeclRefType, Nested, *
this))
13734 BuildAndDiagnose, CaptureType,
13735 DeclRefType, Nested, Kind, EllipsisLoc,
13736 I == N - 1, *
this))
13750 DeclRefType,
nullptr);
13757 false, CaptureType,
13758 DeclRefType,
nullptr);
13767 false, CaptureType,
13768 DeclRefType,
nullptr))
13771 return DeclRefType;
13785 const VarDecl *DefVD =
nullptr;
13812 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(SansParensExpr))
13813 Var = dyn_cast<
VarDecl>(DRE->getFoundDecl());
13814 else if (
MemberExpr *ME = dyn_cast<MemberExpr>(SansParensExpr))
13815 Var = dyn_cast<VarDecl>(ME->getMemberDecl());
13818 LSI->markVariableExprAsNonODRUsed(SansParensExpr);
13840 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
13841 Var = cast<VarDecl>(DRE->getDecl());
13842 Loc = DRE->getLocation();
13843 }
else if (
MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
13844 Var = cast<VarDecl>(ME->getMemberDecl());
13845 Loc = ME->getMemberLoc();
13847 llvm_unreachable(
"Unexpected expression");
13854 MaybeODRUseExprs.clear();
13860 assert((!E || isa<DeclRefExpr>(E) || isa<MemberExpr>(E)) &&
13861 "Invalid Expr argument to DoMarkVarDeclReferenced");
13862 Var->setReferenced();
13865 bool MarkODRUsed =
true;
13879 const bool RefersToEnclosingScope =
13880 (SemaRef.
CurContext != Var->getDeclContext() &&
13881 Var->getDeclContext()->isFunctionOrMethod() && Var->
hasLocalStorage());
13882 if (RefersToEnclosingScope) {
13892 assert(E &&
"Capture variable should be used in an expression.");
13903 MarkODRUsed =
false;
13908 assert(!isa<VarTemplatePartialSpecializationDecl>(Var) &&
13909 "Can't instantiate a partial template specialization.");
13914 if (TSK !=
TSK_Undeclared && !isa<VarTemplateSpecializationDecl>(Var))
13924 if (TryInstantiating && !isa<VarTemplateSpecializationDecl>(Var)) {
13928 L->StaticDataMemberInstantiated(Var);
13932 TryInstantiating =
false;
13938 if (TryInstantiating) {
13940 bool InstantiationDependent =
false;
13941 bool IsNonDependent =
13947 if (IsNonDependent) {
13954 .push_back(std::make_pair(Var, PointOfInstantiation));
13989 Decl *D,
Expr *E,
bool MightBeOdrUse) {
13993 if (
VarDecl *Var = dyn_cast<VarDecl>(D)) {
14009 bool IsVirtualCall = MD->
isVirtual() &&
14011 if (!IsVirtualCall)
14015 if (!MostDerivedClassDecl)
14018 if (!DM || DM->
isPure())
14028 bool OdrUse =
true;
14030 if (Method->isVirtual())
14043 bool MightBeOdrUse =
true;
14046 if (Method->isPure())
14047 MightBeOdrUse =
false;
14059 bool MightBeOdrUse) {
14060 if (MightBeOdrUse) {
14061 if (
auto *VD = dyn_cast<VarDecl>(D)) {
14066 if (
auto *FD = dyn_cast<FunctionDecl>(D)) {
14070 D->setReferenced();
14091 bool MarkReferencedDecls::TraverseTemplateArgument(
14095 S.MarkAnyDeclReferenced(Loc, D,
true);
14098 return Inherited::TraverseTemplateArgument(Arg);
14101 bool MarkReferencedDecls::TraverseRecordType(
RecordType *T) {
14103 = dyn_cast<ClassTemplateSpecializationDecl>(T->
getDecl())) {
14105 return TraverseTemplateArguments(Args.
data(), Args.
size());
14112 MarkReferencedDecls Marker(*
this, Loc);
14121 bool SkipLocalVariables;
14126 EvaluatedExprMarker(
Sema &S,
bool SkipLocalVariables)
14127 : Inherited(S.
Context), S(S), SkipLocalVariables(SkipLocalVariables) { }
14131 if (SkipLocalVariables) {
14133 if (VD->hasLocalStorage())
14137 S.MarkDeclRefReferenced(E);
14141 S.MarkMemberReferenced(E);
14142 Inherited::VisitMemberExpr(E);
14156 Inherited::VisitCXXNewExpr(E);
14164 CXXRecordDecl *Record = cast<CXXRecordDecl>(DestroyedRec->getDecl());
14166 S.LookupDestructor(Record));
14169 Inherited::VisitCXXDeleteExpr(E);
14174 Inherited::VisitCXXConstructExpr(E);
14182 Inherited::VisitImplicitCastExpr(E);
14185 S.UpdateMarkingForLValueToRValue(E->
getSubExpr());
14196 bool SkipLocalVariables) {
14197 EvaluatedExprMarker(*
this, SkipLocalVariables).Visit(E);
14256 class CallReturnIncompleteDiagnoser :
public TypeDiagnoser {
14262 : FD(FD), CE(CE) { }
14266 S.
Diag(Loc, diag::err_call_incomplete_return)
14267 << T << CE->getSourceRange();
14271 S.
Diag(Loc, diag::err_call_function_incomplete_return)
14272 << CE->getSourceRange() << FD->
getDeclName() << T;
14273 S.
Diag(FD->getLocation(), diag::note_entity_declared_at)
14276 } Diagnoser(FD, CE);
14289 unsigned diagnostic = diag::warn_condition_is_assignment;
14290 bool IsOrAssign =
false;
14293 if (Op->getOpcode() != BO_Assign && Op->getOpcode() != BO_OrAssign)
14296 IsOrAssign = Op->getOpcode() == BO_OrAssign;
14300 = dyn_cast<ObjCMessageExpr>(Op->getRHS()->IgnoreParenCasts())) {
14305 diagnostic = diag::warn_condition_is_idiomatic_assignment;
14309 diagnostic = diag::warn_condition_is_idiomatic_assignment;
14312 Loc = Op->getOperatorLoc();
14314 if (Op->getOperator() != OO_Equal && Op->getOperator() != OO_PipeEqual)
14317 IsOrAssign = Op->getOperator() == OO_PipeEqual;
14318 Loc = Op->getOperatorLoc();
14326 Diag(Loc, diagnostic) << E->getSourceRange();
14330 Diag(Loc, diag::note_condition_assign_silence)
14335 Diag(Loc, diag::note_condition_or_assign_to_comparison)
14338 Diag(Loc, diag::note_condition_assign_to_comparison)
14356 if (opE->getOpcode() == BO_EQ &&
14357 opE->getLHS()->IgnoreParenImpCasts()->isModifiableLvalue(
Context)
14361 Diag(Loc, diag::warn_equality_with_extra_parens) << E->getSourceRange();
14362 SourceRange ParenERange = ParenE->getSourceRange();
14363 Diag(Loc, diag::note_equality_comparison_silence)
14366 Diag(Loc, diag::note_equality_comparison_to_assign)
14372 bool IsConstexpr) {
14374 if (
ParenExpr *parenE = dyn_cast<ParenExpr>(E))
14392 Diag(Loc, diag::err_typecheck_statement_requires_scalar)
14393 << T << E->getSourceRange();
14396 CheckBoolLikeConversion(E, Loc);
14427 if (!FullExpr.
get())
14437 struct RebuildUnknownAnyFunction
14438 :
StmtVisitor<RebuildUnknownAnyFunction, ExprResult> {
14442 RebuildUnknownAnyFunction(
Sema &S) : S(S) {}
14445 llvm_unreachable(
"unexpected statement!");
14449 S.Diag(E->
getExprLoc(), diag::err_unsupported_unknown_any_call)
14450 << E->getSourceRange();
14456 template <
class T>
ExprResult rebuildSugarExpr(T *E) {
14457 ExprResult SubResult = Visit(E->getSubExpr());
14460 Expr *SubExpr = SubResult.
get();
14461 E->setSubExpr(SubExpr);
14462 E->setType(SubExpr->
getType());
14469 return rebuildSugarExpr(E);
14473 return rebuildSugarExpr(E);
14480 Expr *SubExpr = SubResult.
get();
14489 if (!isa<FunctionDecl>(VD))
return VisitExpr(E);
14494 if (S.getLangOpts().CPlusPlus &&
14495 !(isa<CXXMethodDecl>(VD) &&
14496 cast<CXXMethodDecl>(VD)->isInstance()))
14507 return resolveDecl(E, E->
getDecl());
14525 struct RebuildUnknownAnyExpr
14526 :
StmtVisitor<RebuildUnknownAnyExpr, ExprResult> {
14534 : S(S), DestType(CastType) {}
14537 llvm_unreachable(
"unexpected statement!");
14541 S.Diag(E->
getExprLoc(), diag::err_unsupported_unknown_any_expr)
14542 << E->getSourceRange();
14551 template <
class T>
ExprResult rebuildSugarExpr(T *E) {
14552 ExprResult SubResult = Visit(E->getSubExpr());
14554 Expr *SubExpr = SubResult.
get();
14555 E->setSubExpr(SubExpr);
14556 E->setType(SubExpr->
getType());
14563 return rebuildSugarExpr(E);
14567 return rebuildSugarExpr(E);
14574 << E->getSourceRange();
14598 return resolveDecl(E, E->
getDecl());
14609 FK_FunctionPointer,
14615 if (CalleeType == S.Context.BoundMemberTy) {
14616 assert(isa<CXXMemberCallExpr>(E) || isa<CXXOperatorCallExpr>(E));
14617 Kind = FK_MemberFunction;
14621 Kind = FK_FunctionPointer;
14624 Kind = FK_BlockPointer;
14629 if (DestType->isArrayType() || DestType->isFunctionType()) {
14630 unsigned diagID = diag::err_func_returning_array_function;
14631 if (Kind == FK_BlockPointer)
14632 diagID = diag::err_block_returning_array_function;
14635 << DestType->isFunctionType() << DestType;
14640 E->
setType(DestType.getNonLValueExprType(S.Context));
14668 if (ParamTypes.empty() && Proto->isVariadic()) {
14670 for (
unsigned i = 0, e = E->
getNumArgs(); i != e; ++i) {
14674 ArgType = S.Context.getLValueReferenceType(ArgType);
14676 ArgType = S.Context.getRValueReferenceType(ArgType);
14678 ArgTypes.push_back(ArgType);
14680 ParamTypes = ArgTypes;
14682 DestType = S.Context.getFunctionType(DestType, ParamTypes,
14683 Proto->getExtProtoInfo());
14685 DestType = S.Context.getFunctionNoProtoType(DestType,
14691 case FK_MemberFunction:
14695 case FK_FunctionPointer:
14696 DestType = S.Context.getPointerType(DestType);
14699 case FK_BlockPointer:
14700 DestType = S.Context.getBlockPointerType(DestType);
14705 ExprResult CalleeResult = Visit(CalleeExpr);
14710 return S.MaybeBindToTemporary(E);
14715 if (DestType->isArrayType() || DestType->isFunctionType()) {
14716 S.Diag(E->
getExprLoc(), diag::err_func_returning_array_function)
14717 << DestType->isFunctionType() << DestType;
14723 assert(Method->getReturnType() == S.Context.UnknownAnyTy);
14724 Method->setReturnType(DestType);
14728 E->
setType(DestType.getNonReferenceType());
14731 return S.MaybeBindToTemporary(E);
14736 if (E->
getCastKind() == CK_FunctionToPointerDecay) {
14743 DestType = DestType->castAs<
PointerType>()->getPointeeType();
14750 }
else if (E->
getCastKind() == CK_LValueToRValue) {
14754 assert(isa<BlockPointerType>(E->
getType()));
14759 DestType = S.Context.getLValueReferenceType(DestType);
14767 llvm_unreachable(
"Unhandled cast type!");
14783 return S.ImpCastExprToType(Result.
get(), Type,
14788 S.Diag(E->
getExprLoc(), diag::err_unknown_any_function)
14789 << VD << E->getSourceRange();
14800 if (DRE && Proto && Proto->getParamTypes().empty() && Proto->isVariadic()) {
14803 FD->getDeclContext(),
14804 Loc, Loc, FD->getNameInfo().getName(),
14805 DestType, FD->getTypeSourceInfo(),
14807 FD->hasPrototype(),
14810 if (FD->getQualifier())
14814 for (
const auto &AI : FT->param_types()) {
14816 S.BuildParmVarDeclForTypedef(FD, Loc, AI);
14818 Params.push_back(Param);
14820 NewFD->setParams(Params);
14821 DRE->setDecl(NewFD);
14822 VD = DRE->getDecl();
14827 if (MD->isInstance()) {
14829 Type = S.Context.BoundMemberTy;
14833 if (!S.getLangOpts().CPlusPlus)
14837 }
else if (isa<VarDecl>(VD)) {
14841 S.Diag(E->
getExprLoc(), diag::err_unknown_any_var_function_type)
14842 << VD << E->getSourceRange();
14848 S.Diag(E->
getExprLoc(), diag::err_unsupported_unknown_any_decl)
14849 << VD << E->getSourceRange();
14869 diag::err_typecheck_cast_to_incomplete))
14873 ExprResult result = RebuildUnknownAnyExpr(*
this, CastType).Visit(CastExpr);
14876 CastExpr = result.
get();
14878 CastKind = CK_NoOp;
14884 return RebuildUnknownAnyExpr(*
this, ToType).Visit(E);
14912 unsigned diagID = diag::err_uncasted_use_of_unknown_any;
14915 if (
CallExpr *call = dyn_cast<CallExpr>(E)) {
14916 E = call->getCallee();
14917 diagID = diag::err_uncasted_call_of_unknown_any;
14925 if (
DeclRefExpr *ref = dyn_cast<DeclRefExpr>(E)) {
14926 loc = ref->getLocation();
14927 d = ref->getDecl();
14928 }
else if (
MemberExpr *mem = dyn_cast<MemberExpr>(E)) {
14929 loc = mem->getMemberLoc();
14930 d = mem->getMemberDecl();
14932 diagID = diag::err_uncasted_call_of_unknown_any;
14933 loc = msg->getSelectorStartLoc();
14934 d = msg->getMethodDecl();
14936 S.
Diag(loc, diag::err_uncasted_send_to_unknown_any_method)
14937 <<
static_cast<unsigned>(msg->isClassMessage()) << msg->getSelector()
14938 << orig->getSourceRange();
14943 << E->getSourceRange();
14947 S.
Diag(loc, diagID) << d << orig->getSourceRange();
14966 if (!placeholderType)
return E;
14968 switch (placeholderType->
getKind()) {
14971 case BuiltinType::Overload: {
14991 case BuiltinType::BoundMember: {
14996 if (isa<CXXPseudoDestructorExpr>(BME)) {
14997 PD =
PDiag(diag::err_dtor_expr_without_call) << 1;
14998 }
else if (
const auto *ME = dyn_cast<MemberExpr>(BME)) {
14999 if (ME->getMemberNameInfo().getName().getNameKind() ==
15001 PD =
PDiag(diag::err_dtor_expr_without_call) << 0;
15009 case BuiltinType::ARCUnbridgedCast: {
15016 case BuiltinType::UnknownAny:
15020 case BuiltinType::PseudoObject:
15023 case BuiltinType::BuiltinFn: {
15027 auto *FD = cast<FunctionDecl>(DRE->getDecl());
15028 if (FD->getBuiltinID() == Builtin::BI__noop) {
15030 CK_BuiltinFnToFnPtr).
get();
15036 Diag(E->getLocStart(), diag::err_builtin_fn_use);
15041 case BuiltinType::OMPArraySection:
15042 Diag(E->getLocStart(), diag::err_omp_array_section_use);
15046 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
15047 case BuiltinType::Id:
15048 #include "clang/Basic/OpenCLImageTypes.def"
15049 #define BUILTIN_TYPE(Id, SingletonId) case BuiltinType::Id:
15050 #define PLACEHOLDER_TYPE(Id, SingletonId)
15051 #include "clang/AST/BuiltinTypes.def"
15055 llvm_unreachable(
"invalid placeholder type!");
15069 assert((Kind == tok::kw___objc_yes || Kind == tok::kw___objc_no) &&
15070 "Unknown Objective-C Boolean value!");
15093 auto Spec = std::find_if(AvailSpecs.begin(), AvailSpecs.end(),
15095 return Spec.getPlatform() == Platform;
15099 if (Spec != AvailSpecs.end())
15100 Version = Spec->getVersion();
15105 Diag(AtLoc, diag::warn_available_using_star_case) << RParen << Platform;
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
unsigned getFlags() const
getFlags - Return the flags for this scope.
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)
ConditionResult ActOnCondition(Scope *S, SourceLocation Loc, Expr *SubExpr, ConditionKind CK)
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 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...
ParsedType CreateParsedType(QualType T, TypeSourceInfo *TInfo)
Package the given type and TSI into a ParsedType.
static bool isVariableAlreadyCapturedInScopeInfo(CapturingScopeInfo *CSI, VarDecl *Var, bool &SubCapturesAreNested, QualType &CaptureType, QualType &DeclRefType)
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.
ExprResult PerformContextuallyConvertToBool(Expr *From)
PerformContextuallyConvertToBool - Perform a contextual conversion of the expression From to bool (C+...
The current expression occurs within an unevaluated operand that unconditionally permits abstract ref...
bool isSignedOverflowDefined() const
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.
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
ArrayRef< Capture > captures() 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 isPODType(const ASTContext &Context) const
Determine whether this is a Plain Old Data (POD) type (C++ 3.9p10).
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
QualType getCallResultType(const ASTContext &Context) const
Determine the type of an expression that calls a function of this type.
static bool checkBlockType(Sema &S, const Expr *E)
Return true if the Expr is block type.
Represents a version number in the form major[.minor[.subminor[.build]]].
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.
EnableIfAttr * CheckEnableIf(FunctionDecl *Function, ArrayRef< Expr * > Args, bool MissingImplicitThis=false)
Check the enable_if expressions on the given function.
bool isMemberPointerType() const
SourceLocation getLocation() const
DeclContext * getFunctionLevelDeclContext()
ExprResult ActOnIntegerConstant(SourceLocation Loc, uint64_t Val)
TheContext getContext() const
static const CastKind CK_Invalid
__SIZE_TYPE__ size_t
The unsigned integer type of the result of the sizeof operator.
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.
bool CheckParmsForFunctionDef(ArrayRef< ParmVarDecl * > Parameters, bool CheckParameterNames)
Helpers for dealing with blocks and functions.
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.
static void addAsFieldToClosureType(Sema &S, LambdaScopeInfo *LSI, QualType FieldType, QualType DeclRefType, SourceLocation Loc, bool RefersToCapturedVariable)
Create a field within the lambda class for the variable being captured.
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 ConditionResult ConditionError()
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.
FullExprArg MakeFullExpr(Expr *Arg)
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.
void computeNRVO(Stmt *Body, sema::FunctionScopeInfo *Scope)
Given the set of return statements within a function body, compute the variables that are subject to ...
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.
bool GatherArgumentsForCall(SourceLocation CallLoc, FunctionDecl *FDecl, const FunctionProtoType *Proto, unsigned FirstParam, ArrayRef< Expr * > Args, SmallVectorImpl< Expr * > &AllArgs, VariadicCallType CallType=VariadicDoesNotApply, bool AllowExplicit=false, bool IsListInitialization=false)
GatherArgumentsForCall - Collector argument expressions for various form of call prototypes.
ExprResult BuildCallToMemberFunction(Scope *S, Expr *MemExpr, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc)
BuildCallToMemberFunction - Build a call to a member function.
SourceLocation getLocStart() const LLVM_READONLY
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...
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...
bool isOpenMPTargetCapturedDecl(ValueDecl *D, unsigned Level)
Check if the specified variable is captured by 'target' directive.
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.
This is a while, do, switch, for, etc that can have break statements embedded into it...
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.
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.
static bool convertPointersToCompositeType(Sema &S, SourceLocation Loc, ExprResult &LHS, ExprResult &RHS)
Returns false if the pointers are converted to a composite type, true otherwise.
Incompatible - We reject this conversion outright, it is invalid to represent it in the AST...
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.
Represents a path from a specific derived class (which is not represented as part of the path) to a p...
bool isInSystemMacro(SourceLocation loc)
Returns whether Loc is expanded from a macro in a system header.
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...
void MarkFunctionReferenced(SourceLocation Loc, FunctionDecl *Func, bool MightBeOdrUse=true)
Mark a function referenced, and check whether it is odr-used (C++ [basic.def.odr]p2, C99 6.9p3)
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.
void InstantiateVariableDefinition(SourceLocation PointOfInstantiation, VarDecl *Var, bool Recursive=false, bool DefinitionRequired=false, bool AtEndOfTU=false)
const llvm::APInt & getSize() const
ExprResult ActOnGNUNullExpr(SourceLocation TokenLoc)
static InitializedEntity InitializeTemporary(QualType Type)
Create the initialization entity for a temporary.
void DiagnoseInvalidJumps(Stmt *Body)
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.
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.
CleanupInfo Cleanup
Used to control the generation of ExprWithCleanups.
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()
DiagnosticsEngine & Diags
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.
llvm::MapVector< NamedDecl *, SourceLocation > UndefinedButUsed
UndefinedInternals - all the used, undefined objects which require a definition in this translation u...
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 ObjCPropertyDecl * findPropertyDecl(const DeclContext *DC, const IdentifierInfo *propertyID, ObjCPropertyQueryKind queryKind)
Lookup a property by name in the specified DeclContext.
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
void setHasBranchProtectedScope()
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.
ExprResult PerformImplicitConversion(Expr *From, QualType ToType, AssignmentAction Action, bool AllowExplicit=false)
PerformImplicitConversion - Perform an implicit conversion of the expression From to the type ToType...
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.
static Sema::AssignConvertType checkObjCPointerTypesForAssignment(Sema &S, QualType LHSType, QualType RHSType)
checkObjCPointerTypesForAssignment - Compares two objective-c pointer types for assignment compatibil...
unsigned getNumParams() const
Expr * FixOverloadedFunctionReference(Expr *E, DeclAccessPair FoundDecl, FunctionDecl *Fn)
FixOverloadedFunctionReference - E is an expression that refers to a C++ overloaded function (possibl...
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 ...
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Computes the source location just past the end of the token at this source location.
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 hasAnyUnrecoverableErrorsInThisFunction() const
Determine whether any errors occurred within this function/method/ block.
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...
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.
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 IsDerivedFrom(SourceLocation Loc, QualType Derived, QualType Base)
Determine whether the type Derived is a C++ class that is derived from the type Base.
bool isReferenceType() const
sema::BlockScopeInfo * getCurBlock()
Retrieve the current block, if any.
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...
void checkSpecializationVisibility(SourceLocation Loc, NamedDecl *Spec)
We've found a use of a templated declaration that would trigger an implicit instantiation.
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.
bool CheckObjCBridgeRelatedConversions(SourceLocation Loc, QualType DestType, QualType SrcType, Expr *&SrcExpr, bool Diagnose=true)
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.
Token - This structure provides full information about a lexed token.
static DeclRefExpr * Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *D, bool RefersToEnclosingVariableOrCapture, SourceLocation NameLoc, QualType T, ExprValueKind VK, NamedDecl *FoundD=nullptr, const TemplateArgumentListInfo *TemplateArgs=nullptr)
CompatiblePointerDiscardsQualifiers - The assignment discards c/v/r qualifiers, which we accept as an...
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.
ExprResult CreateOverloadedUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc, const UnresolvedSetImpl &Fns, Expr *input)
Create a unary operation that may resolve to an overloaded operator.
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.
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.
void CheckObjCBridgeRelatedCast(QualType castType, Expr *castExpr)
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
void CheckExtraCXXDefaultArguments(Declarator &D)
CheckExtraCXXDefaultArguments - Check for any extra default arguments in the declarator, which is not a function declaration or definition and therefore is not permitted to have default arguments.
SourceRange getExprRange(Expr *E) const
No entity found met the criteria within the current instantiation,, but there were dependent base cla...
void NoteDeletedFunction(FunctionDecl *FD)
Emit a note explaining that this function is deleted.
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)
The controlling scope in a if/switch/while/for statement.
Provides information about a function template specialization, which is a FunctionDecl that has been ...
static bool checkCondition(Sema &S, Expr *Cond, SourceLocation QuestionLoc)
Return false if the condition expression is valid, true otherwise.
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.
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
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.
bool CanUseDecl(NamedDecl *D, bool TreatUnavailableAsInvalid)
Determine whether the use of this declaration is valid, without emitting diagnostics.
bool isCompleteType(SourceLocation Loc, QualType T)
bool findMacroSpelling(SourceLocation &loc, StringRef name)
Looks through the macro-expansion chain for the given location, looking for a macro expansion with th...
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.
bool IsOpenMPCapturedByRef(ValueDecl *D, unsigned Level)
Return true if the provided declaration VD should be captured by reference.
ExprResult CallExprUnaryConversions(Expr *E)
CallExprUnaryConversions - a special case of an unary conversion performed on a function designator o...
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 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.
bool exprNeedsCleanups() const
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.
This is a while, do, for, which can have continue statements embedded into it.
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.
bool containsDecl(Decl *D) const
Checks whether a declaration is in this context.
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
ExprResult ActOnObjCAvailabilityCheckExpr(llvm::ArrayRef< AvailabilitySpec > AvailSpecs, SourceLocation AtLoc, SourceLocation RParen)
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...
FunctionDecl * ResolveAddressOfOverloadedFunction(Expr *AddressOfExpr, QualType TargetType, bool Complain, DeclAccessPair &Found, bool *pHadMultipleCandidates=nullptr)
ResolveAddressOfOverloadedFunction - Try to resolve the address of an overloaded function (C++ [over...
ExprResult BuildOverloadedCallExpr(Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc, Expr *ExecConfig, bool AllowTypoCorrection=true, bool CalleesAddressIsTaken=false)
BuildOverloadedCallExpr - Given the call expression that calls Fn (which eventually refers to the dec...
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...
bool isVariadic() const
Whether this function is variadic.
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...
Represents a C++ nested-name-specifier or a global scope specifier.
static void captureVariablyModifiedType(ASTContext &Context, QualType T, CapturingScopeInfo *CSI)
void CheckTollFreeBridgeCast(QualType castType, Expr *castExpr)
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.
ExprResult CheckSwitchCondition(SourceLocation SwitchLoc, Expr *Cond)
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)
sema::AnalysisBasedWarnings AnalysisWarnings
Worker object for performing CFG-based warnings.
static void DiagnoseLogicalAndInLogicalOrRHS(Sema &S, SourceLocation OpLoc, Expr *LHSExpr, Expr *RHSExpr)
Look for '&&' in the right hand of a '||' expr.
A class that does preordor or postorder depth-first traversal on the entire Clang AST and visits each...
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...
Member name lookup, which finds the names of class/struct/union members.
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).
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.
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.
void InstantiateFunctionDefinition(SourceLocation PointOfInstantiation, FunctionDecl *Function, bool Recursive=false, bool DefinitionRequired=false, bool AtEndOfTU=false)
Instantiate the definition of the given function from its template.
bool hasPrototype() const
Whether this function has a prototype, either because one was explicitly written or because it was "i...
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
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
ExprResult checkPseudoObjectIncDec(Scope *S, SourceLocation OpLoc, UnaryOperatorKind Opcode, Expr *Op)
Check an increment or decrement of a pseudo-object expression.
FunctionTemplateSpecializationInfo * getTemplateSpecializationInfo() const
If this function is actually a function template specialization, retrieve information about this func...
ConditionalOperator - The ?: ternary operator.
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.
void MarkAnyDeclReferenced(SourceLocation Loc, Decl *D, bool MightBeOdrUse)
Perform marking for a reference to an arbitrary declaration.
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...
void CheckShadowingDeclModification(Expr *E, SourceLocation Loc)
Warn if 'E', which is an expression that is about to be modified, refers to a shadowing declaration...
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...
bool CheckPointerConversion(Expr *From, QualType ToType, CastKind &Kind, CXXCastPath &BasePath, bool IgnoreBaseAccess, bool Diagnose=true)
CheckPointerConversion - Check the pointer conversion from the expression From to the type ToType...
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
static QualType handleIntegerConversion(Sema &S, ExprResult &LHS, ExprResult &RHS, QualType LHSType, QualType RHSType, bool IsCompAssign)
Handle integer arithmetic conversions.
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.
ImplicitConversionSequence TryImplicitConversion(Expr *From, QualType ToType, bool SuppressUserConversions, bool AllowExplicit, bool InOverloadResolution, bool CStyle, bool AllowObjCWritebackConversion)
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
void mergeFrom(CleanupInfo Rhs)
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
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...
MultiLevelTemplateArgumentList getTemplateInstantiationArgs(NamedDecl *D, const TemplateArgumentList *Innermost=nullptr, bool RelativeToPrimary=false, const FunctionDecl *Pattern=nullptr)
Retrieve the template argument list(s) that should be used to instantiate the definition of the given...
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.
void DefineImplicitCopyConstructor(SourceLocation CurrentLocation, CXXConstructorDecl *Constructor)
DefineImplicitCopyConstructor - Checks for feasibility of defining this constructor as the copy const...
const Expr * getExpr(unsigned Init) const
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...
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.
bool isOpenMPPrivateDecl(ValueDecl *D, unsigned Level)
Check if the specified variable is used in 'private' clause.
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)
Overload resolution succeeded.
void PopFunctionScopeInfo(const sema::AnalysisBasedWarnings::Policy *WP=nullptr, const Decl *D=nullptr, const BlockExpr *blkExpr=nullptr)
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)
bool resolveAndFixAddressOfOnlyViableOverloadCandidate(ExprResult &SrcExpr)
Given an overloaded function, tries to turn it into a non-overloaded function reference using resolve...
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.
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. ...
FunctionDecl * ResolveSingleFunctionTemplateSpecialization(OverloadExpr *ovl, bool Complain=false, DeclAccessPair *Found=nullptr)
Given an expression that refers to an overloaded function, try to resolve that overloaded function ex...
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.
CleanupInfo ParentCleanup
Whether the enclosing context needed a cleanup.
Capture & getCapture(VarDecl *Var)
Retrieve the capture of the given variable, if it has been captured already.
Expr * getSubExpr() const
ObjCIvarDecl * lookupInstanceVariable(IdentifierInfo *IVarName, ObjCInterfaceDecl *&ClassDeclared)
void DefineImplicitMoveAssignment(SourceLocation CurrentLocation, CXXMethodDecl *MethodDecl)
Defines an implicitly-declared move assignment operator.
static bool TooManyArguments(size_t NumParams, size_t NumArgs, bool PartialOverloading=false)
To be used for checking whether the arguments being passed to function exceeds the number of paramete...
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.
A boolean condition, from 'if', 'while', 'for', or 'do'.
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
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.
ArrayRef< ParmVarDecl * > parameters() const
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...
DiagnosticsEngine & getDiagnostics() const
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...
void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext=true)
Add this decl to the scope shadowed decl chains.
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.
unsigned short CapRegionKind
The kind of captured region.
bool RequireCompleteExprType(Expr *E, TypeDiagnoser &Diagnoser)
Ensure that the type of the given expression is complete.
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.
TypeSourceInfo * GetTypeForDeclaratorCast(Declarator &D, QualType FromTy)
static InitializationKind CreateCopy(SourceLocation InitLoc, SourceLocation EqualLoc, bool AllowExplicitConvs=false)
Create a copy initialization.
ExprResult ActOnFinishFullExpr(Expr *Expr)
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 BuildCStyleCastExpr(SourceLocation LParenLoc, TypeSourceInfo *Ty, SourceLocation RParenLoc, Expr *Op)
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.
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
void DiagnoseUnusedParameters(ArrayRef< ParmVarDecl * > Parameters)
Diagnose any unused parameters in the given sequence of ParmVarDecl pointers.
static void MarkExprReferenced(Sema &SemaRef, SourceLocation Loc, Decl *D, Expr *E, bool MightBeOdrUse)
static bool isBitwiseOp(Opcode Opc)
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.
void PushBlockScope(Scope *BlockScope, BlockDecl *Block)
static QualType checkConditionalObjectPointersCompatibility(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc)
Return the resulting type when the operands are both pointers.
void checkDeclIsAllowedInOpenMPTarget(Expr *E, Decl *D)
Check declaration inside target region.
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.
ExprResult MaybeBindToTemporary(Expr *E)
MaybeBindToTemporary - If the passed in expression has a record type with a non-trivial destructor...
Assigning into this object requires the old value to be released and the new value to be retained...
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.
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.
bool CheckForConstantInitializer(Expr *e, QualType t)
type checking declaration initializers (C99 6.7.8)
unsigned getNumParams() const
getNumParams - Return the number of parameters this function must have based on its FunctionType...
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
This represents '#pragma omp declare reduction ...' directive.
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.
void checkRetainCycles(ObjCMessageExpr *msg)
checkRetainCycles - Check whether an Objective-C message send might create an obvious retain cycle...
CXXRecordDecl * Lambda
The class that describes the lambda.
const TemplateArgumentListInfo & getTemplateArgsInfo() const
static bool anyDependentTemplateArguments(ArrayRef< TemplateArgumentLoc > Args, bool &InstantiationDependent)
Determine whether any of the given template arguments are dependent.
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).
VarDecl * IsOpenMPCapturedDecl(ValueDecl *D)
Check if the specified variable is used in one of the private clauses (private, firstprivate, lastprivate, reduction etc.) in OpenMP constructs.
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)"...
CUDAFunctionTarget IdentifyCUDATarget(const FunctionDecl *D)
IdentifyCUDATarget - Determine the CUDA compilation target for this function.
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...
static bool IgnoreCommaOperand(const Expr *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.
bool isInOpenMPDeclareTargetContext() const
Return true inside OpenMP target region.
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?
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 CheckObjCARCUnavailableWeakConversion(QualType castType, QualType ExprType)
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 '...
bool isCXX98PODType(const ASTContext &Context) const
Return true if this is a POD type according to the rules of the C++98 standard, regardless of the cur...
bool isIntegralType(const ASTContext &Ctx) const
Determine whether this type is an integral type.
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...
ExprResult CheckCXXBooleanCondition(Expr *CondExpr, bool IsConstexpr=false)
CheckCXXBooleanCondition - Returns true if conversion to bool is invalid.
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.
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>.
MangleNumberingContext * getCurrentMangleNumberContext(const DeclContext *DC, Decl *&ManglingContextDecl)
Compute the mangling number context for a lambda expression or block literal.
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.
This template specialization was formed from a template-id but has not yet been declared, defined, or instantiated.
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 PerformOpenMPImplicitIntegerConversion(SourceLocation OpLoc, Expr *Op)
ExprResult HandleExprEvaluationContextForTypeof(Expr *E)
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
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)
ExprResult BuildCallToObjectOfClassType(Scope *S, Expr *Object, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc)
BuildCallToObjectOfClassType - Build a call to an object of class type (C++ [over.call.object]), which can end up invoking an overloaded function call operator (operator()) or performing a user-defined conversion on the object argument.
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)
QualType CXXCheckConditionalOperands(ExprResult &cond, ExprResult &lhs, ExprResult &rhs, ExprValueKind &VK, ExprObjectKind &OK, SourceLocation questionLoc)
Check the operands of ?: under C++ semantics.
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.
static bool isNumberOfArgsValidForCall(Sema &S, const FunctionDecl *Callee, std::size_t NumArgs)
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.
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...
static bool isInvalid(LocType Loc, bool *Invalid)
NonConstCaptureKind
Is the given expression (which must be 'const') a reference to a variable which was originally non-co...
static void ConstructTransparentUnion(Sema &S, ASTContext &C, ExprResult &EResult, QualType UnionType, FieldDecl *Field)
Constructs a transparent union from an expression that is used to initialize the transparent union...
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
void setBody(CompoundStmt *B)
void checkUnusedDeclAttributes(Declarator &D)
checkUnusedDeclAttributes - Given a declarator which is not being used to build a declaration...
StringRef getOpcodeStr() const
const Expr * getExpr() const
ParmVarDecl * BuildParmVarDeclForTypedef(DeclContext *DC, SourceLocation Loc, QualType T)
Synthesizes a variable for a parameter arising from a typedef.
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 void diagnoseStringPlusInt(Sema &Self, SourceLocation OpLoc, Expr *LHSExpr, Expr *RHSExpr)
diagnoseStringPlusInt - Emit a warning when adding an integer to a string literal.
bool isSentinelNullExpr(const Expr *E)
The base class of all kinds of template declarations (e.g., class, function, etc.).
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.
void deduceClosureReturnType(sema::CapturingScopeInfo &CSI)
Deduce a block or lambda's return type based on the return statements present in the body...
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 checkPseudoObjectAssignment(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opcode, Expr *LHS, Expr *RHS)
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_RValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CCK_ImplicitConversion)
ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
typedef char* __builtin_va_list;
static bool unsupportedTypeConversion(const Sema &S, QualType LHSType, QualType RHSType)
Diagnose attempts to convert between __float128 and long double if there is no support for such conve...
static bool CheckAlignOfExpr(Sema &S, Expr *E)
SourceLocation RAngleLoc
The location of the '>' after the template argument list.
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)
A constant boolean condition from 'if constexpr'.
A runtime availability query.
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 isLValue() const
isLValue - True if this expression is an "l-value" according to the rules of the current language...
void PushDeclContext(Scope *S, DeclContext *DC)
Set the current declaration context until it gets popped.
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
size_t param_size() const
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.
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.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
static CastKind ScalarTypeToBooleanCastKind(QualType ScalarTy)
ScalarTypeToBooleanCastKind - Returns the cast kind corresponding to the conversion from scalar type ...
bool hasAnyDependentBases() const
Determine whether this class has any dependent base classes which are not the current instantiation...
unsigned short OpenMPLevel
ExplicitCastExpr - An explicit cast written in the source code.
static bool checkArithmeticOnObjCPointer(Sema &S, SourceLocation opLoc, Expr *op)
Diagnose if arithmetic on the given ObjC pointer is illegal.
ExprResult ActOnPredefinedExpr(SourceLocation Loc, tok::TokenKind Kind)
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
void setInitializedFieldInUnion(FieldDecl *FD)
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
ExprResult SemaConvertVectorExpr(Expr *E, TypeSourceInfo *TInfo, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
SemaConvertVectorExpr - Handle __builtin_convertvector.
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.
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)
void markSafeWeakUse(const Expr *E)
Record that a given expression is a "safe" access of a weak object (e.g.
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.
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 CreateOverloadedArraySubscriptExpr(SourceLocation LLoc, SourceLocation RLoc, Expr *Base, Expr *Idx)
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)
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template instantiation this function represents.
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...
QualType CheckPointerToMemberOperands(ExprResult &LHS, ExprResult &RHS, ExprValueKind &VK, SourceLocation OpLoc, bool isIndirect)
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.
MaterializeTemporaryExpr * CreateMaterializeTemporaryExpr(QualType T, Expr *Temporary, bool BoundToLvalueReference)
Base for LValueReferenceType and RValueReferenceType.
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will (ultimately) call.
CanQualType BoundMemberTy
ActionResult< Stmt * > StmtResult
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
bool isCodeCompletionEnabled() const
Determine if we are performing code completion.
static Sema::AssignConvertType checkBlockPointerTypesForAssignment(Sema &S, QualType LHSType, QualType RHSType)
checkBlockPointerTypesForAssignment - This routine determines whether two block pointer types are com...
void CheckShadow(Scope *S, VarDecl *D, const LookupResult &R)
Diagnose variable or built-in function shadowing.
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 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.
void setExprNeedsCleanups(bool SideEffects)
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.
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
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.
This is a scope that can contain a declaration.
static void diagnoseDistinctPointerComparison(Sema &S, SourceLocation Loc, ExprResult &LHS, ExprResult &RHS, bool IsError)
Diagnose bad pointer comparisons.
QualType InvalidOperands(SourceLocation Loc, ExprResult &LHS, ExprResult &RHS)
the following "Check" methods will return a valid/converted QualType or a null QualType (indicating a...
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...
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
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.
An integral condition for a 'switch' statement.
ExprResult CreateUnaryExprOrTypeTraitExpr(TypeSourceInfo *TInfo, SourceLocation OpLoc, UnaryExprOrTypeTrait ExprKind, SourceRange R)
Build a sizeof or alignof expression given a type operand.
ExprResult SubstExpr(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs)
void DefineImplicitLambdaToBlockPointerConversion(SourceLocation CurrentLoc, CXXConversionDecl *Conv)
Define the "body" of the conversion from a lambda object to a block pointer.
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.
bool DiagnoseUnexpandedParameterPack(SourceLocation Loc, TypeSourceInfo *T, UnexpandedParameterPackContext UPPC)
If the given type contains an unexpanded parameter pack, diagnose the error.
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.
Policy getDefaultPolicy()
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD)
ProcessDeclAttributes - Given a declarator (PD) with attributes indicated in it, apply them to D...
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
static QualType getBaseOriginalType(const Expr *Base)
Return original type of the base expression for array section.
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
The current expression occurs within a discarded statement.
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...
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 isSubscriptPointerArithmetic() const
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()
void DiagnoseCommaOperator(const Expr *LHS, SourceLocation Loc)
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
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.
void DiagnoseSelfMove(const Expr *LHSExpr, const Expr *RHSExpr, SourceLocation OpLoc)
Warn if a value is moved to itself.
The name refers to a variable template whose specialization produces a variable.
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
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...
void checkUnsafeExprAssigns(SourceLocation Loc, Expr *LHS, Expr *RHS)
checkUnsafeExprAssigns - Check whether +1 expr is being assigned to weak/__unsafe_unretained expressi...
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 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.
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
IncompatibleObjCQualifiedId - The assignment is between a qualified id type and something else (that ...
ExprResult CheckBooleanCondition(SourceLocation Loc, Expr *E, bool IsConstexpr=false)
CheckBooleanCondition - Diagnose problems involving the use of the given expression as a boolean cond...
NamedDecl - This represents a decl with a name.
void setIdentifier(const IdentifierInfo *Id, SourceLocation IdLoc)
Specify that this unqualified-id was parsed as an identifier.
bool isInvalidType() const
ExprResult BuildVectorLiteral(SourceLocation LParenLoc, SourceLocation RParenLoc, Expr *E, TypeSourceInfo *TInfo)
Build an altivec or OpenCL literal.
ExprResult BuildObjCSubscriptExpression(SourceLocation RB, Expr *BaseExpr, Expr *IndexExpr, ObjCMethodDecl *getterMethod, ObjCMethodDecl *setterMethod)
Build an ObjC subscript pseudo-object expression, given that that's supported by the runtime...
void DiagnoseAlwaysNonNullPointer(Expr *E, Expr::NullPointerConstantKind NullType, bool IsEqual, SourceRange Range)
Diagnose pointers that are always non-null.
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.
ARCConversionResult CheckObjCARCConversion(SourceRange castRange, QualType castType, Expr *&op, CheckedConversionKind CCK, bool Diagnose=true, bool DiagnoseCFAudited=false, BinaryOperatorKind Opc=BO_PtrMemD)
Checks for invalid conversions and casts between retainable pointers and other pointer kinds...
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.
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)
StringRef getPlatformName() const
Retrieve the name of the platform as it is used in the availability attribute.
The lookup resulted in an error.
static void checkObjCPointerIntrospection(Sema &S, ExprResult &L, ExprResult &R, SourceLocation OpLoc)
Check if a bitwise-& is performed on an Objective-C pointer.
Represents the canonical version of C arrays with a specified constant size.
static bool IsArithmeticOp(BinaryOperatorKind Opc)
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
One specifier in an expression.
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".
TypeSourceInfo * GetTypeForDeclarator(Declarator &D, Scope *S)
GetTypeForDeclarator - Convert the type for the specified declarator to Type instances.
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.
llvm::DenseMap< ParmVarDecl *, SourceLocation > UnparsedDefaultArgLocs
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...
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)