45 #include "llvm/Support/ConvertUTF.h"
46 using namespace clang;
53 if (ParsingInitForAutoVars.count(D))
63 if (getLangOpts().CPlusPlus14 && FD->getReturnType()->isUndeducedType() &&
80 if (DC && !DC->
hasAttr<UnusedAttr>())
95 Cat->getMethod(OMD->getSelector(), OMD->isInstanceMethod()))
96 if (!CatMeth->hasAttr<AvailabilityAttr>())
104 bool ObjCPropertyAccess) {
124 if (IDecl->getDefinition()) {
125 D = IDecl->getDefinition();
133 if (
const EnumDecl *TheEnumDecl = dyn_cast<EnumDecl>(DC))
134 Result = TheEnumDecl->getAvailability(&Message);
143 if (PDeclResult == Result)
156 D, Message, Loc, UnknownObjCClass, ObjCPDecl,
162 if (isa<EnumConstantDecl>(D) || isa<EnumDecl>(D))
165 bool Warn = !D->
getAttr<AvailabilityAttr>()->isInherited();
174 if (Warn && isa<ObjCInterfaceDecl>(D))
177 if (!Redecl->hasAttr<AvailabilityAttr>() ||
178 Redecl->getAttr<AvailabilityAttr>()->isInherited())
183 UnknownObjCClass, ObjCPDecl,
191 D, Message, Loc, UnknownObjCClass, ObjCPDecl,
205 if (Method && Method->isDeleted() && Method->isDefaulted()) {
207 if (!Method->isImplicit())
213 if (CSM != CXXInvalid)
214 ShouldDeleteSpecialMember(Method, CSM,
true);
221 const_cast<CXXConstructorDecl*>(CD->getInheritedConstructor())) {
223 if (BaseCD->isDeleted()) {
224 NoteDeletedFunction(BaseCD);
228 Diag(BaseCD->getLocation(), diag::note_cannot_inherit);
242 if (I->getStorageClass() !=
SC_None)
287 if (!DowngradeWarning && UsedFn)
290 S.
Diag(Loc, DowngradeWarning ? diag::ext_internal_in_extern_inline_quiet
291 : diag::ext_internal_in_extern_inline)
296 S.
Diag(D->getCanonicalDecl()->getLocation(), diag::note_entity_declared_at)
306 Diag(DeclBegin, diag::note_convert_inline_to_static)
325 bool ObjCPropertyAccess) {
326 if (getLangOpts().
CPlusPlus && isa<FunctionDecl>(D)) {
329 SuppressedDiagnosticsMap::iterator
331 if (Pos != SuppressedDiagnostics.end()) {
333 for (
unsigned I = 0, N = Suppressed.size(); I != N; ++I)
334 Diag(Suppressed[I].first, Suppressed[I].second);
345 if (cast<FunctionDecl>(D)->isMain())
346 Diag(Loc, diag::ext_main_used);
350 if (ParsingInitForAutoVars.count(D)) {
351 Diag(Loc, diag::err_auto_variable_cannot_appear_in_own_initializer)
358 if (FD->isDeleted()) {
359 Diag(Loc, diag::err_deleted_function_use);
360 NoteDeletedFunction(FD);
366 if (getLangOpts().
CPlusPlus14 && FD->getReturnType()->isUndeducedType() &&
367 DeduceReturnType(FD, Loc))
386 return ": " + Message;
388 return std::string();
397 const SentinelAttr *attr = D->
getAttr<SentinelAttr>();
402 unsigned numFormalParams;
406 enum CalleeType { CT_Function, CT_Method, CT_Block } calleeType;
409 numFormalParams = MD->param_size();
410 calleeType = CT_Method;
411 }
else if (
FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
412 numFormalParams = FD->param_size();
413 calleeType = CT_Function;
414 }
else if (isa<VarDecl>(D)) {
420 calleeType = CT_Function;
423 calleeType = CT_Block;
429 numFormalParams = proto->getNumParams();
441 unsigned nullPos = attr->getNullPos();
442 assert((nullPos == 0 || nullPos == 1) &&
"invalid null position on sentinel");
443 numFormalParams = (nullPos > numFormalParams ? 0 : numFormalParams - nullPos);
446 unsigned numArgsAfterSentinel = attr->getSentinel();
450 if (Args.size() < numFormalParams + numArgsAfterSentinel + 1) {
457 Expr *sentinelExpr = Args[Args.size() - numArgsAfterSentinel - 1];
458 if (!sentinelExpr)
return;
467 = PP.getLocForEndOfToken(sentinelExpr->getLocEnd());
468 std::string NullValue;
469 if (calleeType == CT_Method && PP.isMacroDefined(
"nil"))
471 else if (getLangOpts().CPlusPlus11)
472 NullValue =
"nullptr";
473 else if (PP.isMacroDefined(
"NULL"))
476 NullValue =
"(void*) 0";
479 Diag(Loc, diag::warn_missing_sentinel) << int(calleeType);
481 Diag(MissingNilLoc, diag::warn_missing_sentinel)
505 assert(!Ty.
isNull() &&
"DefaultFunctionArrayConversion - missing type");
510 if (getLangOpts().OpenCL) {
528 if (getLangOpts().C99 || getLangOpts().CPlusPlus || E->
isLValue())
543 UO->getSubExpr()->IgnoreParenCasts()->
545 !UO->getType().isVolatileQualified()) {
547 S.
PDiag(diag::warn_indirection_through_null)
548 << UO->getSubExpr()->getSourceRange());
550 S.
PDiag(diag::note_indirection_through_null));
563 if (!Member || !Member->
isStr(
"isa"))
573 ObjCIvarDecl *IV = IDecl->lookupInstanceVariable(Member, ClassDeclared);
581 if (ObjectSetClass) {
624 assert(!T.
isNull() &&
"r-value conversion on typeless expression?");
628 if (getLangOpts().CPlusPlus &&
643 if (getLangOpts().OpenCL && !getOpenCLOptions().cl_khr_fp16 &&
652 NamedDecl *ObjectGetClass = LookupSingleName(TUScope,
659 SourceRange(OISA->getOpLoc(), OISA->getIsaMemberLoc()),
")");
679 UpdateMarkingForLValueToRValue(E);
683 if (getLangOpts().ObjCAutoRefCount &&
685 ExprNeedsCleanups =
true;
694 T = Atomic->getValueType().getUnqualifiedType();
703 ExprResult Res = DefaultFunctionArrayConversion(E);
706 Res = DefaultLvalueConversion(Res.
get());
725 Res = DefaultLvalueConversion(Res.
get());
738 ExprResult Res = DefaultFunctionArrayLvalueConversion(E);
744 assert(!Ty.
isNull() &&
"UsualUnaryConversions - missing type");
747 if (Ty->
isHalfType() && !getLangOpts().NativeHalfType)
787 assert(!Ty.
isNull() &&
"DefaultArgumentPromotion - missing type");
797 if (BTy && (BTy->
getKind() == BuiltinType::Half ||
798 BTy->
getKind() == BuiltinType::Float))
855 if (!Record->hasNonTrivialCopyConstructor() &&
856 !Record->hasNonTrivialMoveConstructor() &&
857 !Record->hasNonTrivialDestructor())
858 return VAK_ValidInCXX11;
866 if (getLangOpts().MSVCCompat)
867 return VAK_MSVCUndefined;
871 return VAK_Undefined;
881 case VAK_ValidInCXX11:
883 E->getLocStart(),
nullptr,
884 PDiag(diag::warn_cxx98_compat_pass_non_pod_arg_to_vararg)
891 DiagRuntimeBehavior(E->getLocStart(),
nullptr,
892 PDiag(diag::warn_pass_class_arg_to_vararg)
893 << Ty << CT << hasCStrMethod(E) <<
".c_str()");
898 case VAK_MSVCUndefined:
900 E->getLocStart(),
nullptr,
901 PDiag(diag::warn_cannot_pass_non_pod_arg_to_vararg)
902 << getLangOpts().CPlusPlus11 << Ty << CT);
908 E->getLocStart(),
nullptr,
909 PDiag(diag::err_cannot_pass_objc_interface_to_vararg)
912 Diag(E->getLocStart(), diag::err_cannot_pass_to_vararg)
913 << isa<InitListExpr>(E) << Ty << CT;
924 if (PlaceholderTy->getKind() == BuiltinType::ARCUnbridgedCast &&
925 (CT == VariadicMethod ||
926 (FDecl && FDecl->
hasAttr<CFAuditedTransferAttr>()))) {
927 E = stripARCUnbridgedCast(E);
938 ExprResult ExprRes = DefaultArgumentPromotion(E);
945 if (isValidVarArgType(E->
getType()) == VAK_Undefined) {
952 ExprResult TrapFn = ActOnIdExpression(TUScope, SS, TemplateKWLoc,
958 E->getLocStart(),
None,
972 diag::err_call_incomplete_argument))
989 if (SkipCast)
return false;
1008 bool IsCompAssign) {
1031 auto *LHSComplexType = dyn_cast<
ComplexType>(LHSType);
1032 auto *RHSComplexType = dyn_cast<
ComplexType>(RHSType);
1034 LHSComplexType ? LHSComplexType->getElementType() : LHSType;
1036 RHSComplexType ? RHSComplexType->getElementType() : RHSType;
1042 if (!IsCompAssign) {
1049 }
else if (Order > 0) {
1064 bool ConvertFloat,
bool ConvertInt) {
1094 QualType RHSType,
bool IsCompAssign) {
1100 if (LHSFloat && RHSFloat) {
1107 assert(order < 0 &&
"illegal float comparison");
1145 template <PerformCastFn doLHSCast, PerformCastFn doRHSCast>
1148 QualType RHSType,
bool IsCompAssign) {
1153 if (LHSSigned == RHSSigned) {
1156 RHS = (*doRHSCast)(
S, RHS.
get(), LHSType);
1158 }
else if (!IsCompAssign)
1159 LHS = (*doLHSCast)(
S, LHS.
get(), RHSType);
1161 }
else if (order != (LHSSigned ? 1 : -1)) {
1165 RHS = (*doRHSCast)(
S, RHS.
get(), LHSType);
1167 }
else if (!IsCompAssign)
1168 LHS = (*doLHSCast)(
S, LHS.
get(), RHSType);
1175 RHS = (*doRHSCast)(
S, RHS.
get(), LHSType);
1177 }
else if (!IsCompAssign)
1178 LHS = (*doLHSCast)(
S, LHS.
get(), RHSType);
1187 RHS = (*doRHSCast)(
S, RHS.
get(), result);
1189 LHS = (*doLHSCast)(
S, LHS.
get(), result);
1199 bool IsCompAssign) {
1203 if (LHSComplexInt && RHSComplexInt) {
1207 handleIntegerConversion<doComplexIntegralCast, doComplexIntegralCast>
1208 (
S, LHS, RHS, LHSEltType, RHSEltType, IsCompAssign);
1210 return S.Context.getComplexType(ScalarType);
1213 if (LHSComplexInt) {
1216 handleIntegerConversion<doComplexIntegralCast, doIntegralCast>
1217 (
S, LHS, RHS, LHSEltType, RHSType, IsCompAssign);
1219 RHS = S.ImpCastExprToType(RHS.get(), ComplexType,
1225 assert(RHSComplexInt);
1229 handleIntegerConversion<doIntegralCast, doComplexIntegralCast>
1230 (
S, LHS, RHS, LHSType, RHSEltType, IsCompAssign);
1234 LHS = S.ImpCastExprToType(LHS.get(), ComplexType,
1244 bool IsCompAssign) {
1245 if (!IsCompAssign) {
1246 LHS = UsualUnaryConversions(LHS.
get());
1251 RHS = UsualUnaryConversions(RHS.
get());
1264 LHSType = AtomicLHS->getValueType();
1267 if (LHSType == RHSType)
1276 QualType LHSUnpromotedType = LHSType;
1280 if (!LHSBitfieldPromoteTy.
isNull())
1281 LHSType = LHSBitfieldPromoteTy;
1282 if (LHSType != LHSUnpromotedType && !IsCompAssign)
1286 if (LHSType == RHSType)
1307 return handleIntegerConversion<doIntegralCast, doIntegralCast>
1308 (*
this, LHS, RHS, LHSType, RHSType, IsCompAssign);
1321 Expr *ControllingExpr,
1324 unsigned NumAssocs = ArgTypes.size();
1325 assert(NumAssocs == ArgExprs.size());
1328 for (
unsigned i = 0; i < NumAssocs; ++i) {
1330 (void) GetTypeFromParser(ArgTypes[i], &Types[i]);
1335 ExprResult ER = CreateGenericSelectionExpr(KeyLoc, DefaultLoc, RParenLoc,
1337 llvm::makeArrayRef(Types, NumAssocs),
1347 Expr *ControllingExpr,
1350 unsigned NumAssocs = Types.size();
1351 assert(NumAssocs == Exprs.size());
1353 ExprResult result = CheckPlaceholderExpr(ControllingExpr);
1355 ControllingExpr = result.
get();
1360 if (ActiveTemplateInstantiations.empty() &&
1363 diag::warn_side_effects_unevaluated_context);
1365 bool TypeErrorFound =
false,
1367 ContainsUnexpandedParameterPack
1370 for (
unsigned i = 0; i < NumAssocs; ++i) {
1371 if (Exprs[i]->containsUnexpandedParameterPack())
1372 ContainsUnexpandedParameterPack =
true;
1375 if (Types[i]->getType()->containsUnexpandedParameterPack())
1376 ContainsUnexpandedParameterPack =
true;
1378 if (Types[i]->getType()->isDependentType()) {
1379 IsResultDependent =
true;
1384 if (Types[i]->getType()->isIncompleteType())
1385 D = diag::err_assoc_type_incomplete;
1386 else if (!Types[i]->getType()->isObjectType())
1387 D = diag::err_assoc_type_nonobject;
1388 else if (Types[i]->getType()->isVariablyModifiedType())
1389 D = diag::err_assoc_type_variably_modified;
1392 Diag(Types[i]->getTypeLoc().getBeginLoc(), D)
1393 << Types[i]->getTypeLoc().getSourceRange()
1394 << Types[i]->getType();
1395 TypeErrorFound =
true;
1400 for (
unsigned j = i+1; j < NumAssocs; ++j)
1401 if (Types[j] && !Types[j]->getType()->isDependentType() &&
1403 Types[j]->getType())) {
1404 Diag(Types[j]->getTypeLoc().getBeginLoc(),
1405 diag::err_assoc_compatible_types)
1406 << Types[j]->getTypeLoc().getSourceRange()
1407 << Types[j]->getType()
1408 << Types[i]->getType();
1409 Diag(Types[i]->getTypeLoc().getBeginLoc(),
1410 diag::note_compat_assoc)
1411 << Types[i]->getTypeLoc().getSourceRange()
1412 << Types[i]->getType();
1413 TypeErrorFound =
true;
1423 if (IsResultDependent)
1425 Context, KeyLoc, ControllingExpr, Types, Exprs, DefaultLoc, RParenLoc,
1426 ContainsUnexpandedParameterPack);
1429 unsigned DefaultIndex = -1U;
1430 for (
unsigned i = 0; i < NumAssocs; ++i) {
1434 Types[i]->getType()))
1435 CompatIndices.push_back(i);
1441 if (CompatIndices.size() > 1) {
1445 Diag(ControllingExpr->getLocStart(), diag::err_generic_sel_multi_match)
1446 << ControllingExpr->getSourceRange() << ControllingExpr->
getType()
1447 << (
unsigned) CompatIndices.size();
1449 E = CompatIndices.end(); I != E; ++I) {
1450 Diag(Types[*I]->getTypeLoc().getBeginLoc(),
1451 diag::note_compat_assoc)
1452 << Types[*I]->getTypeLoc().getSourceRange()
1453 << Types[*I]->getType();
1461 if (DefaultIndex == -1U && CompatIndices.size() == 0) {
1465 Diag(ControllingExpr->getLocStart(), diag::err_generic_sel_no_match)
1466 << ControllingExpr->getSourceRange() << ControllingExpr->
getType();
1475 unsigned ResultIndex =
1476 CompatIndices.size() ? CompatIndices[0] : DefaultIndex;
1479 Context, KeyLoc, ControllingExpr, Types, Exprs, DefaultLoc, RParenLoc,
1480 ContainsUnexpandedParameterPack, ResultIndex);
1498 assert(Args.size() <= 2 &&
"too many arguments for literal operator");
1501 for (
unsigned ArgIdx = 0; ArgIdx != Args.size(); ++ArgIdx) {
1502 ArgTy[ArgIdx] = Args[ArgIdx]->getType();
1503 if (ArgTy[ArgIdx]->isArrayType())
1529 assert(!StringToks.empty() &&
"Must have at least one string!");
1532 if (Literal.hadError)
1536 for (
unsigned i = 0; i != StringToks.size(); ++i)
1537 StringTokLocs.push_back(StringToks[i].getLocation());
1541 if (Literal.isWide()) {
1544 }
else if (Literal.isUTF8()) {
1546 }
else if (Literal.isUTF16()) {
1549 }
else if (Literal.isUTF32()) {
1552 }
else if (Literal.isPascal()) {
1558 if (getLangOpts().CPlusPlus || getLangOpts().ConstStrings)
1565 llvm::APInt(32, Literal.GetNumStringChars()+1),
1569 if (getLangOpts().OpenCL) {
1575 Kind, Literal.Pascal, StrTy,
1577 StringTokLocs.size());
1578 if (Literal.getUDSuffix().empty())
1585 Literal.getUDSuffixOffset());
1589 return ExprError(
Diag(UDSuffixLoc, diag::err_invalid_string_udl));
1604 LookupResult R(*
this, OpName, UDSuffixLoc, LookupOrdinaryName);
1605 switch (LookupLiteralOperator(UDLScope, R, ArgTy,
1613 Expr *Args[] = { Lit, LenArg };
1615 return BuildLiteralOperatorCall(R, OpNameInfo, Args, StringTokLocs.back());
1618 case LOLR_StringTemplate: {
1623 llvm::APSInt
Value(CharBits, CharIsUnsigned);
1629 for (
unsigned I = 0, N = Lit->
getLength(); I != N; ++I) {
1635 return BuildLiteralOperatorCall(R, OpNameInfo,
None, StringTokLocs.back(),
1640 llvm_unreachable(
"unexpected literal operator lookup result");
1644 llvm_unreachable(
"unexpected literal operator lookup result");
1652 return BuildDeclRefExpr(D, Ty, VK, NameInfo, SS);
1662 if (getLangOpts().CUDA)
1663 if (
const FunctionDecl *Caller = dyn_cast<FunctionDecl>(CurContext))
1664 if (
const FunctionDecl *Callee = dyn_cast<FunctionDecl>(D)) {
1665 if (CheckCUDATarget(Caller, Callee)) {
1666 Diag(NameInfo.
getLoc(), diag::err_ref_bad_target)
1668 << IdentifyCUDATarget(Caller);
1675 bool RefersToCapturedVariable =
1677 NeedToCaptureVariable(cast<VarDecl>(D), NameInfo.
getLoc());
1680 if (isa<VarTemplateSpecializationDecl>(D)) {
1682 cast<VarTemplateSpecializationDecl>(D);
1687 RefersToCapturedVariable, NameInfo.
getLoc(), Ty, VK,
1688 FoundD, TemplateArgs);
1690 assert(!TemplateArgs &&
"No template arguments for non-variable"
1691 " template specialization references");
1695 NameInfo, Ty, VK, FoundD);
1698 MarkDeclRefReferenced(E);
1700 if (getLangOpts().ObjCARCWeak && isa<VarDecl>(D) &&
1702 !Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, E->getLocStart()))
1703 recordUseOfEvaluatedWeak(E);
1733 translateTemplateArguments(TemplateArgsPtr, Buffer);
1738 TemplateArgs = &Buffer;
1740 NameInfo = GetNameFromUnqualifiedId(Id);
1741 TemplateArgs =
nullptr;
1748 unsigned DiagnosticID,
unsigned DiagnosticSuggestID) {
1755 SemaRef.
Diag(TypoLoc, diag::err_no_member) << Typo << Ctx
1758 SemaRef.
Diag(TypoLoc, DiagnosticID) <<
Typo;
1763 bool DroppedSpecifier =
1767 ? diag::note_implicit_param_decl
1768 : diag::note_previous_decl;
1771 SemaRef.
PDiag(NoteID));
1774 << Typo << Ctx << DroppedSpecifier
1776 SemaRef.
PDiag(NoteID));
1784 std::unique_ptr<CorrectionCandidateCallback> CCC,
1789 unsigned diagnostic = diag::err_undeclared_var_use;
1790 unsigned diagnostic_suggest = diag::err_undeclared_var_use_suggest;
1794 diagnostic = diag::err_undeclared_use;
1795 diagnostic_suggest = diag::err_undeclared_use_suggest;
1803 ? CurContext :
nullptr;
1805 if (isa<CXXRecordDecl>(DC)) {
1806 LookupQualifiedName(R, DC);
1815 bool isDefaultArgument = !ActiveTemplateInstantiations.empty() &&
1816 ActiveTemplateInstantiations.back().Kind ==
1817 ActiveTemplateInstantiation::DefaultFunctionArgumentInstantiation;
1819 bool isInstance = CurMethod &&
1821 DC == CurMethod->
getParent() && !isDefaultArgument;
1827 if (getLangOpts().MSVCCompat)
1828 diagnostic = diag::ext_found_via_dependent_bases_lookup;
1833 CallsUndergoingInstantiation.back()->getCallee());
1837 DepMethod = CurMethod;
1843 DepMethod = cast<CXXMethodDecl>(
1845 assert(DepMethod &&
"No template pattern found");
1852 if (ULE->hasExplicitTemplateArgs())
1853 ULE->copyTemplateArgumentsInto(TList);
1856 SS.
Adopt(ULE->getQualifierLoc());
1861 ULE->getTemplateKeywordLoc(),
nullptr,
1863 ULE->hasExplicitTemplateArgs() ? &TList :
nullptr);
1864 CallsUndergoingInstantiation.back()->setCallee(DepExpr);
1871 Diag((*I)->getLocation(), diag::note_dependent_var_use);
1877 if (isDefaultArgument && ((*R.
begin())->isCXXInstanceMember())) {
1893 if (getLangOpts().MSVCCompat && isa<FunctionDecl>(DC) &&
1894 cast<FunctionDecl>(DC)->getFriendObjectKind() &&
1905 assert(!ExplicitTemplateArgs &&
1906 "Diagnosing an empty lookup with explicit template args!");
1907 *Out = CorrectTypoDelayed(
1911 diagnostic, diagnostic_suggest);
1913 nullptr, CTK_ErrorRecovery);
1916 }
else if (S && (Corrected =
1918 &SS, std::move(CCC), CTK_ErrorRecovery))) {
1919 std::string CorrectedStr(Corrected.
getAsString(getLangOpts()));
1920 bool DroppedSpecifier =
1924 bool AcceptableWithRecovery =
false;
1925 bool AcceptableWithoutRecovery =
false;
1933 CDEnd = Corrected.
end();
1934 CD != CDEnd; ++CD) {
1936 dyn_cast<FunctionTemplateDecl>(*CD))
1937 AddTemplateOverloadCandidate(
1940 else if (
FunctionDecl *FD = dyn_cast<FunctionDecl>(*CD))
1941 if (!ExplicitTemplateArgs || ExplicitTemplateArgs->
size() == 0)
1945 switch (OCS.BestViableFunction(*
this, R.
getNameLoc(), Best)) {
1947 ND = Best->Function;
1964 Record = cast<CXXRecordDecl>(
1969 AcceptableWithRecovery =
1970 isa<ValueDecl>(ND) || isa<FunctionTemplateDecl>(ND);
1976 AcceptableWithoutRecovery =
1977 isa<TypeDecl>(ND) || isa<ObjCInterfaceDecl>(ND);
1981 AcceptableWithoutRecovery =
true;
1984 if (AcceptableWithRecovery || AcceptableWithoutRecovery) {
1987 ? diag::note_implicit_param_decl
1988 : diag::note_previous_decl;
1990 diagnoseTypo(Corrected, PDiag(diagnostic_suggest) << Name,
1991 PDiag(NoteID), AcceptableWithRecovery);
1993 diagnoseTypo(Corrected, PDiag(diag::err_no_member_suggest)
1994 << Name << computeDeclContext(SS,
false)
1995 << DroppedSpecifier << SS.getRange(),
1996 PDiag(NoteID), AcceptableWithRecovery);
1999 return !AcceptableWithRecovery;
2006 if (!SS.isEmpty()) {
2008 << Name << computeDeclContext(SS,
false)
2035 else if (
auto *MD = dyn_cast<CXXMethodDecl>(S.
CurContext))
2043 auto DB = S.
Diag(Loc, diag::ext_undeclared_unqual_id_with_dependent_base);
2044 DB << NameInfo.
getName() << RD;
2046 if (!ThisType.
isNull()) {
2049 Context,
nullptr, ThisType,
true,
2051 nullptr, NameInfo, TemplateArgs);
2068 bool HasTrailingLParen,
bool IsAddressOfOperand,
2069 std::unique_ptr<CorrectionCandidateCallback> CCC,
2070 bool IsInlineAsmIdentifier,
Token *KeywordReplacement) {
2071 assert(!(IsAddressOfOperand && HasTrailingLParen) &&
2072 "cannot be direct & operand and have a trailing lparen");
2081 DecomposeUnqualifiedId(Id, TemplateArgsBuffer, NameInfo, TemplateArgs);
2098 bool DependentID =
false;
2102 }
else if (SS.
isSet()) {
2103 if (
DeclContext *DC = computeDeclContext(SS,
false)) {
2104 if (RequireCompleteDeclContext(SS, DC))
2112 return ActOnDependentIdExpression(SS, TemplateKWLoc, NameInfo,
2113 IsAddressOfOperand, TemplateArgs);
2118 ? LookupObjCImplicitSelfParam : LookupOrdinaryName);
2125 bool MemberOfUnknownSpecialization;
2126 LookupTemplateName(R, S, SS,
QualType(),
false,
2127 MemberOfUnknownSpecialization);
2129 if (MemberOfUnknownSpecialization ||
2131 return ActOnDependentIdExpression(SS, TemplateKWLoc, NameInfo,
2132 IsAddressOfOperand, TemplateArgs);
2134 bool IvarLookupFollowUp = II && !SS.
isSet() && getCurMethodDecl();
2135 LookupParsedName(R, S, &SS, !IvarLookupFollowUp);
2140 return ActOnDependentIdExpression(SS, TemplateKWLoc, NameInfo,
2141 IsAddressOfOperand, TemplateArgs);
2145 if (IvarLookupFollowUp) {
2146 ExprResult E(LookupInObjCMethod(R, S, II,
true));
2160 if (R.
empty() && HasTrailingLParen && II && !getLangOpts().CPlusPlus) {
2161 NamedDecl *D = ImplicitlyDefineFunction(NameLoc, *II, S);
2167 bool ADL = UseArgumentDependentLookup(SS, R, HasTrailingLParen);
2169 if (R.
empty() && !ADL) {
2170 if (SS.
isEmpty() && getLangOpts().MSVCCompat) {
2172 TemplateKWLoc, TemplateArgs))
2177 if (IsInlineAsmIdentifier)
2183 auto DefaultValidator = llvm::make_unique<CorrectionCandidateCallback>(
2185 DefaultValidator->IsAddressOfOperand = IsAddressOfOperand;
2186 assert((!CCC || CCC->IsAddressOfOperand == IsAddressOfOperand) &&
2187 "Typo correction callback misconfigured");
2190 CCC->setTypoName(II);
2194 if (DiagnoseEmptyLookup(S, SS, R,
2195 CCC ? std::move(CCC) : std::move(DefaultValidator),
2196 nullptr,
None, &TE)) {
2197 if (TE && KeywordReplacement) {
2198 auto &
State = getTypoExprState(TE);
2199 auto BestTC =
State.Consumer->getNextCorrection();
2200 if (BestTC.isKeyword()) {
2201 auto *II = BestTC.getCorrectionAsIdentifierInfo();
2202 if (
State.DiagHandler)
2203 State.DiagHandler(BestTC);
2205 KeywordReplacement->
setKind(II->getTokenID());
2207 KeywordReplacement->
setLocation(BestTC.getCorrectionRange().getBegin());
2210 clearDelayedTypo(TE);
2213 return (
Expr*)
nullptr;
2215 State.Consumer->resetCorrectionStream();
2220 assert(!R.
empty() &&
2221 "DiagnoseEmptyLookup returned false but added no results");
2228 ExprResult E(LookupInObjCMethod(R, S, Ivar->getIdentifier()));
2238 assert(!R.
empty() || ADL);
2264 if (!R.
empty() && (*R.
begin())->isCXXClassMember()) {
2265 bool MightBeImplicitMember;
2266 if (!IsAddressOfOperand)
2267 MightBeImplicitMember =
true;
2269 MightBeImplicitMember =
false;
2271 MightBeImplicitMember =
false;
2273 MightBeImplicitMember =
true;
2275 MightBeImplicitMember = isa<FieldDecl>(R.
getFoundDecl()) ||
2279 if (MightBeImplicitMember)
2280 return BuildPossibleImplicitMemberExpr(SS, TemplateKWLoc,
2284 if (TemplateArgs || TemplateKWLoc.
isValid()) {
2292 "There should only be one declaration found.");
2295 return BuildTemplateIdExpr(SS, TemplateKWLoc, R, ADL, TemplateArgs);
2298 return BuildDeclarationNameExpr(SS, R, ADL);
2308 bool IsAddressOfOperand,
2315 if (RequireCompleteDeclContext(SS, DC))
2319 LookupQualifiedName(R, DC);
2338 unsigned DiagID = diag::err_typename_missing;
2339 if (RecoveryTSI && getLangOpts().MSVCCompat)
2340 DiagID = diag::ext_typename_missing;
2342 auto D =
Diag(Loc, DiagID);
2373 if (!R.
empty() && (*R.
begin())->isCXXClassMember() && !IsAddressOfOperand)
2374 return BuildPossibleImplicitMemberExpr(SS,
2378 return BuildDeclarationNameExpr(SS, R,
false);
2412 LookForIvars =
true;
2413 else if (IsClassMethod)
2414 LookForIvars =
false;
2426 return ExprError(
Diag(Loc, diag::error_ivar_use_in_class_method)
2435 if (DiagnoseUseOfDecl(IV, Loc))
2441 !getLangOpts().DebuggerSupport)
2452 ExprResult SelfExpr = ActOnIdExpression(S, SelfScopeSpec, TemplateKWLoc,
2453 SelfName,
false,
false);
2457 SelfExpr = DefaultLvalueConversion(SelfExpr.
get());
2461 MarkAnyDeclReferenced(Loc, IV,
true);
2465 !IvarBacksCurrentMethodAccessor(IFace, CurMethod, IV))
2472 if (getLangOpts().ObjCAutoRefCount) {
2474 if (!Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, Loc))
2475 recordUseOfEvaluatedWeak(Result);
2477 if (CurContext->isClosure())
2478 Diag(Loc, diag::warn_implicitly_retains_self)
2491 Diag(Loc, diag::warn_ivar_use_hidden) << IV->getDeclName();
2498 return ExprError(
Diag(Loc, diag::error_ivar_use_in_class_method)
2499 << IV->getDeclName());
2502 if (Lookup.
empty() && II && AllowBuiltinCreation) {
2548 bool PointerConversions =
false;
2549 if (isa<FieldDecl>(Member)) {
2555 PointerConversions =
true;
2557 DestType = DestRecordType;
2558 FromRecordType = FromType;
2560 }
else if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Member)) {
2561 if (Method->isStatic())
2564 DestType = Method->getThisType(
Context);
2569 PointerConversions =
true;
2571 FromRecordType = FromType;
2572 DestType = DestRecordType;
2609 if (Qualifier && Qualifier->
getAsType()) {
2611 assert(QType->
isRecordType() &&
"lookup done with non-record type");
2618 if (IsDerivedFrom(FromRecordType, QRecordType)) {
2620 if (CheckDerivedToBaseConversion(FromRecordType, QRecordType,
2621 FromLoc, FromRange, &BasePath))
2624 if (PointerConversions)
2627 VK, &BasePath).get();
2630 FromRecordType = QRecordType;
2639 bool IgnoreAccess =
false;
2647 assert(isa<UsingShadowDecl>(FoundDecl));
2654 assert(IsDerivedFrom(FromRecordType, URecordType));
2656 if (CheckDerivedToBaseConversion(FromRecordType, URecordType,
2657 FromLoc, FromRange, &BasePath))
2661 if (PointerConversions)
2664 VK, &BasePath).get();
2666 FromRecordType = URecordType;
2671 IgnoreAccess =
true;
2675 if (CheckDerivedToBaseConversion(FromRecordType, DestRecordType,
2676 FromLoc, FromRange, &BasePath,
2686 bool HasTrailingLParen) {
2688 if (!HasTrailingLParen)
2696 if (!getLangOpts().CPlusPlus)
2717 if (isa<UsingShadowDecl>(D))
2718 D = cast<UsingShadowDecl>(D)->getTargetDecl();
2726 if (isa<FunctionDecl>(D)) {
2732 }
else if (!isa<FunctionTemplateDecl>(D))
2745 if (isa<TypedefNameDecl>(D)) {
2750 if (isa<ObjCInterfaceDecl>(D)) {
2755 if (isa<NamespaceDecl>(D)) {
2765 bool AcceptInvalidDecl) {
2799 bool AcceptInvalidDecl) {
2800 assert(D &&
"Cannot refer to a NULL declaration");
2801 assert(!isa<FunctionTemplateDecl>(D) &&
2802 "Cannot refer unambiguously to a function template");
2808 if (
TemplateDecl *Template = dyn_cast<TemplateDecl>(D)) {
2811 Diag(Loc, diag::err_template_decl_ref) << (isa<VarTemplateDecl>(D) ? 1 : 0)
2813 Diag(Template->getLocation(), diag::note_template_decl_here);
2820 Diag(Loc, diag::err_ref_non_value)
2830 if (DiagnoseUseOfDecl(VD, Loc))
2841 if (!indirectField->isCXXClassMember())
2842 return BuildAnonymousStructUnionMemberReference(SS, NameInfo.
getLoc(),
2851 #define ABSTRACT_DECL(kind)
2852 #define VALUE(type, base)
2853 #define DECL(type, base) \
2855 #include "clang/AST/DeclNodes.inc"
2856 llvm_unreachable(
"invalid value decl kind");
2859 case Decl::ObjCAtDefsField:
2860 case Decl::ObjCIvar:
2861 llvm_unreachable(
"forming non-member reference to ivar?");
2865 case Decl::EnumConstant:
2866 case Decl::UnresolvedUsingValue:
2875 case Decl::IndirectField:
2877 "building reference to field in C?");
2887 case Decl::NonTypeTemplateParm: {
2902 case Decl::VarTemplateSpecialization:
2903 case Decl::VarTemplatePartialSpecialization:
2913 case Decl::ImplicitParam:
2914 case Decl::ParmVar: {
2922 if (!isUnevaluatedContext()) {
2923 QualType CapturedType = getCapturedDeclRefType(cast<VarDecl>(VD), Loc);
2924 if (!CapturedType.
isNull())
2925 type = CapturedType;
2931 case Decl::Function: {
2932 if (
unsigned BID = cast<FunctionDecl>(VD)->getBuiltinID()) {
2951 if (getLangOpts().CPlusPlus) {
2961 if (!cast<FunctionDecl>(VD)->hasPrototype() &&
2962 isa<FunctionProtoType>(fty))
2971 case Decl::MSProperty:
2975 case Decl::CXXMethod:
2980 = dyn_cast<FunctionProtoType>(VD->
getType()))
2988 if (cast<CXXMethodDecl>(VD)->isStatic()) {
2994 case Decl::CXXConversion:
2995 case Decl::CXXDestructor:
2996 case Decl::CXXConstructor:
3001 return BuildDeclRefExpr(VD, type, valueKind, NameInfo, &SS, FoundD,
3008 Target.resize(CharByteWidth * (Source.size() + 1));
3009 char *ResultPtr = &Target[0];
3010 const UTF8 *ErrorPtr;
3011 bool success = ConvertUTF8toWide(CharByteWidth, Source, ResultPtr, ErrorPtr);
3014 Target.resize(ResultPtr - &Target[0]);
3020 Decl *currentDecl =
nullptr;
3022 currentDecl = BSI->TheDecl;
3024 currentDecl = LSI->CallOperator;
3026 currentDecl = CSI->TheCapturedDecl;
3028 currentDecl = getCurFunctionOrMethodDecl();
3031 Diag(Loc, diag::ext_predef_outside_function);
3037 if (cast<DeclContext>(currentDecl)->isDependentContext())
3043 unsigned Length = Str.length();
3045 llvm::APInt LengthI(32, Length + 1);
3071 default: llvm_unreachable(
"Unknown simple primary expr!");
3080 return BuildPredefinedExpr(Loc, IT);
3085 bool Invalid =
false;
3086 StringRef ThisTok = PP.getSpelling(Tok, CharBuffer, &Invalid);
3092 if (Literal.hadError())
3096 if (Literal.isWide())
3098 else if (Literal.isUTF16())
3100 else if (Literal.isUTF32())
3102 else if (!getLangOpts().CPlusPlus || Literal.isMultiChar())
3108 if (Literal.isWide())
3110 else if (Literal.isUTF16())
3112 else if (Literal.isUTF32())
3118 if (Literal.getUDSuffix().empty())
3128 return ExprError(
Diag(UDSuffixLoc, diag::err_invalid_character_udl));
3146 using llvm::APFloat;
3147 APFloat Val(Format);
3153 if ((result & APFloat::opOverflow) ||
3154 ((result & APFloat::opUnderflow) && Val.isZero())) {
3155 unsigned diagnostic;
3157 if (result & APFloat::opOverflow) {
3158 diagnostic = diag::warn_float_overflow;
3159 APFloat::getLargest(Format).toString(buffer);
3161 diagnostic = diag::warn_float_underflow;
3162 APFloat::getSmallest(Format).toString(buffer);
3165 S.
Diag(Loc, diagnostic)
3167 << StringRef(buffer.data(), buffer.size());
3170 bool isExact = (result == APFloat::opOK);
3175 assert(E &&
"Invalid expression");
3182 Diag(E->
getExprLoc(), diag::err_pragma_loop_invalid_argument_type) << QT;
3186 llvm::APSInt ValueAPS;
3187 ExprResult R = VerifyIntegerConstantExpression(E, &ValueAPS);
3192 bool ValueIsPositive = ValueAPS.isStrictlyPositive();
3193 if (!ValueIsPositive || ValueAPS.getActiveBits() > 31) {
3194 Diag(E->
getExprLoc(), diag::err_pragma_loop_invalid_argument_value)
3195 << ValueAPS.toString(10) << ValueIsPositive;
3206 const char Val = PP.getSpellingOfSingleCharacterNumericConstant(Tok);
3207 return ActOnIntegerConstant(Tok.
getLocation(), Val-
'0');
3215 SpellingBuffer.resize(Tok.
getLength() + 1);
3218 bool Invalid =
false;
3219 StringRef TokSpelling = PP.getSpelling(Tok, SpellingBuffer, &Invalid);
3224 if (Literal.hadError)
3227 if (Literal.hasUDSuffix()) {
3235 return ExprError(
Diag(UDSuffixLoc, diag::err_invalid_numeric_udl));
3238 if (Literal.isFloatingLiteral()) {
3259 LookupResult R(*
this, OpName, UDSuffixLoc, LookupOrdinaryName);
3260 switch (LookupLiteralOperator(UDLScope, R, CookedTy,
3268 if (Literal.isFloatingLiteral()) {
3272 if (Literal.GetIntegerValue(ResultVal))
3278 return BuildLiteralOperatorCall(R, OpNameInfo, Lit, TokLoc);
3285 unsigned Length = Literal.getUDSuffixOffset();
3291 false, StrTy, &TokLoc, 1);
3292 return BuildLiteralOperatorCall(R, OpNameInfo, Lit, TokLoc);
3295 case LOLR_Template: {
3302 bool CharIsUnsigned =
Context.
CharTy->isUnsignedIntegerType();
3303 llvm::APSInt
Value(CharBits, CharIsUnsigned);
3304 for (
unsigned I = 0, N = Literal.getUDSuffixOffset(); I != N; ++I) {
3305 Value = TokSpelling[I];
3310 return BuildLiteralOperatorCall(R, OpNameInfo,
None, TokLoc,
3313 case LOLR_StringTemplate:
3314 llvm_unreachable(
"unexpected literal operator lookup result");
3320 if (Literal.isFloatingLiteral()) {
3322 if (Literal.isFloat)
3324 else if (!Literal.isLong)
3332 if (getLangOpts().SinglePrecisionConstants) {
3334 }
else if (getLangOpts().OpenCL &&
3335 !((getLangOpts().OpenCLVersion >= 120) ||
3336 getOpenCLOptions().cl_khr_fp64)) {
3341 }
else if (!Literal.isIntegerLiteral()) {
3347 if (!getLangOpts().
C99 && Literal.isLongLong) {
3350 getLangOpts().CPlusPlus11 ?
3351 diag::warn_cxx98_compat_longlong : diag::ext_cxx11_longlong);
3362 if (Literal.MicrosoftInteger == 128 && MaxWidth < 128 &&
3365 llvm::APInt ResultVal(MaxWidth, 0);
3367 if (Literal.GetIntegerValue(ResultVal)) {
3373 "long long is not intmax_t?");
3380 bool AllowUnsigned = Literal.isUnsigned || Literal.getRadix() != 10;
3386 if (Literal.MicrosoftInteger) {
3387 if (Literal.MicrosoftInteger > MaxWidth) {
3392 }
else if (Literal.MicrosoftInteger == 8 && !Literal.isUnsigned) {
3396 Width = Literal.MicrosoftInteger;
3398 !Literal.isUnsigned);
3402 if (Ty.
isNull() && !Literal.isLong && !Literal.isLongLong) {
3407 if (ResultVal.isIntN(IntSize)) {
3409 if (!Literal.isUnsigned && ResultVal[IntSize-1] == 0)
3411 else if (AllowUnsigned)
3418 if (Ty.
isNull() && !Literal.isLongLong) {
3422 if (ResultVal.isIntN(LongSize)) {
3424 if (!Literal.isUnsigned && ResultVal[LongSize-1] == 0)
3426 else if (AllowUnsigned)
3430 else if (!getLangOpts().C99 && !getLangOpts().CPlusPlus11) {
3431 const unsigned LongLongSize =
3434 getLangOpts().CPlusPlus
3436 ? diag::warn_old_implicitly_unsigned_long_cxx
3438 ext_old_implicitly_unsigned_long_cxx
3439 : diag::warn_old_implicitly_unsigned_long)
3440 << (LongLongSize > LongSize ? 0
3453 if (ResultVal.isIntN(LongLongSize)) {
3457 if (!Literal.isUnsigned && (ResultVal[LongLongSize-1] == 0 ||
3458 (getLangOpts().MicrosoftExt && Literal.isLongLong)))
3460 else if (AllowUnsigned)
3462 Width = LongLongSize;
3469 Diag(Tok.
getLocation(), diag::ext_integer_literal_too_large_for_signed);
3474 if (ResultVal.getBitWidth() != Width)
3475 ResultVal = ResultVal.trunc(Width);
3481 if (Literal.isImaginary)
3489 assert(E &&
"ActOnParenExpr() missing expr");
3501 S.
Diag(Loc, diag::err_vecstep_non_scalar_vector_type)
3507 "Scalar types should always be complete");
3523 S.
Diag(Loc, diag::ext_sizeof_alignof_function_type)
3524 << TraitKind << ArgRange;
3531 unsigned DiagID = S.
LangOpts.OpenCL ? diag::err_opencl_sizeof_alignof_type
3532 : diag::ext_sizeof_alignof_void_type;
3533 S.
Diag(Loc, DiagID) << TraitKind << ArgRange;
3547 S.
Diag(Loc, diag::err_sizeof_nonfragile_interface)
3569 S.
Diag(Loc, diag::warn_sizeof_array_decay) << ICE->getSourceRange()
3588 E->getSourceRange());
3592 E->getSourceRange(), ExprKind))
3602 diag::err_sizeof_alignof_incomplete_type, ExprKind,
3603 E->getSourceRange()))
3606 if (RequireCompleteExprType(E, diag::err_sizeof_alignof_incomplete_type,
3607 ExprKind, E->getSourceRange()))
3617 << ExprKind << E->getSourceRange();
3625 Diag(E->
getExprLoc(), diag::warn_side_effects_unevaluated_context);
3628 E->getSourceRange(), ExprKind))
3633 if (
ParmVarDecl *PVD = dyn_cast<ParmVarDecl>(DeclRef->getFoundDecl())) {
3634 QualType OType = PVD->getOriginalType();
3639 Diag(PVD->getLocation(), diag::note_declared_at);
3703 if (RequireCompleteType(OpLoc, ExprType,
3704 diag::err_sizeof_alignof_incomplete_type,
3705 ExprKind, ExprRange))
3709 Diag(OpLoc, diag::err_sizeof_alignof_function_type)
3710 << ExprKind << ExprRange;
3730 << 1 << E->getSourceRange();
3735 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
3737 }
else if (
MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
3738 D = ME->getMemberDecl();
3758 if (
FieldDecl *FD = dyn_cast_or_null<FieldDecl>(D)) {
3761 if (!FD->getParent()->isCompleteDefinition()) {
3762 S.
Diag(E->
getExprLoc(), diag::err_alignof_member_of_incomplete_type)
3763 << E->getSourceRange();
3771 if (!FD->getType()->isReferenceType())
3785 return CheckUnaryExprOrTypeTraitOperand(E,
UETT_VecStep);
3800 CheckUnaryExprOrTypeTraitOperand(T, OpLoc, R, ExprKind))
3826 isInvalid = CheckVecStepExpr(E);
3834 isInvalid = CheckUnaryExprOrTypeTraitOperand(E,
UETT_SizeOf);
3841 PE = TransformToPotentiallyEvaluated(E);
3864 return CreateUnaryExprOrTypeTraitExpr(TInfo, OpLoc, ExprKind, ArgRange);
3868 ExprResult Result = CreateUnaryExprOrTypeTraitExpr(ArgEx, OpLoc, ExprKind);
3874 if (V.
get()->isTypeDependent())
3886 return CT->getElementType();
3889 if (V.
get()->getType()->isArithmeticType())
3890 return V.
get()->getType();
3895 if (PR.
get() != V.
get()) {
3901 S.
Diag(Loc, diag::err_realimag_invalid_type) << V.
get()->getType()
3902 << (IsReal ?
"__real" :
"__imag");
3913 default: llvm_unreachable(
"Unknown unary op!");
3915 case tok::minusminus: Opc =
UO_PostDec;
break;
3921 Input = Result.
get();
3923 return BuildUnaryOp(S, OpLoc, Opc, Input);
3934 !S.
LangOpts.ObjCSubscriptingLegacyRuntime)
3937 S.
Diag(opLoc, diag::err_arithmetic_nonfragile_interface)
3939 << op->getSourceRange();
3947 if (isa<ParenListExpr>(base)) {
3948 ExprResult result = MaybeConvertParenListExprToParenExpr(S, base);
3950 base = result.
get();
3959 ExprResult result = CheckPlaceholderExpr(base);
3961 base = result.
get();
3964 ExprResult result = CheckPlaceholderExpr(idx);
3984 if (getLangOpts().CPlusPlus &&
3988 return CreateOverloadedArraySubscriptExpr(lbLoc, rbLoc, base, idx);
3991 return CreateBuiltinArraySubscriptExpr(base, lbLoc, idx, rbLoc);
3997 Expr *LHSExp = Base;
4005 LHSExp = Result.
get();
4010 RHSExp = Result.
get();
4020 Expr *BaseExpr, *IndexExpr;
4037 if (!LangOpts.isSubscriptPointerArithmetic())
4038 return BuildObjCSubscriptExpression(RLoc, BaseExpr, IndexExpr,
nullptr,
4053 if (!LangOpts.isSubscriptPointerArithmetic()) {
4054 Diag(LLoc, diag::err_subscript_nonfragile_interface)
4055 << ResultType << BaseExpr->getSourceRange();
4066 ResultType = VTy->getElementType();
4073 Diag(LHSExp->getLocStart(), diag::ext_subscript_non_lvalue) <<
4074 LHSExp->getSourceRange();
4082 }
else if (RHSTy->isArrayType()) {
4084 Diag(RHSExp->getLocStart(), diag::ext_subscript_non_lvalue) <<
4085 RHSExp->getSourceRange();
4094 return ExprError(
Diag(LLoc, diag::err_typecheck_subscript_value)
4095 << LHSExp->getSourceRange() << RHSExp->getSourceRange());
4099 return ExprError(
Diag(LLoc, diag::err_typecheck_subscript_not_integer)
4100 << IndexExpr->getSourceRange());
4105 Diag(LLoc, diag::warn_subscript_is_char) << IndexExpr->getSourceRange();
4112 Diag(BaseExpr->getLocStart(), diag::err_subscript_function_type)
4113 << ResultType << BaseExpr->getSourceRange();
4117 if (ResultType->
isVoidType() && !getLangOpts().CPlusPlus) {
4119 Diag(LLoc, diag::ext_gnu_subscript_void_type)
4120 << BaseExpr->getSourceRange();
4126 RequireCompleteType(LLoc, ResultType,
4127 diag::err_subscript_incomplete_type, BaseExpr))
4130 assert(VK ==
VK_RValue || LangOpts.CPlusPlus ||
4142 diag::err_use_of_default_argument_to_function_declared_later) <<
4144 Diag(UnparsedDefaultArgLocs[Param],
4145 diag::note_default_argument_declared_here);
4157 = getTemplateInstantiationArgs(FD,
nullptr,
true);
4161 if (Inst.isInvalid())
4172 Result = SubstExpr(UninstExpr, MutiLevelArgList);
4182 UninstExpr->getLocStart());
4186 Result = InitSeq.Perform(*
this, Entity, Kind, ResultE);
4203 if (isa<ExprWithCleanups>(Param->
getInit())) {
4206 ExprNeedsCleanups =
true;
4211 assert(!cast<ExprWithCleanups>(Param->
getInit())->getNumObjects() &&
4212 "default argument expression has capturing blocks?");
4228 if (dyn_cast_or_null<CXXConstructorDecl>(FDecl))
4229 return VariadicConstructor;
4231 return VariadicBlock;
4233 if (
CXXMethodDecl *Method = dyn_cast_or_null<CXXMethodDecl>(FDecl))
4234 if (Method->isInstance())
4235 return VariadicMethod;
4237 return VariadicMethod;
4238 return VariadicFunction;
4240 return VariadicDoesNotApply;
4249 FunctionName(FuncName) {}
4251 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
4275 llvm::make_unique<FunctionCallCCC>(
S, FuncName.getAsIdentifierInfo(),
4278 if (
NamedDecl *ND = Corrected.getCorrectionDecl()) {
4279 if (Corrected.isOverloaded()) {
4283 CDEnd = Corrected.end();
4284 CD != CDEnd; ++CD) {
4291 ND = Best->Function;
4292 Corrected.setCorrectionDecl(ND);
4298 if (isa<ValueDecl>(ND) || isa<FunctionTemplateDecl>(ND)) {
4318 bool IsExecConfig) {
4328 bool Invalid =
false;
4337 if (Args.size() < NumParams) {
4338 if (Args.size() < MinArgs) {
4343 ? diag::err_typecheck_call_too_few_args_suggest
4344 : diag::err_typecheck_call_too_few_args_at_least_suggest;
4345 diagnoseTypo(TC, PDiag(diag_id) << FnKind << MinArgs
4346 << static_cast<unsigned>(Args.size())
4351 ? diag::err_typecheck_call_too_few_args_one
4352 : diag::err_typecheck_call_too_few_args_at_least_one)
4353 << FnKind << FDecl->
getParamDecl(0) << Fn->getSourceRange();
4356 ? diag::err_typecheck_call_too_few_args
4357 : diag::err_typecheck_call_too_few_args_at_least)
4358 << FnKind << MinArgs << static_cast<unsigned>(Args.size())
4359 << Fn->getSourceRange();
4362 if (!TC && FDecl && !FDecl->
getBuiltinID() && !IsExecConfig)
4373 if (Args.size() > NumParams) {
4379 ? diag::err_typecheck_call_too_many_args_suggest
4380 : diag::err_typecheck_call_too_many_args_at_most_suggest;
4381 diagnoseTypo(TC, PDiag(diag_id) << FnKind << NumParams
4382 << static_cast<unsigned>(Args.size())
4384 }
else if (NumParams == 1 && FDecl &&
4386 Diag(Args[NumParams]->getLocStart(),
4387 MinArgs == NumParams
4388 ? diag::err_typecheck_call_too_many_args_one
4389 : diag::err_typecheck_call_too_many_args_at_most_one)
4391 <<
static_cast<unsigned>(Args.size()) << Fn->getSourceRange()
4393 Args.back()->getLocEnd());
4395 Diag(Args[NumParams]->getLocStart(),
4396 MinArgs == NumParams
4397 ? diag::err_typecheck_call_too_many_args
4398 : diag::err_typecheck_call_too_many_args_at_most)
4399 << FnKind << NumParams << static_cast<unsigned>(Args.size())
4400 << Fn->getSourceRange()
4402 Args.back()->getLocEnd());
4405 if (!TC && FDecl && !FDecl->
getBuiltinID() && !IsExecConfig)
4417 Invalid = GatherArgumentsForCall(Call->
getLocStart(), FDecl,
4418 Proto, 0, Args, AllArgs, CallType);
4421 unsigned TotalNumArgs = AllArgs.size();
4422 for (
unsigned i = 0; i < TotalNumArgs; ++i)
4423 Call->
setArg(i, AllArgs[i]);
4433 bool IsListInitialization) {
4435 bool Invalid =
false;
4438 for (
unsigned i = FirstParam; i < NumParams; i++) {
4443 if (ArgIx < Args.size()) {
4444 Arg = Args[ArgIx++];
4446 if (RequireCompleteType(Arg->getLocStart(),
4448 diag::err_call_incomplete_argument, Arg))
4452 bool CFAudited =
false;
4454 FDecl && FDecl->
hasAttr<CFAuditedTransferAttr>() &&
4455 (!Param || !Param->
hasAttr<CFConsumedAttr>()))
4456 Arg = stripARCUnbridgedCast(Arg);
4457 else if (getLangOpts().ObjCAutoRefCount &&
4458 FDecl && FDecl->
hasAttr<CFAuditedTransferAttr>() &&
4459 (!Param || !Param->
hasAttr<CFConsumedAttr>()))
4473 Entity,
SourceLocation(), Arg, IsListInitialization, AllowExplicit);
4479 assert(Param &&
"can't use default arguments without a known callee");
4482 BuildCXXDefaultArgExpr(CallLoc, FDecl, Param);
4492 CheckArrayAccess(Arg);
4495 CheckStaticArrayArgument(CallLoc, Param, Arg);
4497 AllArgs.push_back(Arg);
4501 if (CallType != VariadicDoesNotApply) {
4506 for (
unsigned i = ArgIx, e = Args.size(); i != e; ++i) {
4508 ExprResult arg = checkUnknownAnyArg(CallLoc, Args[i], paramType);
4510 AllArgs.push_back(arg.
get());
4515 for (
unsigned i = ArgIx, e = Args.size(); i != e; ++i) {
4516 ExprResult Arg = DefaultVariadicArgumentPromotion(Args[i], CallType,
4519 AllArgs.push_back(Arg.
get());
4524 for (
unsigned i = ArgIx, e = Args.size(); i != e; ++i)
4525 CheckArrayAccess(Args[i]);
4533 TL = DTL.getOriginalLoc();
4536 << ATL.getLocalSourceRange();
4550 const Expr *ArgExpr) {
4563 Diag(CallLoc, diag::warn_null_arg) << ArgExpr->getSourceRange();
4578 Diag(CallLoc, diag::warn_static_array_too_small)
4579 << ArgExpr->getSourceRange()
4595 if (!placeholder)
return false;
4597 switch (placeholder->
getKind()) {
4599 #define PLACEHOLDER_TYPE(ID, SINGLETON_ID)
4600 #define BUILTIN_TYPE(ID, SINGLETON_ID) case BuiltinType::ID:
4601 #include "clang/AST/BuiltinTypes.def"
4606 case BuiltinType::Overload:
4611 case BuiltinType::ARCUnbridgedCast:
4615 case BuiltinType::PseudoObject:
4620 case BuiltinType::UnknownAny:
4624 case BuiltinType::BoundMember:
4625 case BuiltinType::BuiltinFn:
4628 llvm_unreachable(
"bad builtin type kind");
4636 bool hasInvalid =
false;
4637 for (
size_t i = 0, e = args.size(); i != e; i++) {
4640 if (result.
isInvalid()) hasInvalid =
true;
4641 else args[i] = result.
get();
4642 }
else if (hasInvalid) {
4671 bool NeedsNewDecl =
false;
4680 if (!ParamType->isPointerType() ||
4681 ParamType.getQualifiers().hasAddressSpace() ||
4684 OverloadParams.push_back(ParamType);
4688 NeedsNewDecl =
true;
4701 OverloadParams, EPI);
4712 FT = cast<FunctionProtoType>(OverloadTy);
4713 for (
unsigned i = 0, e = FT->
getNumParams(); i != e; ++i) {
4720 Params.push_back(Parm);
4722 OverloadDecl->setParams(Params);
4723 return OverloadDecl;
4732 Expr *ExecConfig,
bool IsExecConfig) {
4743 if (isa<CXXPseudoDestructorExpr>(Fn)) {
4744 if (!ArgExprs.empty()) {
4746 Diag(Fn->getLocStart(), diag::err_pseudo_dtor_call_with_args)
4749 ArgExprs.back()->getLocEnd()));
4756 ExprResult result = CheckPlaceholderExpr(Fn);
4765 bool Dependent =
false;
4774 Context, Fn, cast<CallExpr>(ExecConfig), ArgExprs,
4784 return BuildCallToObjectOfClassType(S, Fn, LParenLoc, ArgExprs,
4794 return BuildCallToMemberFunction(S, Fn, LParenLoc, ArgExprs, RParenLoc);
4805 if (isa<UnresolvedLookupExpr>(ovl)) {
4807 return BuildOverloadedCallExpr(S, Fn, ULE, LParenLoc, ArgExprs,
4808 RParenLoc, ExecConfig);
4810 return BuildCallToMemberFunction(S, Fn, LParenLoc, ArgExprs,
4830 if (isa<DeclRefExpr>(NakedFn)) {
4831 NDecl = cast<DeclRefExpr>(NakedFn)->getDecl();
4846 }
else if (isa<MemberExpr>(NakedFn))
4847 NDecl = cast<MemberExpr>(NakedFn)->getMemberDecl();
4849 if (
FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(NDecl)) {
4850 if (FD->hasAttr<EnableIfAttr>()) {
4851 if (
const EnableIfAttr *
Attr = CheckEnableIf(FD, ArgExprs,
true)) {
4852 Diag(Fn->getLocStart(),
4853 isa<CXXMethodDecl>(FD) ?
4854 diag::err_ovl_no_viable_member_function_in_call :
4855 diag::err_ovl_no_viable_function_in_call)
4856 << FD << FD->getSourceRange();
4857 Diag(FD->getLocation(),
4858 diag::note_ovl_candidate_disabled_by_enable_if_attr)
4859 <<
Attr->getCond()->getSourceRange() <<
Attr->getMessage();
4864 return BuildResolvedCallExpr(Fn, NDecl, LParenLoc, ArgExprs, RParenLoc,
4865 ExecConfig, IsExecConfig);
4877 QualType DstTy = GetTypeFromParser(ParsedDestTy);
4881 diag::err_invalid_astype_of_different_size)
4884 << E->getSourceRange());
4897 GetTypeFromParser(ParsedDestTy, &TInfo);
4898 return SemaConvertVectorExpr(E, TInfo, BuiltinLoc, RParenLoc);
4912 Expr *Config,
bool IsExecConfig) {
4913 FunctionDecl *FDecl = dyn_cast_or_null<FunctionDecl>(NDecl);
4914 unsigned BuiltinID = (FDecl ? FDecl->
getBuiltinID() : 0);
4925 Result = CallExprUnaryConversions(Fn);
4936 cast<CallExpr>(Config), Args,
4943 if (!getLangOpts().CPlusPlus) {
4948 ExprResult Result = CorrectDelayedTyposInExpr(TheCall);
4951 if (!TheCall)
return Result;
4957 return CheckBuiltinFunctionCall(FDecl, BuiltinID, TheCall);
4966 return ExprError(
Diag(LParenLoc, diag::err_typecheck_call_not_function)
4967 << Fn->
getType() << Fn->getSourceRange());
4981 return ExprError(
Diag(LParenLoc, diag::err_typecheck_call_not_function)
4982 << Fn->
getType() << Fn->getSourceRange());
4985 if (getLangOpts().CUDA) {
4988 if (FDecl && !FDecl->
hasAttr<CUDAGlobalAttr>())
4989 return ExprError(
Diag(LParenLoc,diag::err_kern_call_not_global_function)
4990 << FDecl->
getName() << Fn->getSourceRange());
4994 return ExprError(
Diag(LParenLoc, diag::err_kern_type_not_void_return)
4995 << Fn->
getType() << Fn->getSourceRange());
4998 if (FDecl && FDecl->
hasAttr<CUDAGlobalAttr>())
4999 return ExprError(
Diag(LParenLoc, diag::err_global_call_not_config)
5000 << FDecl->
getName() << Fn->getSourceRange());
5005 if (CheckCallReturnType(FuncT->
getReturnType(), Fn->getLocStart(), TheCall,
5015 if (ConvertArgumentsForCall(TheCall, Fn, FDecl, Proto, Args, RParenLoc,
5019 assert(isa<FunctionNoProtoType>(FuncT) &&
"Unknown FunctionType!");
5028 Diag(RParenLoc, diag::warn_call_wrong_number_of_arguments)
5029 << (Args.size() > Def->
param_size()) << FDecl << Fn->getSourceRange();
5039 for (
unsigned i = 0, e = Args.size(); i != e; i++) {
5040 Expr *Arg = Args[i];
5042 if (Proto && i < Proto->getNumParams()) {
5047 if (ArgE.isInvalid())
5050 Arg = ArgE.getAs<
Expr>();
5053 ExprResult ArgE = DefaultArgumentPromotion(Arg);
5061 if (RequireCompleteType(Arg->getLocStart(),
5063 diag::err_call_incomplete_argument, Arg))
5070 if (
CXXMethodDecl *Method = dyn_cast_or_null<CXXMethodDecl>(FDecl))
5071 if (!Method->isStatic())
5072 return ExprError(
Diag(LParenLoc, diag::err_member_call_without_object)
5073 << Fn->getSourceRange());
5077 DiagnoseSentinelCalls(NDecl, LParenLoc, Args);
5081 if (CheckFunctionCall(FDecl, TheCall, Proto))
5085 return CheckBuiltinFunctionCall(FDecl, BuiltinID, TheCall);
5087 if (CheckPointerCall(NDecl, TheCall, Proto))
5090 if (CheckOtherCall(TheCall, Proto))
5094 return MaybeBindToTemporary(TheCall);
5100 assert(Ty &&
"ActOnCompoundLiteral(): missing type");
5105 QualType literalType = GetTypeFromParser(Ty, &TInfo);
5109 return BuildCompoundLiteralExpr(LParenLoc, TInfo, RParenLoc, InitExpr);
5119 diag::err_illegal_decl_array_incomplete_type,
5121 LiteralExpr->getSourceRange().getEnd())))
5124 return ExprError(
Diag(LParenLoc, diag::err_variable_object_no_init)
5125 <<
SourceRange(LParenLoc, LiteralExpr->getSourceRange().getEnd()));
5127 RequireCompleteType(LParenLoc, literalType,
5128 diag::err_typecheck_decl_incomplete_type,
5129 SourceRange(LParenLoc, LiteralExpr->getSourceRange().getEnd())))
5143 LiteralExpr = Result.
get();
5145 bool isFileScope = getCurFunctionOrMethodDecl() ==
nullptr;
5150 if (CheckForConstantInitializer(LiteralExpr, literalType))
5157 return MaybeBindToTemporary(
5159 VK, LiteralExpr, isFileScope));
5167 for (
unsigned I = 0, E = InitArgList.size(); I != E; ++I) {
5168 if (InitArgList[I]->getType()->isNonOverloadPlaceholderType()) {
5169 ExprResult result = CheckPlaceholderExpr(InitArgList[I]);
5175 InitArgList[I] = result.
get();
5194 if (!getLangOpts().ObjCAutoRefCount)
return;
5199 ExprNeedsCleanups =
true;
5209 maybeExtendBlockObject(E);
5230 llvm_unreachable(
"member pointer type in C");
5239 if (SrcAS != DestAS)
5251 maybeExtendBlockObject(Src);
5261 llvm_unreachable(
"illegal cast from pointer");
5263 llvm_unreachable(
"Should have returned before this");
5282 Src = ImpCastExprToType(Src.
get(),
5287 Src = ImpCastExprToType(Src.
get(),
5292 llvm_unreachable(
"member pointer type in C");
5294 llvm_unreachable(
"Should have returned before this");
5305 Src = ImpCastExprToType(Src.
get(),
5310 Src = ImpCastExprToType(Src.
get(),
5317 llvm_unreachable(
"valid float->pointer cast?");
5319 llvm_unreachable(
"member pointer type in C");
5321 llvm_unreachable(
"Should have returned before this");
5339 Src = ImpCastExprToType(Src.
get(),
5346 llvm_unreachable(
"valid complex float->pointer cast?");
5348 llvm_unreachable(
"member pointer type in C");
5350 llvm_unreachable(
"Should have returned before this");
5368 Src = ImpCastExprToType(Src.
get(),
5375 llvm_unreachable(
"valid complex int->pointer cast?");
5377 llvm_unreachable(
"member pointer type in C");
5379 llvm_unreachable(
"Should have returned before this");
5382 llvm_unreachable(
"Unhandled scalar cast");
5389 len = vecType->getNumElements();
5390 eltType = vecType->getElementType();
5405 uint64_t srcLen, destLen;
5416 return (srcLen * srcEltSize == destLen * destEltSize);
5430 assert(VectorTy->
isVectorType() &&
"Not a vector type!");
5436 diag::err_invalid_conversion_between_vectors :
5437 diag::err_invalid_conversion_between_vector_and_integer)
5438 << VectorTy << Ty << R;
5441 diag::err_invalid_conversion_between_vector_and_scalar)
5442 << VectorTy << Ty << R;
5458 if (SrcTy->isVectorType()) {
5460 || (getLangOpts().OpenCL &&
5462 Diag(R.
getBegin(),diag::err_invalid_conversion_between_ext_vectors)
5463 << DestTy << SrcTy << R;
5473 if (SrcTy->isPointerType())
5475 diag::err_invalid_conversion_between_vector_and_scalar)
5476 << DestTy << SrcTy << R;
5480 CastKind CK = PrepareScalarCast(CastExprRes, DestElemTy);
5483 CastExpr = ImpCastExprToType(CastExprRes.
get(), DestElemTy, CK).
get();
5494 "ActOnCastExpr(): missing type or expr");
5500 if (getLangOpts().CPlusPlus) {
5502 CheckExtraCXXDefaultArguments(D);
5505 ExprResult Res = CorrectDelayedTyposInExpr(CastExpr);
5508 CastExpr = Res.
get();
5514 Ty = CreateParsedType(castType, castTInfo);
5516 bool isVectorLiteral =
false;
5522 if ((getLangOpts().AltiVec || getLangOpts().ZVector || getLangOpts().OpenCL)
5524 if (PLE && PLE->getNumExprs() == 0) {
5525 Diag(PLE->getExprLoc(), diag::err_altivec_empty_initializer);
5528 if (PE || PLE->getNumExprs() == 1) {
5531 isVectorLiteral =
true;
5534 isVectorLiteral =
true;
5539 if (isVectorLiteral)
5540 return BuildVectorLiteral(LParenLoc, RParenLoc, CastExpr, castTInfo);
5545 if (isa<ParenListExpr>(CastExpr)) {
5548 CastExpr = Result.
get();
5552 !getSourceManager().isInSystemMacro(LParenLoc))
5553 Diag(LParenLoc, diag::warn_old_style_cast) << CastExpr->getSourceRange();
5555 CheckTollFreeBridgeCast(castType, CastExpr);
5557 CheckObjCBridgeRelatedCast(castType, CastExpr);
5559 return BuildCStyleCastExpr(LParenLoc, castTInfo, RParenLoc, CastExpr);
5565 assert((isa<ParenListExpr>(E) || isa<ParenExpr>(E)) &&
5566 "Expected paren or paren list expression");
5573 LiteralLParenLoc = PE->getLParenLoc();
5574 LiteralRParenLoc = PE->getRParenLoc();
5575 exprs = PE->getExprs();
5576 numExprs = PE->getNumExprs();
5578 LiteralLParenLoc = cast<ParenExpr>(E)->getLParen();
5579 LiteralRParenLoc = cast<ParenExpr>(E)->getRParen();
5580 subExpr = cast<ParenExpr>(E)->getSubExpr();
5600 if (numExprs == 1) {
5602 ExprResult Literal = DefaultLvalueConversion(exprs[0]);
5605 Literal = ImpCastExprToType(Literal.
get(), ElemTy,
5606 PrepareScalarCast(Literal, ElemTy));
5607 return BuildCStyleCastExpr(LParenLoc, TInfo, RParenLoc, Literal.
get());
5609 else if (numExprs < numElems) {
5611 diag::err_incorrect_number_of_vector_initializers);
5615 initExprs.append(exprs, exprs + numExprs);
5620 if (getLangOpts().OpenCL &&
5624 ExprResult Literal = DefaultLvalueConversion(exprs[0]);
5627 Literal = ImpCastExprToType(Literal.
get(), ElemTy,
5628 PrepareScalarCast(Literal, ElemTy));
5629 return BuildCStyleCastExpr(LParenLoc, TInfo, RParenLoc, Literal.
get());
5632 initExprs.append(exprs, exprs + numExprs);
5637 initExprs, LiteralRParenLoc);
5639 return BuildCompoundLiteralExpr(LParenLoc, TInfo, RParenLoc, initE);
5673 Expr *NullExpr = LHSExpr;
5674 Expr *NonPointerExpr = RHSExpr;
5681 NonPointerExpr = LHSExpr;
5698 if (!findMacroSpelling(loc,
"NULL"))
5703 Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands_null)
5704 << NonPointerExpr->
getType() << DiagType
5705 << NonPointerExpr->getSourceRange();
5715 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_nonfloat)
5716 << CondTy << Cond->getSourceRange();
5723 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_scalar)
5724 << CondTy << Cond->getSourceRange();
5735 S.
Diag(RHSExpr->getLocStart(), diag::ext_typecheck_cond_one_void)
5736 << RHSExpr->getSourceRange();
5738 S.
Diag(LHSExpr->getLocStart(), diag::ext_typecheck_cond_one_void)
5739 << LHSExpr->getSourceRange();
5750 !NullExpr.
get()->isNullPointerConstant(S.
Context,
5774 bool IsBlockPointer =
false;
5778 IsBlockPointer =
true;
5805 if (CompositeTy.
isNull()) {
5806 S.
Diag(Loc, diag::ext_typecheck_cond_incompatible_pointers)
5807 << LHSTy << RHSTy << LHS.
get()->getSourceRange()
5808 << RHS.
get()->getSourceRange();
5845 S.
Diag(Loc, diag::err_typecheck_cond_incompatible_operands)
5846 << LHSTy << RHSTy << LHS.
get()->getSourceRange()
5847 << RHS.
get()->getSourceRange();
5898 bool IsIntFirstExpr) {
5900 !Int.
get()->getType()->isIntegerType())
5903 Expr *Expr1 = IsIntFirstExpr ? Int.
get() : PointerExpr;
5904 Expr *Expr2 = IsIntFirstExpr ? PointerExpr : Int.
get();
5906 S.
Diag(Loc, diag::ext_typecheck_cond_pointer_integer_mismatch)
5908 << Expr1->getSourceRange() << Expr2->getSourceRange();
5944 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_int_float)
5945 << LHSType << LHS.
get()->getSourceRange();
5950 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_int_float)
5951 << RHSType << RHS.
get()->getSourceRange();
5956 if (LHSType == RHSType)
5965 return handleIntegerConversion<doIntegralCast, doIntegralCast>
5966 (
S, LHS, RHS, LHSType, RHSType,
false);
6000 llvm::raw_svector_ostream OS(Str);
6001 OS <<
"(vector of " << NumElements <<
" '" << EleTyName <<
"' values)";
6002 S.
Diag(QuestionLoc, diag::err_conditional_vector_element_size)
6003 << CondTy << OS.str();
6024 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_nonfloat)
6025 << Cond->
getType() << Cond->getSourceRange();
6042 S.
Diag(QuestionLoc, diag::err_conditional_vector_size)
6043 << CondTy << VecResTy;
6048 QualType RVE = RV->getElementType();
6051 S.
Diag(QuestionLoc, diag::err_conditional_vector_element_size)
6052 << CondTy << VecResTy;
6076 if (LHS.
get()->getType()->isVectorType() ||
6077 RHS.
get()->getType()->isVectorType()) {
6111 if (getLangOpts().CPlusPlus)
6112 return CXXCheckConditionalOperands(Cond, LHS, RHS, VK, OK, QuestionLoc);
6123 Cond = UsualUnaryConversions(Cond.
get());
6132 return CheckVectorOperands(LHS, RHS, QuestionLoc,
false,
6136 QualType ResTy = UsualArithmeticConversions(LHS, RHS);
6146 LHS = ImpCastExprToType(LHS.
get(), ResTy, PrepareScalarCast(LHS, ResTy));
6147 RHS = ImpCastExprToType(RHS.get(), ResTy, PrepareScalarCast(RHS, ResTy));
6156 if (LHSRT->getDecl() == RHSRT->getDecl())
6175 QualType compositeType = FindCompositeObjCPointerType(LHS, RHS,
6179 if (!compositeType.
isNull())
6180 return compositeType;
6205 if (DiagnoseConditionalForNull(LHS.
get(), RHS.
get(), QuestionLoc))
6209 Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands)
6210 << LHSTy << RHSTy << LHS.
get()->getSourceRange()
6211 << RHS.
get()->getSourceRange();
6281 if (!(compositeType =
6299 Diag(QuestionLoc, diag::ext_typecheck_cond_incompatible_operands)
6301 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
6304 RHS = ImpCastExprToType(RHS.get(), incompatTy,
CK_BitCast);
6308 LHS = ImpCastExprToType(LHS.
get(), compositeType,
CK_BitCast);
6309 RHS = ImpCastExprToType(RHS.get(), compositeType,
CK_BitCast);
6310 return compositeType;
6314 if (getLangOpts().ObjCAutoRefCount) {
6317 Diag(QuestionLoc, diag::err_cond_voidptr_arc) << LHSTy << RHSTy
6318 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
6328 LHS = ImpCastExprToType(LHS.
get(), destType,
CK_NoOp);
6330 RHS = ImpCastExprToType(RHS.get(), destType,
CK_BitCast);
6334 if (getLangOpts().ObjCAutoRefCount) {
6337 Diag(QuestionLoc, diag::err_cond_voidptr_arc) << LHSTy << RHSTy
6338 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
6348 RHS = ImpCastExprToType(RHS.
get(), destType,
CK_NoOp);
6350 LHS = ImpCastExprToType(LHS.get(), destType,
CK_BitCast);
6364 Self.
Diag(Loc, Note)
6369 Self.
Diag(Loc, Note) << ParenRange;
6391 *Opcode = OP->getOpcode();
6392 *RHSExprs = OP->getRHS();
6399 if (Call->getNumArgs() != 2)
6405 if (OO < OO_Plus || OO > OO_Arrow ||
6406 OO == OO_PlusPlus || OO == OO_MinusMinus)
6412 *RHSExprs = Call->getArg(1);
6435 return OP->getOpcode() ==
UO_LNot;
6462 Self.
Diag(OpLoc, diag::warn_precedence_conditional)
6463 << Condition->getSourceRange()
6467 Self.
PDiag(diag::note_precedence_silence)
6469 SourceRange(Condition->getLocStart(), Condition->getLocEnd()));
6472 Self.
PDiag(diag::note_precedence_conditional_first),
6473 SourceRange(CondRHS->getLocStart(), RHSExpr->getLocEnd()));
6486 ExprResult CondResult = CorrectDelayedTyposInExpr(CondExpr);
6488 CondExpr = CondResult.
get();
6494 Expr *commonExpr =
nullptr;
6496 commonExpr = CondExpr;
6501 ExprResult result = CheckPlaceholderExpr(commonExpr);
6503 commonExpr = result.
get();
6514 ExprResult commonRes = UsualUnaryConversions(commonExpr);
6517 commonExpr = commonRes.
get();
6525 LHSExpr = CondExpr = opaqueValue;
6530 ExprResult Cond = CondExpr, LHS = LHSExpr, RHS = RHSExpr;
6531 QualType result = CheckConditionalOperands(Cond, LHS, RHS,
6532 VK, OK, QuestionLoc);
6540 CheckBoolLikeConversion(Cond.
get(), QuestionLoc);
6545 RHS.get(), result, VK, OK);
6548 commonExpr, opaqueValue, Cond.
get(), LHS.get(), RHS.get(), QuestionLoc,
6559 assert(LHSType.
isCanonical() &&
"LHS not canonicalized!");
6560 assert(RHSType.
isCanonical() &&
"RHS not canonicalized!");
6563 const Type *lhptee, *rhptee;
6565 std::tie(lhptee, lhq) =
6566 cast<PointerType>(LHSType)->getPointeeType().split().asPair();
6567 std::tie(rhptee, rhq) =
6568 cast<PointerType>(RHSType)->getPointeeType().split().asPair();
6594 && (lhptee->isVoidType() || rhptee->isVoidType()))
6609 if (lhptee->isVoidType()) {
6610 if (rhptee->isIncompleteOrObjectType())
6614 assert(rhptee->isFunctionType());
6618 if (rhptee->isVoidType()) {
6619 if (lhptee->isIncompleteOrObjectType())
6623 assert(lhptee->isFunctionType());
6634 if (lhptee->isCharType())
6636 else if (lhptee->hasSignedIntegerRepresentation())
6639 if (rhptee->isCharType())
6641 else if (rhptee->hasSignedIntegerRepresentation())
6644 if (ltrans == rtrans) {
6658 if (isa<PointerType>(lhptee) && isa<PointerType>(rhptee)) {
6660 lhptee = cast<PointerType>(lhptee)->getPointeeType().getTypePtr();
6661 rhptee = cast<PointerType>(rhptee)->getPointeeType().getTypePtr();
6662 }
while (isa<PointerType>(lhptee) && isa<PointerType>(rhptee));
6664 if (lhptee == rhptee)
6684 assert(LHSType.
isCanonical() &&
"LHS not canonicalized!");
6685 assert(RHSType.
isCanonical() &&
"RHS not canonicalized!");
6690 lhptee = cast<BlockPointerType>(LHSType)->getPointeeType();
6691 rhptee = cast<BlockPointerType>(RHSType)->getPointeeType();
6700 if (lhptee.getLocalQualifiers() != rhptee.getLocalQualifiers())
6714 assert(LHSType.
isCanonical() &&
"LHS was not canonicalized!");
6715 assert(RHSType.
isCanonical() &&
"RHS was not canonicalized!");
6756 return CheckAssignmentConstraints(LHSType, RHSPtr, K);
6788 if (LHSType == RHSType) {
6795 if (
const AtomicType *AtomicTy = dyn_cast<AtomicType>(LHSType)) {
6797 CheckAssignmentConstraints(AtomicTy->getValueType(), RHS,
Kind);
6798 if (result != Compatible)
6801 RHS = ImpCastExprToType(RHS.
get(), AtomicTy->getValueType(),
Kind);
6818 return Incompatible;
6825 return Incompatible;
6830 if (elType != RHSType) {
6831 Kind = PrepareScalarCast(RHS, elType);
6832 RHS = ImpCastExprToType(RHS.
get(), elType,
Kind);
6852 if (isLaxVectorConversion(RHSType, LHSType)) {
6854 return IncompatibleVectors;
6857 return Incompatible;
6863 Kind = PrepareScalarCast(RHS, LHSType);
6868 if (
const PointerType *LHSPointer = dyn_cast<PointerType>(LHSType)) {
6870 if (isa<PointerType>(RHSType)) {
6871 unsigned AddrSpaceL = LHSPointer->getPointeeType().getAddressSpace();
6880 return IntToPointer;
6885 if (isa<ObjCObjectPointerType>(RHSType)) {
6887 if (LHSPointer->getPointeeType()->isVoidType()) {
6901 return IncompatiblePointer;
6906 if (LHSPointer->getPointeeType()->isVoidType()) {
6912 return Incompatible;
6916 if (isa<BlockPointerType>(LHSType)) {
6926 return IntToBlockPointer;
6937 if (RHSPT->getPointeeType()->isVoidType()) {
6942 return Incompatible;
6946 if (isa<ObjCObjectPointerType>(LHSType)) {
6952 if (getLangOpts().ObjCAutoRefCount &&
6953 result == Compatible &&
6954 !CheckObjCARCUnavailableWeakConversion(OrigLHSType, RHSType))
6955 result = IncompatibleObjCWeakRef;
6962 return IntToPointer;
6967 if (isa<PointerType>(RHSType)) {
6982 return IncompatiblePointer;
6988 maybeExtendBlockObject(RHS);
6993 return Incompatible;
6997 if (isa<PointerType>(RHSType)) {
7007 return PointerToInt;
7010 return Incompatible;
7014 if (isa<ObjCObjectPointerType>(RHSType)) {
7024 return PointerToInt;
7027 return Incompatible;
7031 if (isa<TagType>(LHSType) && isa<TagType>(RHSType)) {
7038 return Incompatible;
7051 Initializer->
setType(UnionType);
7070 return Incompatible;
7076 for (
auto *it : UD->
fields()) {
7077 if (it->getType()->isPointerType()) {
7090 RHS = ImpCastExprToType(RHS.
get(), it->
getType(),
7098 if (CheckAssignmentConstraints(it->getType(), RHS,
Kind)
7107 return Incompatible;
7116 bool DiagnoseCFAudited) {
7135 return Incompatible;
7140 return Incompatible;
7142 if (getLangOpts().ObjCAutoRefCount &&
7143 !CheckObjCARCUnavailableWeakConversion(LHSType,
7145 result = IncompatibleObjCWeakRef;
7164 CheckPointerConversion(RHS.
get(), LHSType,
Kind, Path,
false);
7165 RHS = ImpCastExprToType(RHS.get(), LHSType,
Kind,
VK_RValue, &Path);
7176 RHS = DefaultFunctionArrayLvalueConversion(RHS.
get());
7178 return Incompatible;
7192 CheckAssignmentConstraints(LHSType, RHS, Kind);
7200 if (result != Incompatible && RHS.
get()->
getType() != LHSType) {
7203 if (getLangOpts().ObjCAutoRefCount)
7204 CheckObjCARCConversion(
SourceRange(), Ty, E, CCK_ImplicitConversion,
7206 if (getLangOpts().ObjC1 &&
7207 (CheckObjCBridgeRelatedConversions(E->getLocStart(),
7209 ConversionToObjCStringLiteralCheck(LHSType, E))) {
7214 RHS = ImpCastExprToType(E, Ty, Kind);
7221 Diag(Loc, diag::err_typecheck_invalid_operands)
7223 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
7277 bool AllowBoolConversions) {
7278 if (!IsCompAssign) {
7279 LHS = DefaultFunctionArrayLvalueConversion(LHS.
get());
7283 RHS = DefaultFunctionArrayLvalueConversion(RHS.
get());
7294 assert(LHSVecType || RHSVecType);
7298 if (!AllowBothBool &&
7301 return InvalidOperands(Loc, LHS, RHS);
7308 if (LHSVecType && RHSVecType &&
7310 if (isa<ExtVectorType>(LHSVecType)) {
7323 if (AllowBoolConversions && LHSVecType && RHSVecType &&
7333 if (!IsCompAssign &&
7336 RHSVecType->getElementType()->isIntegerType()) {
7344 if (!RHSVecType && isa<ExtVectorType>(LHSVecType)) {
7349 if (!LHSVecType && isa<ExtVectorType>(RHSVecType)) {
7351 LHSType, RHSVecType->getElementType(),
7360 if (isLaxVectorConversion(RHSType, LHSType)) {
7369 if ((!RHSVecType && !RHSType->
isRealType()) ||
7371 Diag(Loc, diag::err_typecheck_vector_not_convertable_non_scalar)
7372 << LHSType << RHSType
7373 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
7378 Diag(Loc, diag::err_typecheck_vector_not_convertable)
7379 << LHSType << RHSType
7380 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
7392 bool LHSNull = isa<GNUNullExpr>(LHS.
get()->IgnoreParenImpCasts());
7393 bool RHSNull = isa<GNUNullExpr>(RHS.
get()->IgnoreParenImpCasts());
7395 QualType NonNullType = LHSNull ? RHS.
get()->getType() : LHS.
get()->getType();
7399 if ((!LHSNull && !RHSNull) || NonNullType->isBlockPointerType() ||
7400 NonNullType->isMemberPointerType() || NonNullType->isFunctionType())
7406 S.
Diag(Loc, diag::warn_null_in_arithmetic_operation)
7414 if (LHSNull == RHSNull || NonNullType->isAnyPointerType() ||
7415 NonNullType->canDecayToPointerType())
7418 S.
Diag(Loc, diag::warn_null_in_comparison_operation)
7419 << LHSNull << NonNullType
7420 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
7425 bool IsCompAssign,
bool IsDiv) {
7430 return CheckVectorOperands(LHS, RHS, Loc, IsCompAssign,
7431 getLangOpts().AltiVec,
7434 QualType compType = UsualArithmeticConversions(LHS, RHS, IsCompAssign);
7440 return InvalidOperands(Loc, LHS, RHS);
7443 llvm::APSInt RHSValue;
7446 DiagRuntimeBehavior(Loc, RHS.
get(),
7447 PDiag(diag::warn_division_by_zero)
7448 << RHS.
get()->getSourceRange());
7461 return CheckVectorOperands(LHS, RHS, Loc, IsCompAssign,
7462 getLangOpts().AltiVec,
7464 return InvalidOperands(Loc, LHS, RHS);
7467 QualType compType = UsualArithmeticConversions(LHS, RHS, IsCompAssign);
7472 return InvalidOperands(Loc, LHS, RHS);
7475 llvm::APSInt RHSValue;
7478 DiagRuntimeBehavior(Loc, RHS.
get(),
7479 PDiag(diag::warn_remainder_by_zero)
7480 << RHS.
get()->getSourceRange());
7489 ? diag::err_typecheck_pointer_arith_void_type
7490 : diag::ext_gnu_void_ptr)
7491 << 1 << LHSExpr->getSourceRange()
7492 << RHSExpr->getSourceRange();
7499 ? diag::err_typecheck_pointer_arith_void_type
7500 : diag::ext_gnu_void_ptr)
7501 << 0 << Pointer->getSourceRange();
7510 ? diag::err_typecheck_pointer_arith_function_type
7511 : diag::ext_gnu_ptr_func_arith)
7517 << LHS->getSourceRange() << RHS->getSourceRange();
7525 ? diag::err_typecheck_pointer_arith_function_type
7526 : diag::ext_gnu_ptr_func_arith)
7529 << Pointer->getSourceRange();
7539 ResType = ResAtomicType->getValueType();
7544 diag::err_typecheck_arithmetic_incomplete_type,
7545 PointeeTy, Operand->getSourceRange());
7560 ResType = ResAtomicType->getValueType();
7592 if (!isLHSPointer && !isRHSPointer)
return true;
7594 QualType LHSPointeeTy, RHSPointeeTy;
7599 if (isLHSPointer && isRHSPointer) {
7604 diag::err_typecheck_op_on_nonoverlapping_address_space_pointers)
7606 << LHSExpr->getSourceRange() << RHSExpr->getSourceRange();
7612 bool isLHSVoidPtr = isLHSPointer && LHSPointeeTy->
isVoidType();
7613 bool isRHSVoidPtr = isRHSPointer && RHSPointeeTy->
isVoidType();
7614 if (isLHSVoidPtr || isRHSVoidPtr) {
7622 bool isLHSFuncPtr = isLHSPointer && LHSPointeeTy->
isFunctionType();
7623 bool isRHSFuncPtr = isRHSPointer && RHSPointeeTy->
isFunctionType();
7624 if (isLHSFuncPtr || isRHSFuncPtr) {
7646 Expr* IndexExpr = RHSExpr;
7649 IndexExpr = LHSExpr;
7652 bool IsStringPlusInt = StrExpr &&
7654 if (!IsStringPlusInt || IndexExpr->isValueDependent())
7658 if (IndexExpr->EvaluateAsInt(index, Self.
getASTContext())) {
7659 unsigned StrLenWithNull = StrExpr->
getLength() + 1;
7660 if (index.isNonNegative() &&
7661 index <= llvm::APSInt(llvm::APInt(index.getBitWidth(), StrLenWithNull),
7662 index.isUnsigned()))
7666 SourceRange DiagRange(LHSExpr->getLocStart(), RHSExpr->getLocEnd());
7667 Self.
Diag(OpLoc, diag::warn_string_plus_int)
7668 << DiagRange << IndexExpr->IgnoreImpCasts()->getType();
7671 if (IndexExpr == RHSExpr) {
7673 Self.
Diag(OpLoc, diag::note_string_plus_scalar_silence)
7678 Self.
Diag(OpLoc, diag::note_string_plus_scalar_silence);
7684 const Expr *StringRefExpr = LHSExpr;
7690 StringRefExpr = RHSExpr;
7693 if (!CharExpr || !StringRefExpr)
7707 SourceRange DiagRange(LHSExpr->getLocStart(), RHSExpr->getLocEnd());
7710 if (!CharType->isAnyCharacterType() &&
7711 CharType->isIntegerType() &&
7713 Self.
Diag(OpLoc, diag::warn_string_plus_char)
7714 << DiagRange << Ctx.
CharTy;
7716 Self.
Diag(OpLoc, diag::warn_string_plus_char)
7717 << DiagRange << CharExpr->
getType();
7723 Self.
Diag(OpLoc, diag::note_string_plus_scalar_silence)
7728 Self.
Diag(OpLoc, diag::note_string_plus_scalar_silence);
7737 S.
Diag(Loc, diag::err_typecheck_sub_ptr_compatible)
7738 << LHSExpr->
getType() << RHSExpr->
getType() << LHSExpr->getSourceRange()
7739 << RHSExpr->getSourceRange();
7749 QualType compType = CheckVectorOperands(
7750 LHS, RHS, Loc, CompLHSTy,
7751 getLangOpts().AltiVec,
7752 getLangOpts().ZVector);
7753 if (CompLHSTy) *CompLHSTy = compType;
7757 QualType compType = UsualArithmeticConversions(LHS, RHS, CompLHSTy);
7769 if (CompLHSTy) *CompLHSTy = compType;
7779 isObjCPointer =
false;
7781 isObjCPointer =
true;
7783 std::swap(PExp, IExp);
7785 isObjCPointer =
false;
7787 isObjCPointer =
true;
7789 return InvalidOperands(Loc, LHS, RHS);
7794 if (!IExp->getType()->isIntegerType())
7795 return InvalidOperands(Loc, LHS, RHS);
7804 CheckArrayAccess(PExp, IExp);
7827 QualType compType = CheckVectorOperands(
7828 LHS, RHS, Loc, CompLHSTy,
7829 getLangOpts().AltiVec,
7830 getLangOpts().ZVector);
7831 if (CompLHSTy) *CompLHSTy = compType;
7835 QualType compType = UsualArithmeticConversions(LHS, RHS, CompLHSTy);
7843 if (CompLHSTy) *CompLHSTy = compType;
7862 CheckArrayAccess(LHS.
get(), RHS.
get(),
nullptr,
7865 if (CompLHSTy) *CompLHSTy = LHS.
get()->
getType();
7898 if (ElementSize.
isZero()) {
7899 Diag(Loc,diag::warn_sub_ptr_zero_size_types)
7901 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
7905 if (CompLHSTy) *CompLHSTy = LHS.
get()->
getType();
7910 return InvalidOperands(Loc, LHS, RHS);
7915 return ET->getDecl()->isScoped();
7929 if (RHS.
get()->isValueDependent() ||
7933 if (Right.isNegative()) {
7935 S.
PDiag(diag::warn_shift_negative)
7936 << RHS.
get()->getSourceRange());
7939 llvm::APInt LeftBits(Right.getBitWidth(),
7941 if (Right.uge(LeftBits)) {
7943 S.
PDiag(diag::warn_shift_gt_typewidth)
7944 << RHS.
get()->getSourceRange());
7955 if (LHS.
get()->isValueDependent() ||
7962 if (Left.isNegative()) {
7964 S.
PDiag(diag::warn_shift_lhs_negative)
7965 << LHS.
get()->getSourceRange());
7969 llvm::APInt ResultBits =
7970 static_cast<llvm::APInt&
>(Right) + Left.getMinSignedBits();
7971 if (LeftBits.uge(ResultBits))
7973 llvm::APSInt
Result = Left.extend(ResultBits.getLimitedValue());
7974 Result = Result.shl(Right);
7979 Result.toString(HexResult, 16,
false,
true);
7985 if (LeftBits == ResultBits - 1) {
7986 S.
Diag(Loc, diag::warn_shift_result_sets_sign_bit)
7987 << HexResult << LHSType
7988 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
7992 S.
Diag(Loc, diag::warn_shift_result_gt_typewidth)
7993 << HexResult.str() << Result.getMinSignedBits() << LHSType
7994 << Left.getBitWidth() << LHS.
get()->getSourceRange()
7995 << RHS.
get()->getSourceRange();
8004 if (!LHS.
get()->getType()->isVectorType()) {
8005 S.
Diag(Loc, diag::err_shift_rhs_only_vector)
8006 << RHS.
get()->getType() << LHS.
get()->getType()
8007 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
8011 if (!IsCompAssign) {
8029 if (!LHSEleType->isIntegerType()) {
8030 S.
Diag(Loc, diag::err_typecheck_expect_int)
8031 << LHS.
get()->getType() << LHS.
get()->getSourceRange();
8035 if (!RHSEleType->isIntegerType()) {
8036 S.
Diag(Loc, diag::err_typecheck_expect_int)
8037 << RHS.
get()->getType() << RHS.
get()->getSourceRange();
8046 S.
Diag(Loc, diag::err_typecheck_vector_lengths_not_equal)
8047 << LHS.
get()->getType() << RHS.
get()->getType()
8048 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
8064 bool IsCompAssign) {
8070 if (LangOpts.OpenCL)
8072 if (LangOpts.ZVector) {
8078 return InvalidOperands(Loc, LHS, RHS);
8081 return InvalidOperands(Loc, LHS, RHS);
8084 return CheckVectorOperands(LHS, RHS, Loc, IsCompAssign,
8095 LHS = UsualUnaryConversions(LHS.
get());
8099 if (IsCompAssign) LHS = OldLHS;
8102 RHS = UsualUnaryConversions(RHS.
get());
8110 return InvalidOperands(Loc, LHS, RHS);
8116 return InvalidOperands(Loc, LHS, RHS);
8127 if (isa<ClassTemplateSpecializationDecl>(DC))
8130 return FD->isFunctionTemplateSpecialization();
8157 S.
Diag(Loc, diag::warn_comparison_of_mixed_enum_types)
8158 << LHSStrippedType << RHSStrippedType
8159 << LHS->getSourceRange() << RHS->getSourceRange();
8166 S.
Diag(Loc, IsError ? diag::err_typecheck_comparison_of_distinct_pointers
8167 : diag::ext_typecheck_comparison_of_distinct_pointers)
8168 << LHS.
get()->getType() << RHS.
get()->getType()
8169 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
8201 bool NonStandardCompositeType =
false;
8202 bool *BoolPtr = S.
isSFINAEContext() ?
nullptr : &NonStandardCompositeType;
8209 if (NonStandardCompositeType)
8210 S.
Diag(Loc, diag::ext_typecheck_comparison_of_distinct_pointers_nonstandard)
8211 << LHSType << RHSType << T << LHS.
get()->getSourceRange()
8212 << RHS.
get()->getSourceRange();
8223 S.
Diag(Loc, IsError ? diag::err_typecheck_comparison_of_fptr_to_void
8224 : diag::ext_typecheck_comparison_of_fptr_to_void)
8225 << LHS.
get()->getType() << RHS.
get()->getType()
8226 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
8230 switch (E.
get()->IgnoreParenImpCasts()->getStmtClass()) {
8231 case Stmt::ObjCArrayLiteralClass:
8232 case Stmt::ObjCDictionaryLiteralClass:
8233 case Stmt::ObjCStringLiteralClass:
8234 case Stmt::ObjCBoxedExprClass:
8290 switch (FromE->getStmtClass()) {
8293 case Stmt::ObjCStringLiteralClass:
8296 case Stmt::ObjCArrayLiteralClass:
8299 case Stmt::ObjCDictionaryLiteralClass:
8301 return LK_Dictionary;
8302 case Stmt::BlockExprClass:
8304 case Stmt::ObjCBoxedExprClass: {
8306 switch (Inner->getStmtClass()) {
8307 case Stmt::IntegerLiteralClass:
8308 case Stmt::FloatingLiteralClass:
8309 case Stmt::CharacterLiteralClass:
8310 case Stmt::ObjCBoolLiteralExprClass:
8311 case Stmt::CXXBoolLiteralExprClass:
8314 case Stmt::ImplicitCastExprClass: {
8315 CastKind CK = cast<CastExpr>(Inner)->getCastKind();
8336 Literal = LHS.
get();
8339 Literal = RHS.
get();
8355 llvm_unreachable(
"Unknown Objective-C object literal kind");
8359 S.
Diag(Loc, diag::warn_objc_string_literal_comparison)
8360 << Literal->getSourceRange();
8362 S.
Diag(Loc, diag::warn_objc_literal_comparison)
8363 << LiteralKind << Literal->getSourceRange();
8372 S.
Diag(Loc, diag::note_objc_literal_comparison_isequal)
8382 unsigned OpaqueOpc) {
8391 if (RHS.
get()->getType()->isBooleanType())
return;
8426 return DR->getDecl();
8428 if (Ivar->isFreeIvar())
8429 return Ivar->getDecl();
8431 if (
MemberExpr* Mem = dyn_cast<MemberExpr>(E)) {
8432 if (Mem->isImplicitAccess())
8433 return Mem->getMemberDecl();
8441 bool IsRelational) {
8449 return CheckVectorCompareOperands(LHS, RHS, Loc, IsRelational);
8462 !LHS.
get()->getLocStart().isMacroID() &&
8463 !RHS.
get()->getLocStart().isMacroID() &&
8464 ActiveTemplateInstantiations.empty()) {
8478 DiagRuntimeBehavior(Loc,
nullptr, PDiag(diag::warn_comparison_always)
8487 char always_evals_to;
8490 always_evals_to = 0;
8493 always_evals_to = 1;
8497 always_evals_to = 2;
8500 DiagRuntimeBehavior(Loc,
nullptr, PDiag(diag::warn_comparison_always)
8502 << always_evals_to);
8505 if (isa<CastExpr>(LHSStripped))
8507 if (isa<CastExpr>(RHSStripped))
8512 Expr *literalString =
nullptr;
8513 Expr *literalStringStripped =
nullptr;
8514 if ((isa<StringLiteral>(LHSStripped) || isa<ObjCEncodeExpr>(LHSStripped)) &&
8517 literalString = LHS.
get();
8518 literalStringStripped = LHSStripped;
8519 }
else if ((isa<StringLiteral>(RHSStripped) ||
8520 isa<ObjCEncodeExpr>(RHSStripped)) &&
8523 literalString = RHS.
get();
8524 literalStringStripped = RHSStripped;
8527 if (literalString) {
8528 DiagRuntimeBehavior(Loc,
nullptr,
8529 PDiag(diag::warn_stringcompare)
8530 << isa<ObjCEncodeExpr>(literalStringStripped)
8531 << literalString->getSourceRange());
8536 UsualArithmeticConversions(LHS, RHS);
8552 CheckFloatComparison(Loc, LHS.
get(), RHS.
get());
8565 if (!IsRelational && LHSIsNull != RHSIsNull) {
8566 bool IsEquality = Opc ==
BO_EQ;
8568 DiagnoseAlwaysNonNullPointer(LHS.
get(), RHSNullKind, IsEquality,
8569 RHS.
get()->getSourceRange());
8571 DiagnoseAlwaysNonNullPointer(RHS.
get(), LHSNullKind, IsEquality,
8572 LHS.
get()->getSourceRange());
8584 if (LCanPointeeTy == RCanPointeeTy)
8586 if (!IsRelational &&
8593 && !LHSIsNull && !RHSIsNull) {
8595 *
this, Loc, LHS, RHS, (
bool)isSFINAEContext());
8597 if (isSFINAEContext())
8615 Diag(Loc, diag::ext_typecheck_ordered_comparison_of_function_pointers)
8616 << LHSType << RHSType << LHS.
get()->getSourceRange()
8617 << RHS.
get()->getSourceRange();
8619 }
else if (!IsRelational &&
8623 && !LHSIsNull && !RHSIsNull)
8630 if (LCanPointeeTy != RCanPointeeTy) {
8634 diag::err_typecheck_op_on_nonoverlapping_address_space_pointers)
8635 << LHSType << RHSType << 0
8636 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
8642 if (LHSIsNull && !RHSIsNull)
8643 LHS = ImpCastExprToType(LHS.
get(), RHSType,
Kind);
8645 RHS = ImpCastExprToType(RHS.get(), LHSType,
Kind);
8650 if (getLangOpts().CPlusPlus) {
8661 RHS = ImpCastExprToType(RHS.
get(), LHSType,
8671 LHS = ImpCastExprToType(LHS.
get(), RHSType,
8679 if (!IsRelational &&
8701 if (!LHSIsNull && !RHSIsNull &&
8703 Diag(Loc, diag::err_typecheck_comparison_of_distinct_blocks)
8704 << LHSType << RHSType << LHS.
get()->getSourceRange()
8705 << RHS.
get()->getSourceRange();
8715 if (!LHSIsNull && !RHSIsNull) {
8720 Diag(Loc, diag::err_typecheck_comparison_of_distinct_blocks)
8721 << LHSType << RHSType << LHS.
get()->getSourceRange()
8722 << RHS.
get()->getSourceRange();
8724 if (LHSIsNull && !RHSIsNull)
8725 LHS = ImpCastExprToType(LHS.
get(), RHSType,
8729 RHS = ImpCastExprToType(RHS.get(), LHSType,
8741 bool RPtrToVoid = RPT ? RPT->getPointeeType()->isVoidType() :
false;
8743 if (!LPtrToVoid && !RPtrToVoid &&
8748 if (LHSIsNull && !RHSIsNull) {
8750 if (getLangOpts().ObjCAutoRefCount)
8751 CheckObjCARCConversion(
SourceRange(), RHSType, E, CCK_ImplicitConversion);
8752 LHS = ImpCastExprToType(E, RHSType,
8757 if (getLangOpts().ObjCAutoRefCount)
8758 CheckObjCARCConversion(
SourceRange(), LHSType, E, CCK_ImplicitConversion,
false,
8760 RHS = ImpCastExprToType(E, LHSType,
8773 if (LHSIsNull && !RHSIsNull)
8776 RHS = ImpCastExprToType(RHS.get(), LHSType,
CK_BitCast);
8782 unsigned DiagID = 0;
8783 bool isError =
false;
8784 if (LangOpts.DebuggerSupport) {
8789 if (IsRelational && !getLangOpts().CPlusPlus)
8790 DiagID = diag::ext_typecheck_ordered_comparison_of_pointer_and_zero;
8791 }
else if (IsRelational && !getLangOpts().CPlusPlus)
8792 DiagID = diag::ext_typecheck_ordered_comparison_of_pointer_integer;
8793 else if (getLangOpts().CPlusPlus) {
8794 DiagID = diag::err_typecheck_comparison_of_pointer_integer;
8797 DiagID = diag::ext_typecheck_comparison_of_pointer_integer;
8801 << LHSType << RHSType << LHS.
get()->getSourceRange()
8802 << RHS.
get()->getSourceRange();
8808 LHS = ImpCastExprToType(LHS.
get(), RHSType,
8811 RHS = ImpCastExprToType(RHS.
get(), LHSType,
8817 if (!IsRelational && RHSIsNull
8822 if (!IsRelational && LHSIsNull
8828 return InvalidOperands(Loc, LHS, RHS);
8847 "Unhandled vector element size in vector compare");
8857 bool IsRelational) {
8860 QualType vType = CheckVectorOperands(LHS, RHS, Loc,
false,
8862 getLangOpts().ZVector);
8870 if (getLangOpts().AltiVec &&
8878 ActiveTemplateInstantiations.empty()) {
8883 if (DRL->getDecl() == DRR->getDecl())
8884 DiagRuntimeBehavior(Loc,
nullptr,
8885 PDiag(diag::warn_comparison_always)
8894 CheckFloatComparison(Loc, LHS.
get(), RHS.
get());
8898 return GetSignedVectorType(LHSType);
8905 QualType vType = CheckVectorOperands(LHS, RHS, Loc,
false,
8909 return InvalidOperands(Loc, LHS, RHS);
8910 if (getLangOpts().OpenCL && getLangOpts().OpenCLVersion < 120 &&
8912 return InvalidOperands(Loc, LHS, RHS);
8914 return GetSignedVectorType(LHS.
get()->
getType());
8925 return CheckVectorOperands(LHS, RHS, Loc, IsCompAssign,
8927 getLangOpts().ZVector);
8928 return InvalidOperands(Loc, LHS, RHS);
8932 QualType compType = UsualArithmeticConversions(LHSResult, RHSResult,
8934 if (LHSResult.
isInvalid() || RHSResult.isInvalid())
8936 LHS = LHSResult.
get();
8937 RHS = RHSResult.
get();
8941 return InvalidOperands(Loc, LHS, RHS);
8949 return CheckVectorLogicalOperands(LHS, RHS, Loc);
8958 !Loc.
isMacroID() && ActiveTemplateInstantiations.empty()) {
8967 (Result != 0 && Result != 1)) {
8968 Diag(Loc, diag::warn_logical_instead_of_bitwise)
8969 << RHS.
get()->getSourceRange()
8970 << (Opc ==
BO_LAnd ?
"&&" :
"||");
8972 Diag(Loc, diag::note_logical_instead_of_bitwise_change_operator)
8973 << (Opc ==
BO_LAnd ?
"&" :
"|")
8980 Diag(Loc, diag::note_logical_instead_of_bitwise_remove_constant)
8984 0, getSourceManager(),
8986 RHS.
get()->getLocEnd()));
8997 return InvalidOperands(Loc, LHS, RHS);
9000 LHS = UsualUnaryConversions(LHS.
get());
9004 RHS = UsualUnaryConversions(RHS.
get());
9010 return InvalidOperands(Loc, LHS, RHS);
9021 ExprResult LHSRes = PerformContextuallyConvertToBool(LHS.
get());
9023 return InvalidOperands(Loc, LHS, RHS);
9026 ExprResult RHSRes = PerformContextuallyConvertToBool(RHS.
get());
9028 return InvalidOperands(Loc, LHS, RHS);
9039 if (!ME)
return false;
9043 if (!Base)
return false;
9064 assert(var->
hasLocalStorage() &&
"capture added 'const' to non-local?");
9105 bool DiagnosticEmitted =
false;
9109 bool IsDereference =
false;
9110 bool NextIsDereference =
false;
9114 IsDereference = NextIsDereference;
9115 NextIsDereference =
false;
9118 if (
const MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
9119 NextIsDereference = ME->isArrow();
9120 const ValueDecl *VD = ME->getMemberDecl();
9121 if (
const FieldDecl *Field = dyn_cast<FieldDecl>(VD)) {
9123 if (Field->isMutable()) {
9124 assert(DiagnosticEmitted &&
"Expected diagnostic not emitted.");
9129 if (!DiagnosticEmitted) {
9130 S.
Diag(Loc, diag::err_typecheck_assign_const)
9131 << ExprRange << ConstMember <<
false << Field
9132 << Field->getType();
9133 DiagnosticEmitted =
true;
9136 << ConstMember <<
false << Field << Field->getType()
9137 << Field->getSourceRange();
9141 }
else if (
const VarDecl *VDecl = dyn_cast<VarDecl>(VD)) {
9142 if (VDecl->getType().isConstQualified()) {
9143 if (!DiagnosticEmitted) {
9144 S.
Diag(Loc, diag::err_typecheck_assign_const)
9145 << ExprRange << ConstMember <<
true << VDecl
9146 << VDecl->getType();
9147 DiagnosticEmitted =
true;
9150 << ConstMember <<
true << VDecl << VDecl->getType()
9151 << VDecl->getSourceRange();
9161 if (
const CallExpr *CE = dyn_cast<CallExpr>(E)) {
9165 if (!DiagnosticEmitted) {
9166 S.
Diag(Loc, diag::err_typecheck_assign_const) << ExprRange
9167 << ConstFunction << FD;
9168 DiagnosticEmitted =
true;
9171 diag::note_typecheck_assign_const)
9175 }
else if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
9177 if (
const ValueDecl *VD = DRE->getDecl()) {
9179 if (!DiagnosticEmitted) {
9180 S.
Diag(Loc, diag::err_typecheck_assign_const)
9181 << ExprRange << ConstVariable << VD << VD->getType();
9182 DiagnosticEmitted =
true;
9184 S.
Diag(VD->getLocation(), diag::note_typecheck_assign_const)
9185 << ConstVariable << VD << VD->getType() << VD->getSourceRange();
9188 }
else if (isa<CXXThisExpr>(E)) {
9190 if (
const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(DC)) {
9191 if (MD->isConst()) {
9192 if (!DiagnosticEmitted) {
9193 S.
Diag(Loc, diag::err_typecheck_assign_const) << ExprRange
9194 << ConstMethod << MD;
9195 DiagnosticEmitted =
true;
9197 S.
Diag(MD->getLocation(), diag::note_typecheck_assign_const)
9198 << ConstMethod << MD << MD->getSourceRange();
9204 if (DiagnosticEmitted)
9208 S.
Diag(Loc, diag::err_typecheck_assign_const) << ExprRange << ConstUnknown;
9223 unsigned DiagID = 0;
9224 bool NeedType =
false;
9231 DiagID = diag::err_block_decl_ref_not_modifiable_lvalue;
9233 DiagID = diag::err_lambda_decl_ref_not_modifiable_lvalue;
9241 if (declRef && isa<VarDecl>(declRef->
getDecl())) {
9254 ? diag::err_typecheck_arc_assign_self_class_method
9255 : diag::err_typecheck_arc_assign_self;
9259 DiagID = diag::err_typecheck_arr_assign_enumeration;
9264 S.
Diag(Loc, DiagID) << E->getSourceRange() << Assign;
9285 DiagID = diag::err_typecheck_array_not_modifiable_lvalue;
9289 DiagID = diag::err_typecheck_non_object_not_modifiable_lvalue;
9293 DiagID = diag::err_typecheck_lvalue_casts_not_supported;
9296 llvm_unreachable(
"did not take early return for MLV_Valid");
9300 DiagID = diag::err_typecheck_expression_not_modifiable_lvalue;
9305 diag::err_typecheck_incomplete_type_not_modifiable_lvalue, E);
9307 DiagID = diag::err_typecheck_duplicate_vector_components_not_mlvalue;
9310 llvm_unreachable(
"readonly properties should be processed differently");
9312 DiagID = diag::error_readonly_message_assignment;
9315 DiagID = diag::error_no_subobject_property_setting;
9323 S.
Diag(Loc, DiagID) << E->
getType() << E->getSourceRange() << Assign;
9325 S.
Diag(Loc, DiagID) << E->getSourceRange() << Assign;
9335 if (ML && MR && ML->
getMemberDecl() == MR->getMemberDecl()) {
9336 if (isa<CXXThisExpr>(ML->
getBase()) && isa<CXXThisExpr>(MR->getBase()))
9337 Sema.
Diag(Loc, diag::warn_identity_field_assign) << 0;
9343 if (OL && OR && OL->
getDecl() == OR->getDecl()) {
9346 if (RL && RR && RL->
getDecl() == RR->getDecl())
9347 Sema.
Diag(Loc, diag::warn_identity_field_assign) << 1;
9365 if (CompoundType.
isNull()) {
9371 ConvTy = CheckSingleAssignmentConstraints(LHSTy, RHS);
9375 if (ConvTy == IncompatiblePointer &&
9380 ConvTy = Compatible;
9382 if (ConvTy == Compatible &&
9384 Diag(Loc, diag::err_objc_object_assignment)
9391 RHSCheck = ICE->getSubExpr();
9392 if (
UnaryOperator *UO = dyn_cast<UnaryOperator>(RHSCheck)) {
9393 if ((UO->getOpcode() ==
UO_Plus ||
9395 Loc.
isFileID() && UO->getOperatorLoc().isFileID() &&
9401 UO->getSubExpr()->getLocStart().
isFileID()) {
9402 Diag(Loc, diag::warn_not_compound_assign)
9403 << (UO->getOpcode() ==
UO_Plus ?
"+" :
"-")
9404 <<
SourceRange(UO->getOperatorLoc(), UO->getOperatorLoc());
9408 if (ConvTy == Compatible) {
9416 checkRetainCycles(LHSExpr, RHS.
get());
9425 if (!Diags.isIgnored(diag::warn_arc_repeated_use_of_weak,
9426 RHS.
get()->getLocStart()))
9427 getCurFunction()->markSafeWeakUse(RHS.
get());
9429 }
else if (getLangOpts().ObjCAutoRefCount) {
9430 checkUnsafeExprAssigns(Loc, LHSExpr, RHS.
get());
9435 ConvTy = CheckAssignmentConstraints(Loc, LHSType, RHSType);
9438 if (DiagnoseAssignmentResult(ConvTy, Loc, LHSType, RHSType,
9439 RHS.
get(), AA_Assigning))
9479 if (!RHS.
get()->getType()->isVoidType())
9481 diag::err_incomplete_type);
9484 return RHS.
get()->getType();
9493 bool IsInc,
bool IsPrefix) {
9502 ResType = ResAtomicType->getValueType();
9504 assert(!ResType.isNull() &&
"no type for increment/decrement expression");
9506 if (S.
getLangOpts().CPlusPlus && ResType->isBooleanType()) {
9509 S.
Diag(OpLoc, diag::err_decrement_bool) << Op->getSourceRange();
9513 S.
Diag(OpLoc, diag::warn_increment_bool) << Op->getSourceRange();
9514 }
else if (S.
getLangOpts().CPlusPlus && ResType->isEnumeralType()) {
9516 S.
Diag(OpLoc, diag::err_increment_decrement_enum) << IsInc << ResType;
9518 }
else if (ResType->isRealType()) {
9520 }
else if (ResType->isPointerType()) {
9524 }
else if (ResType->isObjCObjectPointerType()) {
9530 }
else if (ResType->isAnyComplexType()) {
9532 S.
Diag(OpLoc, diag::ext_integer_increment_complex)
9533 << ResType << Op->getSourceRange();
9534 }
else if (ResType->isPlaceholderType()) {
9539 }
else if (S.
getLangOpts().AltiVec && ResType->isVectorType()) {
9541 }
else if (S.
getLangOpts().ZVector && ResType->isVectorType() &&
9542 (ResType->getAs<
VectorType>()->getVectorKind() !=
9545 }
else if(S.
getLangOpts().OpenCL && ResType->isVectorType() &&
9549 S.
Diag(OpLoc, diag::err_typecheck_illegal_increment_decrement)
9550 << ResType << int(IsInc) << Op->getSourceRange();
9566 return ResType.getUnqualifiedType();
9584 switch (E->getStmtClass()) {
9585 case Stmt::DeclRefExprClass:
9586 return cast<DeclRefExpr>(E)->getDecl();
9587 case Stmt::MemberExprClass:
9591 if (cast<MemberExpr>(E)->isArrow())
9595 case Stmt::ArraySubscriptExprClass: {
9598 Expr*
Base = cast<ArraySubscriptExpr>(E)->getBase();
9600 if (ICE->getSubExpr()->getType()->isArrayType())
9605 case Stmt::UnaryOperatorClass: {
9617 case Stmt::ParenExprClass:
9619 case Stmt::ImplicitCastExprClass:
9631 AO_Vector_Element = 1,
9632 AO_Property_Expansion = 2,
9633 AO_Register_Variable = 3,
9642 S.
Diag(Loc, diag::err_typecheck_address_of) << Type << E->getSourceRange();
9654 if (PTy->getKind() == BuiltinType::Overload) {
9656 if (!isa<OverloadExpr>(E)) {
9657 assert(cast<UnaryOperator>(E)->getOpcode() ==
UO_AddrOf);
9658 Diag(OpLoc, diag::err_typecheck_invalid_lvalue_addrof_addrof_function)
9659 << OrigOp.
get()->getSourceRange();
9664 if (isa<UnresolvedMemberExpr>(Ovl))
9665 if (!ResolveSingleFunctionTemplateSpecialization(Ovl)) {
9666 Diag(OpLoc, diag::err_invalid_form_pointer_member_function)
9667 << OrigOp.
get()->getSourceRange();
9674 if (PTy->getKind() == BuiltinType::UnknownAny)
9677 if (PTy->getKind() == BuiltinType::BoundMember) {
9678 Diag(OpLoc, diag::err_invalid_form_pointer_member_function)
9679 << OrigOp.
get()->getSourceRange();
9683 OrigOp = CheckPlaceholderExpr(OrigOp.
get());
9697 Diag(op->
getExprLoc(), diag::err_opencl_taking_function_address);
9701 if (getLangOpts().
C99) {
9707 return uOp->getSubExpr()->getType();
9714 unsigned AddressOfError = AO_No_Error;
9717 bool sfinae = (
bool)isSFINAEContext();
9718 Diag(OpLoc, isSFINAEContext() ? diag::err_typecheck_addrof_temporary
9719 : diag::ext_typecheck_addrof_temporary)
9720 << op->
getType() << op->getSourceRange();
9726 }
else if (isa<ObjCSelectorExpr>(op)) {
9733 if (!isa<DeclRefExpr>(op)) {
9734 Diag(OpLoc, diag::err_invalid_form_pointer_member_function)
9735 << OrigOp.
get()->getSourceRange();
9742 if (OrigOp.
get() != DRE) {
9743 Diag(OpLoc, diag::err_parens_pointer_member_function)
9744 << OrigOp.
get()->getSourceRange();
9748 if (MD->getParent()->getName().empty())
9749 Diag(OpLoc, diag::err_unqualified_pointer_member_function)
9750 << op->getSourceRange();
9753 StringRef Qual = (MD->getParent()->getName() +
"::").toStringRef(Str);
9754 Diag(OpLoc, diag::err_unqualified_pointer_member_function)
9755 << op->getSourceRange()
9761 if (isa<CXXDestructorDecl>(MD))
9762 Diag(OpLoc, diag::err_typecheck_addrof_dtor) << op->getSourceRange();
9767 RequireCompleteType(OpLoc, MPTy, 0);
9774 if (isa<PseudoObjectExpr>(op)) {
9775 AddressOfError = AO_Property_Expansion;
9777 Diag(OpLoc, diag::err_typecheck_invalid_lvalue_addrof)
9778 << op->
getType() << op->getSourceRange();
9784 AddressOfError = AO_Bit_Field;
9787 AddressOfError = AO_Vector_Element;
9791 if (
const VarDecl *vd = dyn_cast<VarDecl>(dcl)) {
9795 !getLangOpts().CPlusPlus) {
9796 AddressOfError = AO_Register_Variable;
9798 }
else if (isa<MSPropertyDecl>(dcl)) {
9799 AddressOfError = AO_Property_Expansion;
9800 }
else if (isa<FunctionTemplateDecl>(dcl)) {
9802 }
else if (isa<FieldDecl>(dcl) || isa<IndirectFieldDecl>(dcl)) {
9806 if (isa<DeclRefExpr>(op) && cast<DeclRefExpr>(op)->getQualifier()) {
9811 diag::err_cannot_form_pointer_to_member_of_reference_type)
9816 while (cast<RecordDecl>(Ctx)->isAnonymousStructOrUnion())
9823 RequireCompleteType(OpLoc, MPTy, 0);
9827 }
else if (!isa<FunctionDecl>(dcl) && !isa<NonTypeTemplateParmDecl>(dcl))
9828 llvm_unreachable(
"Unknown/unexpected decl type");
9831 if (AddressOfError != AO_No_Error) {
9840 Diag(OpLoc, diag::ext_typecheck_addrof_void) << op->getSourceRange();
9860 if (!FD->hasAttr<NonNullAttr>() && !Param->
hasAttr<NonNullAttr>())
9863 if (!FD->ModifiedNonNullParams.count(Param))
9864 FD->ModifiedNonNullParams.insert(Param);
9874 if (ConvResult.isInvalid())
9876 Op = ConvResult.get();
9880 if (isa<CXXReinterpretCastExpr>(Op)) {
9883 Op->getSourceRange());
9899 S.
Diag(OpLoc, diag::err_typecheck_indirection_requires_pointer)
9900 << OpTy << Op->getSourceRange();
9914 S.
Diag(OpLoc, diag::ext_typecheck_indirection_through_void_pointer)
9915 << OpTy << Op->getSourceRange();
9930 default: llvm_unreachable(
"Unknown binop!");
9931 case tok::periodstar: Opc =
BO_PtrMemD;
break;
9932 case tok::arrowstar: Opc =
BO_PtrMemI;
break;
9933 case tok::star: Opc =
BO_Mul;
break;
9934 case tok::slash: Opc =
BO_Div;
break;
9935 case tok::percent: Opc =
BO_Rem;
break;
9936 case tok::plus: Opc =
BO_Add;
break;
9937 case tok::minus: Opc =
BO_Sub;
break;
9938 case tok::lessless: Opc =
BO_Shl;
break;
9939 case tok::greatergreater: Opc =
BO_Shr;
break;
9940 case tok::lessequal: Opc =
BO_LE;
break;
9941 case tok::less: Opc =
BO_LT;
break;
9942 case tok::greaterequal: Opc =
BO_GE;
break;
9943 case tok::greater: Opc =
BO_GT;
break;
9944 case tok::exclaimequal: Opc =
BO_NE;
break;
9945 case tok::equalequal: Opc =
BO_EQ;
break;
9946 case tok::amp: Opc =
BO_And;
break;
9947 case tok::caret: Opc =
BO_Xor;
break;
9948 case tok::pipe: Opc =
BO_Or;
break;
9949 case tok::ampamp: Opc =
BO_LAnd;
break;
9950 case tok::pipepipe: Opc =
BO_LOr;
break;
9951 case tok::equal: Opc =
BO_Assign;
break;
9958 case tok::greatergreaterequal: Opc =
BO_ShrAssign;
break;
9962 case tok::comma: Opc =
BO_Comma;
break;
9971 default: llvm_unreachable(
"Unknown unary op!");
9972 case tok::plusplus: Opc =
UO_PreInc;
break;
9973 case tok::minusminus: Opc =
UO_PreDec;
break;
9975 case tok::star: Opc =
UO_Deref;
break;
9976 case tok::plus: Opc =
UO_Plus;
break;
9977 case tok::minus: Opc =
UO_Minus;
break;
9978 case tok::tilde: Opc =
UO_Not;
break;
9979 case tok::exclaim: Opc =
UO_LNot;
break;
9980 case tok::kw___real: Opc =
UO_Real;
break;
9981 case tok::kw___imag: Opc =
UO_Imag;
break;
10000 if (!LHSDeclRef || !RHSDeclRef ||
10002 RHSDeclRef->getLocation().isMacroID())
10007 cast<ValueDecl>(RHSDeclRef->getDecl()->getCanonicalDecl());
10008 if (LHSDecl != RHSDecl)
10013 if (RefTy->getPointeeType().isVolatileQualified())
10016 S.
Diag(OpLoc, diag::warn_self_assignment)
10018 << LHSExpr->getSourceRange() << RHSExpr->getSourceRange();
10028 const Expr *ObjCPointerExpr =
nullptr, *OtherExpr =
nullptr;
10033 ObjCPointerExpr = LHS;
10037 ObjCPointerExpr = RHS;
10045 if (ObjCPointerExpr && isa<IntegerLiteral>(OtherExpr->IgnoreParenCasts())) {
10046 unsigned Diag = diag::warn_objc_pointer_masking;
10055 if (SelArg0.startswith(
"performSelector"))
10056 Diag = diag::warn_objc_pointer_masking_performSelector;
10059 S.
Diag(OpLoc, Diag)
10060 << ObjCPointerExpr->getSourceRange();
10067 if (
auto *DRE = dyn_cast<DeclRefExpr>(E))
10068 return DRE->getDecl();
10069 if (
auto *ME = dyn_cast<MemberExpr>(E))
10070 return ME->getMemberDecl();
10071 if (
auto *IRE = dyn_cast<ObjCIvarRefExpr>(E))
10072 return IRE->getDecl();
10082 if (getLangOpts().
CPlusPlus11 && isa<InitListExpr>(RHSExpr)) {
10094 ExprResult Init = InitSeq.Perform(*
this, Entity, Kind, RHSExpr);
10097 RHSExpr = Init.
get();
10112 LHS = CorrectDelayedTyposInExpr(LHSExpr);
10113 RHS = CorrectDelayedTyposInExpr(RHSExpr, [Opc, LHS](
Expr *E) {
10120 if (!LHS.
isUsable() || !RHS.isUsable())
10126 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc,
QualType());
10127 if (getLangOpts().CPlusPlus &&
10132 if (!ResultTy.
isNull()) {
10134 DiagnoseSelfMove(LHS.
get(), RHS.get(), OpLoc);
10140 ResultTy = CheckPointerToMemberOperands(LHS, RHS, VK, OpLoc,
10145 ResultTy = CheckMultiplyDivideOperands(LHS, RHS, OpLoc,
false,
10149 ResultTy = CheckRemainderOperands(LHS, RHS, OpLoc);
10152 ResultTy = CheckAdditionOperands(LHS, RHS, OpLoc, Opc);
10155 ResultTy = CheckSubtractionOperands(LHS, RHS, OpLoc);
10159 ResultTy = CheckShiftOperands(LHS, RHS, OpLoc, Opc);
10165 ResultTy = CheckCompareOperands(LHS, RHS, OpLoc, Opc,
true);
10169 ResultTy = CheckCompareOperands(LHS, RHS, OpLoc, Opc,
false);
10175 ResultTy = CheckBitwiseOperands(LHS, RHS, OpLoc);
10179 ResultTy = CheckLogicalOperands(LHS, RHS, OpLoc, Opc);
10183 CompResultTy = CheckMultiplyDivideOperands(LHS, RHS, OpLoc,
true,
10185 CompLHSTy = CompResultTy;
10187 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy);
10190 CompResultTy = CheckRemainderOperands(LHS, RHS, OpLoc,
true);
10191 CompLHSTy = CompResultTy;
10193 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy);
10196 CompResultTy = CheckAdditionOperands(LHS, RHS, OpLoc, Opc, &CompLHSTy);
10198 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy);
10201 CompResultTy = CheckSubtractionOperands(LHS, RHS, OpLoc, &CompLHSTy);
10203 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy);
10207 CompResultTy = CheckShiftOperands(LHS, RHS, OpLoc, Opc,
true);
10208 CompLHSTy = CompResultTy;
10210 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy);
10216 CompResultTy = CheckBitwiseOperands(LHS, RHS, OpLoc,
true);
10217 CompLHSTy = CompResultTy;
10219 ResultTy = CheckAssignmentOperands(LHS.
get(), RHS, OpLoc, CompResultTy);
10223 if (getLangOpts().
CPlusPlus && !RHS.isInvalid()) {
10224 VK = RHS.get()->getValueKind();
10225 OK = RHS.get()->getObjectKind();
10233 CheckArrayAccess(LHS.
get());
10234 CheckArrayAccess(RHS.get());
10237 NamedDecl *ObjectSetClass = LookupSingleName(TUScope,
10240 if (ObjectSetClass && isa<ObjCIsaExpr>(LHS.
get())) {
10241 SourceLocation RHSLocEnd = PP.getLocForEndOfToken(RHS.get()->getLocEnd());
10254 if (CompResultTy.
isNull())
10256 OK, OpLoc, FPFeatures.fp_contract);
10263 LHS.
get(), RHS.get(), Opc, ResultTy, VK, OK, CompLHSTy, CompResultTy,
10264 OpLoc, FPFeatures.fp_contract);
10279 bool isRightComp = RHSBO && RHSBO->isComparisonOp();
10280 if (!isLeftComp && !isRightComp)
10285 bool isLeftBitwise = LHSBO && LHSBO->
isBitwiseOp();
10286 bool isRightBitwise = RHSBO && RHSBO->isBitwiseOp();
10287 if ((isLeftComp || isLeftBitwise) && (isRightComp || isRightBitwise))
10293 StringRef OpStr = isLeftComp ? LHSBO->
getOpcodeStr() : RHSBO->getOpcodeStr();
10296 :
SourceRange(LHSExpr->getLocStart(), RHSBO->getLHS()->getLocEnd());
10298 Self.
Diag(OpLoc, diag::warn_precedence_bitwise_rel)
10301 Self.
PDiag(diag::note_precedence_silence) << OpStr,
10302 (isLeftComp ? LHSExpr : RHSExpr)->getSourceRange());
10304 Self.
PDiag(diag::note_precedence_bitwise_first)
10317 << Bop->getSourceRange() << OpLoc;
10319 Self.
PDiag(diag::note_precedence_silence)
10321 Bop->getSourceRange());
10332 << Bop->getSourceRange() << OpLoc;
10334 Self.
PDiag(diag::note_precedence_silence)
10336 Bop->getSourceRange());
10359 if (Bop->getOpcode() ==
BO_LAnd) {
10366 }
else if (Bop->getOpcode() ==
BO_LOr) {
10367 if (
BinaryOperator *RBop = dyn_cast<BinaryOperator>(Bop->getRHS())) {
10381 if (Bop->getOpcode() ==
BO_LAnd) {
10396 if (Bop->getOpcode() ==
BO_And)
10404 if (Bop->getOpcode() ==
BO_Add || Bop->getOpcode() ==
BO_Sub) {
10405 StringRef Op = Bop->getOpcodeStr();
10406 S.
Diag(Bop->getOperatorLoc(), diag::warn_addition_in_bitshift)
10407 << Bop->getSourceRange() << OpLoc << Shift << Op;
10409 S.
PDiag(diag::note_precedence_silence) << Op,
10410 Bop->getSourceRange());
10426 if (Kind != OO_LessLess && Kind != OO_GreaterGreater)
10429 S.
Diag(OpLoc, diag::warn_overloaded_shift_in_comparison)
10430 << LHSExpr->getSourceRange() << RHSExpr->getSourceRange()
10431 << (Kind == OO_LessLess);
10433 S.
PDiag(diag::note_precedence_silence)
10434 << (Kind == OO_LessLess ?
"<<" :
">>"),
10437 S.
PDiag(diag::note_evaluate_comparison_first),
10439 RHSExpr->getLocEnd()));
10482 assert(LHSExpr &&
"ActOnBinOp(): missing left expression");
10483 assert(RHSExpr &&
"ActOnBinOp(): missing right expression");
10488 return BuildBinOp(S, TokLoc, Opc, LHSExpr, RHSExpr);
10502 if (Sc && OverOp !=
OO_None && OverOp != OO_Equal)
10523 if (pty->getKind() == BuiltinType::PseudoObject &&
10525 return checkPseudoObjectAssignment(S, OpLoc, Opc, LHSExpr, RHSExpr);
10528 if (pty->getKind() == BuiltinType::Overload) {
10534 ExprResult resolvedRHS = CheckPlaceholderExpr(RHSExpr);
10536 RHSExpr = resolvedRHS.
get();
10543 ExprResult LHS = CheckPlaceholderExpr(LHSExpr);
10545 LHSExpr = LHS.
get();
10552 if (Opc ==
BO_Assign && pty->getKind() == BuiltinType::Overload) {
10559 return CreateBuiltinBinOp(OpLoc, Opc, LHSExpr, RHSExpr);
10563 if (pty->getKind() == BuiltinType::Overload &&
10567 ExprResult resolvedRHS = CheckPlaceholderExpr(RHSExpr);
10569 RHSExpr = resolvedRHS.
get();
10586 return CreateBuiltinBinOp(OpLoc, Opc, LHSExpr, RHSExpr);
10609 resultType = CheckAddressOfOperand(Input, OpLoc);
10613 Input = DefaultFunctionArrayLvalueConversion(Input.
get());
10620 Input = UsualUnaryConversions(Input.
get());
10633 else if (getLangOpts().CPlusPlus &&
10638 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
10639 << resultType << Input.
get()->getSourceRange());
10642 Input = UsualUnaryConversions(Input.
get());
10651 Diag(OpLoc, diag::ext_integer_complement_complex)
10652 << resultType << Input.
get()->getSourceRange();
10661 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
10662 << resultType << Input.
get()->getSourceRange());
10666 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
10667 << resultType << Input.
get()->getSourceRange());
10673 Input = DefaultFunctionArrayLvalueConversion(Input.
get());
10691 ScalarTypeToBooleanCastKind(resultType));
10697 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
10698 << resultType << Input.
get()->getSourceRange());
10707 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
10708 << resultType << Input.
get()->getSourceRange());
10711 resultType = GetSignedVectorType(resultType);
10714 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
10715 << resultType << Input.
get()->getSourceRange());
10734 Input = DefaultLvalueConversion(Input.
get());
10751 CheckArrayAccess(Input.
get());
10761 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
10762 if (!DRE->getQualifier())
10769 if (isa<FieldDecl>(VD) || isa<IndirectFieldDecl>(VD))
10772 return Method->isInstance();
10778 if (!ULE->getQualifier())
10782 DEnd = ULE->decls_end();
10785 if (Method->isInstance())
10805 if (pty->getKind() == BuiltinType::PseudoObject &&
10807 return checkPseudoObjectIncDec(S, OpLoc, Opc, Input);
10811 return CreateBuiltinUnaryOp(OpLoc, Opc, Input);
10816 (pty->getKind() == BuiltinType::Overload ||
10817 pty->getKind() == BuiltinType::UnknownAny ||
10818 pty->getKind() == BuiltinType::BoundMember))
10819 return CreateBuiltinUnaryOp(OpLoc, Opc, Input);
10824 Input = Result.
get();
10837 LookupOverloadedOperatorName(OverOp, S, Input->
getType(),
QualType(),
10840 return CreateOverloadedUnaryOp(OpLoc, Opc, Functions, Input);
10843 return CreateBuiltinUnaryOp(OpLoc, Opc, Input);
10869 if (!cleanups)
return nullptr;
10885 PushExpressionEvaluationContext(ExprEvalContexts.back().Context);
10892 DiscardCleanupsInEvaluationContext();
10893 PopExpressionEvaluationContext();
10899 assert(SubStmt && isa<CompoundStmt>(SubStmt) &&
"Invalid action invocation!");
10902 if (hasAnyUnrecoverableErrorsInThisFunction())
10903 DiscardCleanupsInEvaluationContext();
10904 assert(!ExprNeedsCleanups &&
"cleanups within StmtExpr not correctly bound!");
10905 PopExpressionEvaluationContext();
10914 bool StmtExprMayBindToTemp =
false;
10919 while (
LabelStmt *Label = dyn_cast<LabelStmt>(LastStmt)) {
10920 LastLabelStmt = Label;
10921 LastStmt = Label->getSubStmt();
10924 if (
Expr *LastE = dyn_cast<Expr>(LastStmt)) {
10927 ExprResult LastExpr = DefaultFunctionArrayConversion(LastE);
10939 if (
Expr *rebuiltLastStmt
10941 LastExpr = rebuiltLastStmt;
10943 LastExpr = PerformCopyInitialization(
10953 if (LastExpr.
get() !=
nullptr) {
10954 if (!LastLabelStmt)
10958 StmtExprMayBindToTemp =
true;
10967 if (StmtExprMayBindToTemp)
10968 return MaybeBindToTemporary(ResStmtExpr);
10969 return ResStmtExpr;
10975 unsigned NumComponents,
10985 return ExprError(
Diag(BuiltinLoc, diag::err_offsetof_record_type)
10986 << ArgTy << TypeRange);
10991 && RequireCompleteType(BuiltinLoc, ArgTy,
10992 diag::err_offsetof_incomplete_type, TypeRange))
10999 if (NumComponents != 1)
11000 Diag(BuiltinLoc, diag::ext_offsetof_extended_field_designator)
11001 <<
SourceRange(CompPtr[1].LocStart, CompPtr[NumComponents-1].LocEnd);
11003 bool DidWarnAboutNonPOD =
false;
11008 for (
unsigned i = 0; i != NumComponents; ++i) {
11021 ExprResult IdxRval = DefaultLvalueConversion(static_cast<Expr*>(OC.
U.
E));
11031 diag::err_typecheck_subscript_not_integer)
11032 << Idx->getSourceRange());
11035 Comps.push_back(OffsetOfNode(OC.
LocStart, Exprs.size(), OC.
LocEnd));
11036 Exprs.push_back(Idx);
11050 if (RequireCompleteType(OC.
LocStart, CurrentType,
11051 diag::err_offsetof_incomplete_type))
11069 bool IsSafe = LangOpts.CPlusPlus11? CRD->isStandardLayout() : CRD->isPOD();
11071 LangOpts.CPlusPlus11? diag::ext_offsetof_non_standardlayout_type
11072 : diag::ext_offsetof_non_pod_type;
11074 if (!IsSafe && !DidWarnAboutNonPOD &&
11075 DiagRuntimeBehavior(BuiltinLoc,
nullptr,
11079 DidWarnAboutNonPOD =
true;
11084 LookupQualifiedName(R, RD);
11089 MemberDecl = IndirectMemberDecl->getAnonField();
11102 Diag(OC.
LocEnd, diag::err_offsetof_bitfield)
11110 if (IndirectMemberDecl)
11111 Parent = cast<RecordDecl>(IndirectMemberDecl->getDeclContext());
11117 if (Paths.getDetectedVirtual()) {
11118 Diag(OC.
LocEnd, diag::err_offsetof_field_of_virtual_base)
11125 for (CXXBasePath::iterator B = Path.begin(), BEnd = Path.end();
11127 Comps.push_back(OffsetOfNode(B->Base));
11130 if (IndirectMemberDecl) {
11131 for (
auto *FI : IndirectMemberDecl->chain()) {
11132 assert(isa<FieldDecl>(FI));
11133 Comps.push_back(OffsetOfNode(OC.
LocStart,
11134 cast<FieldDecl>(FI), OC.
LocEnd));
11137 Comps.push_back(OffsetOfNode(OC.
LocStart, MemberDecl, OC.
LocEnd));
11143 Comps, Exprs, RParenLoc);
11151 unsigned NumComponents,
11155 QualType ArgTy = GetTypeFromParser(ParsedArgTy, &ArgTInfo);
11162 return BuildBuiltinOffsetOf(BuiltinLoc, ArgTInfo, CompPtr, NumComponents,
11171 assert((CondExpr && LHSExpr && RHSExpr) &&
"Missing type argument(s)");
11176 bool ValueDependent =
false;
11177 bool CondIsTrue =
false;
11180 ValueDependent =
true;
11183 llvm::APSInt condEval(32);
11185 = VerifyIntegerConstantExpression(CondExpr, &condEval,
11186 diag::err_typecheck_choose_expr_requires_constant,
false);
11189 CondExpr = CondICE.
get();
11190 CondIsTrue = condEval.getZExtValue();
11193 Expr *ActiveExpr = CondIsTrue ? LHSExpr : RHSExpr;
11195 resType = ActiveExpr->
getType();
11202 ChooseExpr(BuiltinLoc, CondExpr, LHSExpr, RHSExpr, resType, VK, OK, RPLoc,
11214 if (LangOpts.CPlusPlus) {
11215 Decl *ManglingContextDecl;
11218 ManglingContextDecl)) {
11219 unsigned ManglingNumber = MCtx->getManglingNumber(Block);
11224 PushBlockScope(CurScope, Block);
11225 CurContext->addDecl(Block);
11227 PushDeclContext(CurScope, Block);
11229 CurContext = Block;
11231 getCurBlock()->HasImplicitReturnType =
true;
11235 PushExpressionEvaluationContext(PotentiallyEvaluated);
11241 "block-id should have no identifier!");
11245 TypeSourceInfo *Sig = GetTypeForDeclarator(ParamInfo, CurScope);
11250 if (DiagnoseUnexpandedParameterPack(CaretLoc, Sig, UPPC_Block)) {
11263 "GetTypeForDeclarator made a non-function block signature");
11274 if (ExplicitSignature.getLocalRangeBegin() ==
11275 ExplicitSignature.getLocalRangeEnd()) {
11287 CurBlock->TheDecl->setSignatureAsWritten(Sig);
11288 CurBlock->FunctionType = T;
11293 (isa<FunctionProtoType>(Fn) && cast<FunctionProtoType>(Fn)->isVariadic());
11295 CurBlock->TheDecl->setIsVariadic(isVariadic);
11302 CurBlock->ReturnType = RetTy;
11303 CurBlock->TheDecl->setBlockMissingReturnType(
false);
11304 CurBlock->HasImplicitReturnType =
false;
11309 if (ExplicitSignature) {
11310 for (
unsigned I = 0, E = ExplicitSignature.getNumParams(); I != E; ++I) {
11311 ParmVarDecl *Param = ExplicitSignature.getParam(I);
11315 !getLangOpts().CPlusPlus)
11317 Params.push_back(Param);
11323 for (
const auto &I : Fn->param_types()) {
11326 Params.push_back(Param);
11331 if (!Params.empty()) {
11332 CurBlock->TheDecl->setParams(Params);
11333 CheckParmsForFunctionDef(CurBlock->TheDecl->param_begin(),
11334 CurBlock->TheDecl->param_end(),
11339 ProcessDeclAttributes(CurScope, CurBlock->TheDecl, ParamInfo);
11342 for (
auto AI : CurBlock->TheDecl->params()) {
11343 AI->setOwningFunction(CurBlock->TheDecl);
11346 if (AI->getIdentifier()) {
11347 CheckShadow(CurBlock->TheScope, AI);
11349 PushOnScopeChains(AI, CurBlock->TheScope);
11358 DiscardCleanupsInEvaluationContext();
11359 PopExpressionEvaluationContext();
11363 PopFunctionScopeInfo();
11371 if (!LangOpts.Blocks)
11372 Diag(CaretLoc, diag::err_blocks_disable);
11375 if (hasAnyUnrecoverableErrorsInThisFunction())
11376 DiscardCleanupsInEvaluationContext();
11377 assert(!ExprNeedsCleanups &&
"cleanups within block not correctly bound!");
11378 PopExpressionEvaluationContext();
11380 BlockScopeInfo *BSI = cast<BlockScopeInfo>(FunctionScopes.back());
11383 deduceClosureReturnType(*BSI);
11397 for (
unsigned i = 0, e = BSI->
Captures.size(); i != e; i++) {
11403 Captures.push_back(NewCap);
11413 if (NoReturn && !Ext.getNoReturn()) Ext = Ext.
withNoReturn(
true);
11416 if (isa<FunctionNoProtoType>(FTy)) {
11448 if (getCurFunction()->NeedsScopeChecking() &&
11449 !PP.isCodeCompletionEnabled())
11450 DiagnoseInvalidJumps(cast<CompoundStmt>(Body));
11459 computeNRVO(Body, BSI);
11463 PopFunctionScopeInfo(&WP, Result->
getBlockDecl(), Result);
11470 ExprNeedsCleanups =
true;
11475 const VarDecl *var = CI.getVariable();
11477 getCurFunction()->setHasBranchProtectedScope();
11490 GetTypeFromParser(Ty, &TInfo);
11491 return BuildVAArgExpr(BuiltinLoc, E, TInfo, RPLoc);
11497 Expr *OrigExpr = E;
11511 }
else if (VaListType->
isRecordType() && getLangOpts().CPlusPlus) {
11518 if (Init.isInvalid())
11520 E = Init.getAs<
Expr>();
11532 diag::err_first_argument_to_va_arg_not_of_type_va_list)
11533 << OrigExpr->
getType() << E->getSourceRange());
11538 diag::err_second_parameter_to_va_arg_incomplete,
11544 diag::err_second_parameter_to_va_arg_abstract,
11551 ? diag::warn_second_parameter_to_va_arg_ownership_qualified
11552 : diag::warn_second_parameter_to_va_arg_not_pod)
11569 PDiag(diag::warn_second_parameter_to_va_arg_never_compatible)
11591 llvm_unreachable(
"I don't know size of pointer!");
11618 if (OV->getSourceExpr())
11634 bool *Complained) {
11636 *Complained =
false;
11639 bool CheckInferredResultType =
false;
11641 unsigned DiagKind = 0;
11644 bool MayHaveConvFixit =
false;
11645 bool MayHaveFunctionDiff =
false;
11655 DiagKind = diag::ext_typecheck_convert_pointer_int;
11657 MayHaveConvFixit =
true;
11660 DiagKind = diag::ext_typecheck_convert_int_pointer;
11662 MayHaveConvFixit =
true;
11667 diag::err_arc_typecheck_convert_incompatible_pointer :
11668 diag::ext_typecheck_convert_incompatible_pointer);
11671 if (Hint.
isNull() && !CheckInferredResultType) {
11674 else if (CheckInferredResultType) {
11678 MayHaveConvFixit =
true;
11681 DiagKind = diag::ext_typecheck_convert_incompatible_pointer_sign;
11684 DiagKind = diag::ext_typecheck_convert_pointer_void_func;
11693 DiagKind = diag::err_typecheck_incompatible_address_space;
11698 DiagKind = diag::err_typecheck_incompatible_ownership;
11702 llvm_unreachable(
"unknown error case for discarding qualifiers!");
11718 DiagKind = diag::ext_typecheck_convert_discards_qualifiers;
11721 DiagKind = diag::ext_nested_pointer_qualifier_mismatch;
11724 DiagKind = diag::err_int_to_block_pointer;
11727 DiagKind = diag::err_typecheck_convert_incompatible_block_pointer;
11733 for (
auto *srcProto : srcOPT->
quals()) {
11739 IFace = IFaceT->getDecl();
11744 for (
auto *dstProto : dstOPT->
quals()) {
11750 IFace = IFaceT->getDecl();
11752 DiagKind = diag::warn_incompatible_qualified_id;
11756 DiagKind = diag::warn_incompatible_vectors;
11759 DiagKind = diag::err_arc_weak_unavailable_assign;
11762 DiagKind = diag::err_typecheck_convert_incompatible;
11764 MayHaveConvFixit =
true;
11766 MayHaveFunctionDiff =
true;
11775 FirstType = DstType;
11776 SecondType = SrcType;
11786 FirstType = SrcType;
11787 SecondType = DstType;
11793 FDiag << FirstType << SecondType <<
AA_Passing << SrcExpr->getSourceRange();
11795 FDiag << FirstType << SecondType << Action << SrcExpr->getSourceRange();
11799 if (!ConvHints.
isNull()) {
11800 for (std::vector<FixItHint>::iterator HI = ConvHints.
Hints.begin(),
11801 HE = ConvHints.
Hints.end(); HI != HE; ++HI)
11806 if (MayHaveConvFixit) { FDiag << (
unsigned) (ConvHints.
Kind); }
11808 if (MayHaveFunctionDiff)
11812 if (DiagKind == diag::warn_incompatible_qualified_id &&
11814 Diag(IFace->
getLocation(), diag::not_incomplete_class_and_qualified_id)
11821 if (CheckInferredResultType)
11828 *Complained =
true;
11833 llvm::APSInt *Result) {
11837 S.
Diag(Loc, diag::err_expr_not_ice) << S.
LangOpts.CPlusPlus << SR;
11845 llvm::APSInt *Result,
11852 IDDiagnoser(
unsigned DiagID)
11856 S.
Diag(Loc, DiagID) << SR;
11858 } Diagnoser(DiagID);
11865 S.
Diag(Loc, diag::ext_expr_not_ice) << SR << S.
LangOpts.CPlusPlus;
11883 CXX11ConvertDiagnoser(
bool Silent)
11889 return S.
Diag(Loc, diag::err_ice_not_integral) << T;
11894 return S.
Diag(Loc, diag::err_ice_incomplete_type) << T;
11899 return S.
Diag(Loc, diag::err_ice_explicit_conversion) << T << ConvTy;
11910 return S.
Diag(Loc, diag::err_ice_ambiguous_conversion) << T;
11921 llvm_unreachable(
"conversion functions are permitted");
11923 } ConvertDiagnoser(Diagnoser.
Suppress);
11929 E = Converted.
get();
11949 EvalResult.
Diag = &Notes;
11968 if (Notes.size() == 1 && Notes[0].second.getDiagID() ==
11969 diag::note_invalid_subexpr_in_const_expr) {
11970 DiagLoc = Notes[0].first;
11974 if (!Folded || !AllowFold) {
11977 for (
unsigned I = 0, N = Notes.size(); I != N; ++I)
11978 Diag(Notes[I].first, Notes[I].second);
11984 Diagnoser.
diagnoseFold(*
this, DiagLoc, E->getSourceRange());
11985 for (
unsigned I = 0, N = Notes.size(); I != N; ++I)
11986 Diag(Notes[I].first, Notes[I].second);
11996 class TransformToPE :
public TreeTransform<TransformToPE> {
12000 TransformToPE(
Sema &SemaRef) : BaseTransform(SemaRef) { }
12003 bool AlwaysRebuild() {
return true; }
12010 return BaseTransform::TransformLabelStmt(S);
12021 if (isa<FieldDecl>(E->
getDecl()) &&
12022 !SemaRef.isUnevaluatedContext())
12024 diag::err_invalid_non_static_member_use)
12025 << E->
getDecl() << E->getSourceRange();
12027 return BaseTransform::TransformDeclRefExpr(E);
12035 return BaseTransform::TransformUnaryOperator(E);
12047 "Should only transform unevaluated expressions");
12052 return TransformToPE(*this).TransformExpr(E);
12057 Decl *LambdaContextDecl,
12086 D = diag::err_lambda_unevaluated_operand;
12092 D = diag::err_lambda_in_constant_expression;
12094 for (
const auto *L : Rec.
Lambdas)
12095 Diag(L->getLocStart(), D);
12099 for (
auto *Lambda : Rec.
Lambdas) {
12100 for (
auto *
C : Lambda->capture_inits())
12129 assert(NumTypos == 0 &&
"There are outstanding typos after popping the "
12130 "last ExpressionEvaluationContextRecord");
12174 llvm_unreachable(
"Invalid context");
12181 assert(Func &&
"No function?");
12193 if (Func->
isUsed(
false) ||
12227 Constructor = cast<CXXConstructorDecl>(Constructor->getFirstDecl());
12228 if (Constructor->isDefaulted() && !Constructor->isDeleted()) {
12229 if (Constructor->isDefaultConstructor()) {
12230 if (Constructor->isTrivial() && !Constructor->hasAttr<DLLExportAttr>())
12233 }
else if (Constructor->isCopyConstructor()) {
12235 }
else if (Constructor->isMoveConstructor()) {
12238 }
else if (Constructor->getInheritedConstructor()) {
12242 dyn_cast<CXXDestructorDecl>(Func)) {
12243 Destructor = cast<CXXDestructorDecl>(Destructor->getFirstDecl());
12244 if (Destructor->isDefaulted() && !Destructor->isDeleted()) {
12245 if (Destructor->isTrivial() && !Destructor->hasAttr<DLLExportAttr>())
12249 if (Destructor->isVirtual() &&
getLangOpts().AppleKext)
12251 }
else if (
CXXMethodDecl *MethodDecl = dyn_cast<CXXMethodDecl>(Func)) {
12252 if (MethodDecl->isOverloadedOperator() &&
12253 MethodDecl->getOverloadedOperator() == OO_Equal) {
12254 MethodDecl = cast<CXXMethodDecl>(MethodDecl->getFirstDecl());
12255 if (MethodDecl->isDefaulted() && !MethodDecl->isDeleted()) {
12256 if (MethodDecl->isCopyAssignmentOperator())
12261 }
else if (isa<CXXConversionDecl>(MethodDecl) &&
12262 MethodDecl->getParent()->isLambda()) {
12264 cast<CXXConversionDecl>(MethodDecl->getFirstDecl());
12269 }
else if (MethodDecl->isVirtual() &&
getLangOpts().AppleKext)
12283 if (!OdrUse)
return;
12288 bool AlreadyInstantiated =
false;
12292 if (SpecInfo->getPointOfInstantiation().isInvalid())
12293 SpecInfo->setPointOfInstantiation(Loc);
12294 else if (SpecInfo->getTemplateSpecializationKind()
12296 AlreadyInstantiated =
true;
12297 PointOfInstantiation = SpecInfo->getPointOfInstantiation();
12301 if (MSInfo->getPointOfInstantiation().isInvalid())
12302 MSInfo->setPointOfInstantiation(Loc);
12303 else if (MSInfo->getTemplateSpecializationKind()
12305 AlreadyInstantiated =
true;
12306 PointOfInstantiation = MSInfo->getPointOfInstantiation();
12310 if (!AlreadyInstantiated || Func->
isConstexpr()) {
12315 std::make_pair(Func, PointOfInstantiation));
12323 PointOfInstantiation));
12330 for (
auto i : Func->
redecls()) {
12331 if (!i->isUsed(
false) && i->isImplicitlyInstantiable())
12338 if (mightHaveNonExternalLinkage(Func))
12367 if (isa<ParmVarDecl>(var) &&
12368 isa<TranslationUnitDecl>(VarDC))
12381 if (isa<CXXMethodDecl>(VarDC) &&
12382 cast<CXXRecordDecl>(VarDC->
getParent())->isLambda()) {
12383 S.
Diag(loc, diag::err_reference_to_local_var_in_enclosing_lambda)
12385 }
else if (
FunctionDecl *fn = dyn_cast<FunctionDecl>(VarDC)) {
12386 S.
Diag(loc, diag::err_reference_to_local_var_in_enclosing_function)
12388 }
else if (isa<BlockDecl>(VarDC)) {
12389 S.
Diag(loc, diag::err_reference_to_local_var_in_enclosing_block)
12394 S.
Diag(loc, diag::err_reference_to_local_var_in_enclosing_context)
12407 bool &SubCapturesAreNested,
12413 SubCapturesAreNested =
true;
12423 !(isa<LambdaScopeInfo>(CSI) && cast<LambdaScopeInfo>(CSI)->Mutable))
12434 const bool Diagnose,
Sema &S) {
12449 const bool Diagnose,
Sema &S) {
12451 bool IsBlock = isa<BlockScopeInfo>(CSI);
12452 bool IsLambda = isa<LambdaScopeInfo>(CSI);
12460 S.
Diag(Loc, diag::err_lambda_capture_anonymous_var);
12469 S.
Diag(Loc, diag::err_ref_vm_type);
12478 if (VTTy->getDecl()->hasFlexibleArrayMember()) {
12481 S.
Diag(Loc, diag::err_ref_flexarray_type);
12483 S.
Diag(Loc, diag::err_lambda_capture_flexarray_type)
12491 const bool HasBlocksAttr = Var->
hasAttr<BlocksAttr>();
12494 if (HasBlocksAttr && (IsLambda || isa<CapturedRegionScopeInfo>(CSI))) {
12496 S.
Diag(Loc, diag::err_capture_block_variable)
12510 const bool BuildAndDiagnose,
12515 Expr *CopyExpr =
nullptr;
12516 bool ByRef =
false;
12520 if (BuildAndDiagnose) {
12521 S.
Diag(Loc, diag::err_ref_array_type);
12530 if (BuildAndDiagnose) {
12531 S.
Diag(Loc, diag::err_arc_autoreleasing_capture)
12538 const bool HasBlocksAttr = Var->
hasAttr<BlocksAttr>();
12546 DeclRefType = CaptureType;
12548 if (S.
getLangOpts().CPlusPlus && BuildAndDiagnose) {
12555 if (isa<ParmVarDecl>(Var))
12572 CaptureType,
false),
12579 !cast<CXXConstructExpr>(Result.
get())->getConstructor()
12582 CopyExpr = Result.
get();
12589 if (BuildAndDiagnose)
12590 BSI->
addCapture(Var, HasBlocksAttr, ByRef, Nested, Loc,
12602 const bool BuildAndDiagnose,
12605 const bool RefersToCapturedVariable,
12614 Expr *CopyExpr =
nullptr;
12615 if (BuildAndDiagnose) {
12636 if (BuildAndDiagnose)
12637 RSI->
addCapture(Var,
false, ByRef, RefersToCapturedVariable, Loc,
12649 bool RefersToCapturedVariable) {
12666 const bool BuildAndDiagnose,
12669 const bool RefersToCapturedVariable,
12672 const bool IsTopScope,
12676 bool ByRef =
false;
12710 if (!RefType->getPointeeType()->isFunctionType())
12716 if (BuildAndDiagnose) {
12717 S.
Diag(Loc, diag::err_arc_autoreleasing_capture) << 1;
12725 if (BuildAndDiagnose) {
12728 diag::err_capture_of_incomplete_type,
12733 diag::err_capture_of_abstract_type))
12739 if (BuildAndDiagnose)
12741 RefersToCapturedVariable);
12758 if (BuildAndDiagnose)
12759 LSI->
addCapture(Var,
false, ByRef, RefersToCapturedVariable,
12760 Loc, EllipsisLoc, CaptureType,
nullptr);
12768 QualType &DeclRefType,
const unsigned *
const FunctionScopeIndexToStopAt) {
12776 const unsigned MaxFunctionScopesIndex = FunctionScopeIndexToStopAt
12780 if (FunctionScopeIndexToStopAt) {
12782 while (FSIndex != MaxFunctionScopesIndex) {
12791 if (VarDC == DC)
return true;
12807 CaptureType = Var->
getType();
12809 bool Nested =
false;
12811 unsigned FunctionScopesIndex = MaxFunctionScopesIndex;
12812 unsigned OpenMPLevel = 0;
12825 FunctionScopesIndex = MaxFunctionScopesIndex - 1;
12840 if (
auto *RSI = dyn_cast<CapturedRegionScopeInfo>(CSI)) {
12859 if (BuildAndDiagnose) {
12882 if (
ParmVarDecl *PVD = dyn_cast_or_null<ParmVarDecl>(Var))
12883 QTy = PVD->getOriginalType();
12887 #define TYPE(Class, Base)
12888 #define ABSTRACT_TYPE(Class, Base)
12889 #define NON_CANONICAL_TYPE(Class, Base)
12890 #define DEPENDENT_TYPE(Class, Base) case Type::Class:
12891 #define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base)
12892 #include "clang/AST/TypeNodes.def"
12896 case Type::Builtin:
12897 case Type::Complex:
12899 case Type::ExtVector:
12902 case Type::Elaborated:
12903 case Type::TemplateSpecialization:
12904 case Type::ObjCObject:
12905 case Type::ObjCInterface:
12906 case Type::ObjCObjectPointer:
12907 llvm_unreachable(
"type class is never variably-modified!");
12908 case Type::Adjusted:
12909 QTy = cast<AdjustedType>(Ty)->getOriginalType();
12911 case Type::Decayed:
12912 QTy = cast<DecayedType>(Ty)->getPointeeType();
12914 case Type::Pointer:
12915 QTy = cast<PointerType>(Ty)->getPointeeType();
12917 case Type::BlockPointer:
12918 QTy = cast<BlockPointerType>(Ty)->getPointeeType();
12920 case Type::LValueReference:
12921 case Type::RValueReference:
12922 QTy = cast<ReferenceType>(Ty)->getPointeeType();
12924 case Type::MemberPointer:
12925 QTy = cast<MemberPointerType>(Ty)->getPointeeType();
12927 case Type::ConstantArray:
12928 case Type::IncompleteArray:
12932 case Type::VariableArray: {
12941 if (
auto LSI = dyn_cast<LambdaScopeInfo>(CSI)) {
12942 CapRecord = LSI->Lambda;
12943 }
else if (
auto CRSI = dyn_cast<CapturedRegionScopeInfo>(CSI)) {
12944 CapRecord = CRSI->TheRecordDecl;
12947 auto ExprLoc = Size->getExprLoc();
12951 Context, CapRecord, ExprLoc, ExprLoc,
12952 nullptr, SizeType,
nullptr,
12955 Field->setImplicit(
true);
12957 Field->setCapturedVLAType(VAT);
12967 case Type::FunctionProto:
12968 case Type::FunctionNoProto:
12969 QTy = cast<FunctionType>(Ty)->getReturnType();
12973 case Type::UnaryTransform:
12974 case Type::Attributed:
12975 case Type::SubstTemplateTypeParm:
12976 case Type::PackExpansion:
12980 case Type::Typedef:
12981 QTy = cast<TypedefType>(Ty)->desugar();
12983 case Type::Decltype:
12984 QTy = cast<DecltypeType>(Ty)->desugar();
12987 QTy = cast<AutoType>(Ty)->getDeducedType();
12989 case Type::TypeOfExpr:
12990 QTy = cast<TypeOfExprType>(Ty)->getUnderlyingExpr()->getType();
12993 QTy = cast<AtomicType>(Ty)->getValueType();
13002 if (BuildAndDiagnose) {
13006 Diag(cast<LambdaScopeInfo>(CSI)->Lambda->getLocStart(),
13007 diag::note_lambda_decl);
13023 FunctionScopesIndex--;
13026 }
while (!VarDC->
Equals(DC));
13033 for (
unsigned I = ++FunctionScopesIndex, N = MaxFunctionScopesIndex + 1; I != N;
13039 BuildAndDiagnose, CaptureType,
13040 DeclRefType, Nested, *
this))
13045 BuildAndDiagnose, CaptureType,
13046 DeclRefType, Nested, *
this))
13052 BuildAndDiagnose, CaptureType,
13053 DeclRefType, Nested, Kind, EllipsisLoc,
13054 I == N - 1, *
this))
13068 DeclRefType,
nullptr);
13075 false, CaptureType,
13076 DeclRefType,
nullptr);
13085 false, CaptureType,
13086 DeclRefType,
nullptr))
13089 return DeclRefType;
13103 const VarDecl *DefVD =
nullptr;
13130 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(SansParensExpr))
13131 Var = dyn_cast<
VarDecl>(DRE->getFoundDecl());
13132 else if (
MemberExpr *ME = dyn_cast<MemberExpr>(SansParensExpr))
13133 Var = dyn_cast<VarDecl>(ME->getMemberDecl());
13136 LSI->markVariableExprAsNonODRUsed(SansParensExpr);
13160 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(*i)) {
13161 Var = cast<VarDecl>(DRE->getDecl());
13162 Loc = DRE->getLocation();
13163 }
else if (
MemberExpr *ME = dyn_cast<MemberExpr>(*i)) {
13164 Var = cast<VarDecl>(ME->getMemberDecl());
13165 Loc = ME->getMemberLoc();
13167 llvm_unreachable(
"Unexpected expression");
13180 assert((!E || isa<DeclRefExpr>(E) || isa<MemberExpr>(E)) &&
13181 "Invalid Expr argument to DoMarkVarDeclReferenced");
13185 bool MarkODRUsed =
true;
13199 const bool RefersToEnclosingScope =
13202 if (RefersToEnclosingScope) {
13212 assert(E &&
"Capture variable should be used in an expression.");
13223 MarkODRUsed =
false;
13228 assert(!isa<VarTemplatePartialSpecializationDecl>(Var) &&
13229 "Can't instantiate a partial template specialization.");
13238 if (TryInstantiating && !isa<VarTemplateSpecializationDecl>(Var)) {
13242 L->StaticDataMemberInstantiated(Var);
13246 TryInstantiating =
false;
13252 if (TryInstantiating) {
13254 bool InstantiationDependent =
false;
13255 bool IsNonDependent =
13261 if (IsNonDependent) {
13268 .push_back(std::make_pair(Var, PointOfInstantiation));
13274 if(!MarkODRUsed)
return;
13303 if (
VarDecl *Var = dyn_cast<VarDecl>(D)) {
13320 if (!IsVirtualCall)
13324 if (!MostDerivedClassDecl)
13327 if (!DM || DM->
isPure())
13337 bool OdrUse =
true;
13339 if (Method->isVirtual())
13352 bool OdrUse =
true;
13355 if (Method->isPure())
13369 if (
auto *VD = dyn_cast<VarDecl>(D)) {
13374 if (
auto *FD = dyn_cast<FunctionDecl>(D)) {
13399 bool MarkReferencedDecls::TraverseTemplateArgument(
13403 S.MarkAnyDeclReferenced(Loc, D,
true);
13406 return Inherited::TraverseTemplateArgument(Arg);
13409 bool MarkReferencedDecls::TraverseRecordType(
RecordType *T) {
13411 = dyn_cast<ClassTemplateSpecializationDecl>(T->
getDecl())) {
13413 return TraverseTemplateArguments(Args.
data(), Args.
size());
13420 MarkReferencedDecls Marker(*
this, Loc);
13429 bool SkipLocalVariables;
13434 EvaluatedExprMarker(
Sema &S,
bool SkipLocalVariables)
13435 : Inherited(S.
Context), S(S), SkipLocalVariables(SkipLocalVariables) { }
13439 if (SkipLocalVariables) {
13441 if (VD->hasLocalStorage())
13445 S.MarkDeclRefReferenced(E);
13449 S.MarkMemberReferenced(E);
13450 Inherited::VisitMemberExpr(E);
13464 Inherited::VisitCXXNewExpr(E);
13472 CXXRecordDecl *Record = cast<CXXRecordDecl>(DestroyedRec->getDecl());
13474 S.LookupDestructor(Record));
13477 Inherited::VisitCXXDeleteExpr(E);
13482 Inherited::VisitCXXConstructExpr(E);
13490 Inherited::VisitImplicitCastExpr(E);
13493 S.UpdateMarkingForLValueToRValue(E->
getSubExpr());
13504 bool SkipLocalVariables) {
13505 EvaluatedExprMarker(*
this, SkipLocalVariables).Visit(E);
13563 class CallReturnIncompleteDiagnoser :
public TypeDiagnoser {
13569 : FD(FD), CE(CE) { }
13573 S.
Diag(Loc, diag::err_call_incomplete_return)
13574 << T << CE->getSourceRange();
13578 S.
Diag(Loc, diag::err_call_function_incomplete_return)
13579 << CE->getSourceRange() << FD->
getDeclName() << T;
13583 } Diagnoser(FD, CE);
13596 unsigned diagnostic = diag::warn_condition_is_assignment;
13597 bool IsOrAssign =
false;
13607 = dyn_cast<ObjCMessageExpr>(Op->getRHS()->IgnoreParenCasts())) {
13612 diagnostic = diag::warn_condition_is_idiomatic_assignment;
13616 diagnostic = diag::warn_condition_is_idiomatic_assignment;
13619 Loc = Op->getOperatorLoc();
13621 if (Op->getOperator() != OO_Equal && Op->getOperator() != OO_PipeEqual)
13624 IsOrAssign = Op->getOperator() == OO_PipeEqual;
13625 Loc = Op->getOperatorLoc();
13633 Diag(Loc, diagnostic) << E->getSourceRange();
13637 Diag(Loc, diag::note_condition_assign_silence)
13642 Diag(Loc, diag::note_condition_or_assign_to_comparison)
13645 Diag(Loc, diag::note_condition_assign_to_comparison)
13663 if (opE->getOpcode() ==
BO_EQ &&
13664 opE->getLHS()->IgnoreParenImpCasts()->isModifiableLvalue(
Context)
13668 Diag(Loc, diag::warn_equality_with_extra_parens) << E->getSourceRange();
13669 SourceRange ParenERange = ParenE->getSourceRange();
13670 Diag(Loc, diag::note_equality_comparison_silence)
13673 Diag(Loc, diag::note_equality_comparison_to_assign)
13680 if (
ParenExpr *parenE = dyn_cast<ParenExpr>(E))
13698 Diag(Loc, diag::err_typecheck_statement_requires_scalar)
13699 << T << E->getSourceRange();
13702 CheckBoolLikeConversion(E, Loc);
13719 struct RebuildUnknownAnyFunction
13720 :
StmtVisitor<RebuildUnknownAnyFunction, ExprResult> {
13724 RebuildUnknownAnyFunction(
Sema &S) : S(S) {}
13727 llvm_unreachable(
"unexpected statement!");
13731 S.Diag(E->
getExprLoc(), diag::err_unsupported_unknown_any_call)
13732 << E->getSourceRange();
13738 template <
class T>
ExprResult rebuildSugarExpr(T *E) {
13739 ExprResult SubResult = Visit(E->getSubExpr());
13742 Expr *SubExpr = SubResult.
get();
13743 E->setSubExpr(SubExpr);
13744 E->setType(SubExpr->
getType());
13751 return rebuildSugarExpr(E);
13755 return rebuildSugarExpr(E);
13762 Expr *SubExpr = SubResult.
get();
13771 if (!isa<FunctionDecl>(VD))
return VisitExpr(E);
13776 if (S.getLangOpts().CPlusPlus &&
13777 !(isa<CXXMethodDecl>(VD) &&
13778 cast<CXXMethodDecl>(VD)->isInstance()))
13789 return resolveDecl(E, E->
getDecl());
13807 struct RebuildUnknownAnyExpr
13808 :
StmtVisitor<RebuildUnknownAnyExpr, ExprResult> {
13816 : S(S), DestType(CastType) {}
13819 llvm_unreachable(
"unexpected statement!");
13823 S.Diag(E->
getExprLoc(), diag::err_unsupported_unknown_any_expr)
13824 << E->getSourceRange();
13833 template <
class T>
ExprResult rebuildSugarExpr(T *E) {
13834 ExprResult SubResult = Visit(E->getSubExpr());
13836 Expr *SubExpr = SubResult.
get();
13837 E->setSubExpr(SubExpr);
13838 E->setType(SubExpr->
getType());
13845 return rebuildSugarExpr(E);
13849 return rebuildSugarExpr(E);
13856 << E->getSourceRange();
13880 return resolveDecl(E, E->
getDecl());
13891 FK_FunctionPointer,
13897 if (CalleeType == S.Context.BoundMemberTy) {
13898 assert(isa<CXXMemberCallExpr>(E) || isa<CXXOperatorCallExpr>(E));
13899 Kind = FK_MemberFunction;
13903 Kind = FK_FunctionPointer;
13906 Kind = FK_BlockPointer;
13911 if (DestType->isArrayType() || DestType->isFunctionType()) {
13912 unsigned diagID = diag::err_func_returning_array_function;
13913 if (Kind == FK_BlockPointer)
13914 diagID = diag::err_block_returning_array_function;
13917 << DestType->isFunctionType() << DestType;
13922 E->
setType(DestType.getNonLValueExprType(S.Context));
13950 if (ParamTypes.empty() && Proto->isVariadic()) {
13952 for (
unsigned i = 0, e = E->
getNumArgs(); i != e; ++i) {
13956 ArgType = S.Context.getLValueReferenceType(ArgType);
13958 ArgType = S.Context.getRValueReferenceType(ArgType);
13960 ArgTypes.push_back(ArgType);
13962 ParamTypes = ArgTypes;
13964 DestType = S.Context.getFunctionType(DestType, ParamTypes,
13965 Proto->getExtProtoInfo());
13967 DestType = S.Context.getFunctionNoProtoType(DestType,
13973 case FK_MemberFunction:
13977 case FK_FunctionPointer:
13978 DestType = S.Context.getPointerType(DestType);
13981 case FK_BlockPointer:
13982 DestType = S.Context.getBlockPointerType(DestType);
13987 ExprResult CalleeResult = Visit(CalleeExpr);
13992 return S.MaybeBindToTemporary(E);
13997 if (DestType->isArrayType() || DestType->isFunctionType()) {
13998 S.Diag(E->
getExprLoc(), diag::err_func_returning_array_function)
13999 << DestType->isFunctionType() << DestType;
14005 assert(Method->getReturnType() == S.Context.UnknownAnyTy);
14006 Method->setReturnType(DestType);
14010 E->
setType(DestType.getNonReferenceType());
14013 return S.MaybeBindToTemporary(E);
14025 DestType = DestType->castAs<
PointerType>()->getPointeeType();
14036 assert(isa<BlockPointerType>(E->
getType()));
14041 DestType = S.Context.getLValueReferenceType(DestType);
14049 llvm_unreachable(
"Unhandled cast type!");
14065 return S.ImpCastExprToType(Result.
get(), Type,
14070 S.Diag(E->
getExprLoc(), diag::err_unknown_any_function)
14071 << VD << E->getSourceRange();
14082 if (DRE && Proto && Proto->getParamTypes().empty() && Proto->isVariadic()) {
14085 FD->getDeclContext(),
14086 Loc, Loc, FD->getNameInfo().getName(),
14087 DestType, FD->getTypeSourceInfo(),
14089 FD->hasPrototype(),
14092 if (FD->getQualifier())
14096 for (
const auto &AI : FT->param_types()) {
14098 S.BuildParmVarDeclForTypedef(FD, Loc, AI);
14100 Params.push_back(Param);
14102 NewFD->setParams(Params);
14103 DRE->setDecl(NewFD);
14104 VD = DRE->getDecl();
14109 if (MD->isInstance()) {
14111 Type = S.Context.BoundMemberTy;
14115 if (!S.getLangOpts().CPlusPlus)
14119 }
else if (isa<VarDecl>(VD)) {
14123 S.Diag(E->
getExprLoc(), diag::err_unknown_any_var_function_type)
14124 << VD << E->getSourceRange();
14130 S.Diag(E->
getExprLoc(), diag::err_unsupported_unknown_any_decl)
14131 << VD << E->getSourceRange();
14149 ExprResult result = RebuildUnknownAnyExpr(*
this, CastType).Visit(CastExpr);
14152 CastExpr = result.
get();
14160 return RebuildUnknownAnyExpr(*
this, ToType).Visit(E);
14188 unsigned diagID = diag::err_uncasted_use_of_unknown_any;
14191 if (
CallExpr *call = dyn_cast<CallExpr>(E)) {
14192 E = call->getCallee();
14193 diagID = diag::err_uncasted_call_of_unknown_any;
14201 if (
DeclRefExpr *ref = dyn_cast<DeclRefExpr>(E)) {
14202 loc = ref->getLocation();
14203 d = ref->getDecl();
14204 }
else if (
MemberExpr *mem = dyn_cast<MemberExpr>(E)) {
14205 loc = mem->getMemberLoc();
14206 d = mem->getMemberDecl();
14208 diagID = diag::err_uncasted_call_of_unknown_any;
14209 loc = msg->getSelectorStartLoc();
14210 d = msg->getMethodDecl();
14212 S.
Diag(loc, diag::err_uncasted_send_to_unknown_any_method)
14213 <<
static_cast<unsigned>(msg->isClassMessage()) << msg->getSelector()
14214 << orig->getSourceRange();
14219 << E->getSourceRange();
14223 S.
Diag(loc, diagID) << d << orig->getSourceRange();
14242 if (!placeholderType)
return E;
14244 switch (placeholderType->
getKind()) {
14247 case BuiltinType::Overload: {
14263 case BuiltinType::BoundMember: {
14268 if (isa<CXXPseudoDestructorExpr>(BME)) {
14269 PD =
PDiag(diag::err_dtor_expr_without_call) << 1;
14270 }
else if (
const auto *ME = dyn_cast<MemberExpr>(BME)) {
14271 if (ME->getMemberNameInfo().getName().getNameKind() ==
14273 PD =
PDiag(diag::err_dtor_expr_without_call) << 0;
14281 case BuiltinType::ARCUnbridgedCast: {
14288 case BuiltinType::UnknownAny:
14292 case BuiltinType::PseudoObject:
14295 case BuiltinType::BuiltinFn: {
14299 auto *FD = cast<FunctionDecl>(DRE->getDecl());
14300 if (FD->getBuiltinID() == Builtin::BI__noop) {
14308 Diag(E->getLocStart(), diag::err_builtin_fn_use);
14313 #define BUILTIN_TYPE(Id, SingletonId) \
14314 case BuiltinType::Id:
14315 #define PLACEHOLDER_TYPE(Id, SingletonId)
14316 #include "clang/AST/BuiltinTypes.def"
14320 llvm_unreachable(
"invalid placeholder type!");
14334 assert((Kind == tok::kw___objc_yes || Kind == tok::kw___objc_no) &&
14335 "Unknown Objective-C Boolean value!");
Abstract class used to diagnose incomplete types.
static void diagnoseArithmeticOnFunctionPointer(Sema &S, SourceLocation Loc, Expr *Pointer)
Diagnose invalid arithmetic on a function pointer.
SourceLocation getLocStart() const LLVM_READONLY
unsigned getNumElements() const
LValueClassification ClassifyLValue(ASTContext &Ctx) const
Reasons why an expression might not be an l-value.
A call to an overloaded operator written using operator syntax.
unsigned getAddressSpace() const
getAddressSpace - Return the address space of this type.
ObjCMethodDecl * LookupMethodInQualifiedType(Selector Sel, const ObjCObjectPointerType *OPT, bool IsInstance)
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...
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this function is an instantiation of a member function of a class template specialization, retrieves the member specialization information.
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)
Defines the clang::ASTContext interface.
void MarkDeclarationsReferencedInExpr(Expr *E, bool SkipLocalVariables=false)
Mark any declarations that appear within this expression or any potentially-evaluated subexpressions ...
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
SourceLocation getEnd() const
QualType getCurrentThisType()
Try to retrieve the type of the 'this' pointer.
const Expr * getBase() const
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
static std::string ComputeName(IdentType IT, const Decl *CurrentDecl)
CastKind getCastKind() const
IdKind getKind() const
Determine what kind of name we have.
ExprObjectKind getObjectKind() const
bool RequireNonAbstractType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
void setImplicit(bool I=true)
void MarkVarDeclODRUsed(VarDecl *Var, SourceLocation Loc, Sema &SemaRef, const unsigned *const FunctionScopeIndexToStopAt)
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
The current expression occurs within an unevaluated operand that unconditionally permits abstract ref...
Smart pointer class that efficiently represents Objective-C method names.
bool isNonOverloadPlaceholderType() const
bool isCXX98PODType(ASTContext &Context) const
EvaluatedExprVisitor - This class visits 'Expr *'s.
QualType CheckAdditionOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, unsigned Opc, QualType *CompLHSTy=nullptr)
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)
static QualType checkConditionalPointerCompatibility(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc)
Checks compatibility between two pointers and return the resulting type.
Simple class containing the result of Sema::CorrectTypo.
QualType CheckAssignmentOperands(Expr *LHSExpr, ExprResult &RHS, SourceLocation Loc, QualType CompoundType)
bool containsUnexpandedParameterPack() const
Whether this expression contains an unexpanded parameter pack (for C++11 variadic templates)...
QualType areCommonBaseCompatible(const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT)
bool isThisCapture() const
bool isSpecificBuiltinType(unsigned K) const
isSpecificBuiltinType - 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
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)
bool isMemberPointerType() const
SourceLocation getLocation() const
DeclContext * getFunctionLevelDeclContext()
ExprResult ActOnIntegerConstant(SourceLocation Loc, uint64_t Val)
TheContext getContext() const
static const CastKind CK_Invalid
const FunctionProtoType * ResolveExceptionSpec(SourceLocation Loc, const FunctionProtoType *FPT)
static QualType handleIntToFloatConversion(Sema &S, ExprResult &FloatExpr, ExprResult &IntExpr, QualType FloatTy, QualType IntTy, bool ConvertFloat, bool ConvertInt)
Hande arithmetic conversion from integer to float. Helper function of UsualArithmeticConversions() ...
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)
IdentifierInfo * getIdentifier() const
ExprResult ActOnParenListExpr(SourceLocation L, SourceLocation R, MultiExprArg Val)
static bool checkConditionalNullPointer(Sema &S, ExprResult &NullExpr, QualType PointerTy)
Return false if the NullExpr can be promoted to PointerTy, true otherwise.
QualType getNonLValueExprType(const ASTContext &Context) const
Determine the type of a (typically non-lvalue) expression with the specified result type...
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
const LangOptions & getLangOpts() const
static ExprResult diagnoseUnknownAnyExpr(Sema &S, Expr *E)
void setLookupName(DeclarationName Name)
Sets the name to look up.
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false)
Perform unqualified name lookup starting from a given scope.
SourceLocation TemplateNameLoc
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
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.
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
unsigned getIntWidth(QualType T) const
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
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()
addConst - add the specified type qualifier to this QualType.
ActionResult< Expr * > ExprResult
ExprResult BuildCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param)
The current expression is potentially evaluated at run time, which means that code may be generated t...
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
static void diagnoseObjCLiteralComparison(Sema &S, SourceLocation Loc, ExprResult &LHS, ExprResult &RHS, BinaryOperator::Opcode Opc)
ExprResult BuildPredefinedExpr(SourceLocation Loc, PredefinedExpr::IdentType IT)
static void CheckIdentityFieldAssignment(Expr *LHSExpr, Expr *RHSExpr, SourceLocation Loc, Sema &Sema)
bool hasPlaceholderType() const
Returns whether this expression has a placeholder type.
SourceLocation getTemplateKeywordLoc() const
Gets the location of the template keyword, if present.
bool isRecordType() const
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)
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)
SourceLocation getLocStart() const LLVM_READONLY
ExprResult CheckBooleanCondition(Expr *E, SourceLocation Loc)
bool isPredefinedLibFunction(unsigned ID) const
Determines whether this builtin is a predefined libc/libm function, such as "malloc", where we know the signature a priori.
std::deque< PendingImplicitInstantiation > PendingInstantiations
The queue of implicit template instantiations that are required but have not yet been performed...
param_iterator param_end()
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.
static NonConstCaptureKind isReferenceToNonConstCapture(Sema &S, Expr *E)
unsigned getBuiltinID() const
Return a value indicating whether this is a builtin function.
Defines the C++ template declaration subclasses.
bool isVoidPointerType() const
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)
Decl * getPreviousDecl()
Retrieve the previous declaration that declares the same entity as this declaration, or NULL if there is no previous declaration.
bool CheckVecStepExpr(Expr *E)
std::string getAsString() const
ExprResult forceUnknownAnyToType(Expr *E, QualType ToType)
Force an expression with unknown-type to an expression of the given type.
ExprResult CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc, Expr *Idx, SourceLocation RLoc)
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type...
CanQualType ARCUnbridgedCastTy
ExprResult ActOnVAArg(SourceLocation BuiltinLoc, Expr *E, ParsedType Ty, SourceLocation RPLoc)
IdentifierInfo * getAsIdentifierInfo() const
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 CheckSubtractionOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, QualType *CompLHSTy=nullptr)
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...
Represents a call to a C++ constructor.
static TypoCorrection TryTypoCorrectionForCall(Sema &S, Expr *Fn, FunctionDecl *FDecl, ArrayRef< Expr * > Args)
static ExprValueKind getValueKindForType(QualType T)
static bool convertPointersToCompositeType(Sema &S, SourceLocation Loc, ExprResult &LHS, ExprResult &RHS)
Returns false if the pointers are converted to a composite type, true otherwise.
bool isBooleanType() const
TemplateNameKind Kind
The kind of template that Template refers to.
bool compatiblyIncludes(Qualifiers other) const
Determines if these qualifiers compatibly include another set. Generally this answers the question of...
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. Helper function of UsualArithmeticConversions() ...
SourceLocation getOperatorLoc() const
SourceLocation getLocStart() const LLVM_READONLY
bool isBlockPointerType() const
static StringLiteral * Create(const ASTContext &C, StringRef Str, StringKind Kind, bool Pascal, QualType Ty, const SourceLocation *Loc, unsigned NumStrs)
static bool IsWithinTemplateSpecialization(Decl *D)
QualType CheckVectorLogicalOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc)
static bool CheckForModifiableLvalue(Expr *E, SourceLocation Loc, Sema &S)
Wrapper for source info for pointers decayed from arrays and functions.
bool isCForbiddenLValueType() const
Determine whether expressions of the given type are forbidden from being lvalues in C...
Abstract base class used for diagnosing integer constant expression violations.
[ARC] Consumes a retainable object pointer that has just been produced, e.g. as the return value of a...
Represents a path from a specific derived class (which is not represented as part of the path) to a p...
static bool checkVectorResult(Sema &S, QualType CondTy, QualType VecResTy, SourceLocation QuestionLoc)
Return false if the vector condition type and the vector result type are compatible.
Represents a C++ constructor within a class.
bool HasSideEffects(const ASTContext &Ctx, bool IncludePossibleEffects=true) const
Represents a prvalue temporary that is written into memory so that a reference can bind to it...
bool hasUnsignedIntegerRepresentation() const
Determine whether this type has an unsigned integer representation of some sort, e.g., it is an unsigned integer type or a vector.
const llvm::APInt & getSize() const
ExprResult ActOnGNUNullExpr(SourceLocation TokenLoc)
static InitializedEntity InitializeTemporary(QualType Type)
Create the initialization entity for a temporary.
static void DiagnoseBadShiftValues(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, unsigned Opc, QualType LHSType)
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...
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
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)
static void diagnoseLogicalNotOnLHSofComparison(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, unsigned OpaqueOpc)
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...
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.
Information about one declarator, including the parsed type information and the identifier.
void removeObjCLifetime()
static void diagnoseFunctionPointerToVoidComparison(Sema &S, SourceLocation Loc, ExprResult &LHS, ExprResult &RHS, bool IsError)
void setCXXLiteralOperatorNameLoc(SourceLocation Loc)
const Expr * getCallee() const
ObjCLifetime getObjCLifetime() const
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...
ExtProtoInfo - Extra information about a function prototype.
QualType getUsageType(QualType objectType) const
static void EmitDiagnosticForBitwiseAndInBitwiseOr(Sema &Self, SourceLocation OpLoc, BinaryOperator *Bop)
It accepts a '&' expr that is inside a '|' one. Emit a diagnostic together with a fixit hint that wra...
std::string getDeletedOrUnavailableSuffix(const FunctionDecl *FD)
Retrieve the message suffix that should be added to a diagnostic complaining about the given function...
bool isUnresolvableResult() const
static FunctionDecl * rewriteBuiltinFunctionDecl(Sema *Sema, ASTContext &Context, const FunctionDecl *FDecl, MultiExprArg ArgExprs)
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...
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. Helper function of UsualArithmeticConversions() ...
void ActOnStartStmtExpr()
static InitializedEntity InitializeResult(SourceLocation ReturnLoc, QualType Type, bool NRVO)
Create the initialization entity for the result of a function.
SourceLocation getOperatorLoc() const
Returns the location of the operator symbol in the expression.
static InitializationKind CreateDirectList(SourceLocation InitLoc)
const BuiltinType * getAsPlaceholderType() const
void DefineImplicitLambdaToFunctionPointerConversion(SourceLocation CurrentLoc, CXXConversionDecl *Conv)
Define the "body" of the conversion from a lambda object to a function pointer.
ExprResult BuildUnaryOp(Scope *S, SourceLocation OpLoc, UnaryOperatorKind Opc, Expr *Input)
bool tryCaptureVariable(VarDecl *Var, SourceLocation Loc, TryCaptureKind Kind, SourceLocation EllipsisLoc, bool BuildAndDiagnose, QualType &CaptureType, QualType &DeclRefType, const unsigned *const FunctionScopeIndexToStopAt)
Try to capture the given variable.
unsigned getValue() const
static void DiagnoseConstAssignment(Sema &S, const Expr *E, SourceLocation Loc)
std::vector< FixItHint > Hints
The list of Hints generated so far.
AssignConvertType CheckSingleAssignmentConstraints(QualType LHSType, ExprResult &RHS, bool Diagnose=true, bool DiagnoseCFAudited=false)
ParmVarDecl - Represents a parameter to a function.
NullPointerConstantKind isNullPointerConstant(ASTContext &Ctx, NullPointerConstantValueDependence NPC) const
Defines the clang::Expr interface and subclasses for C++ expressions.
SourceLocation getLocation() const
bool isEmpty() const
No scope specifier.
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier (with source-location information) that qualifies the name of this...
QualType getFunctionNoProtoType(QualType ResultTy, const FunctionType::ExtInfo &Info) const
Return a K&R style C function type like 'int()'.
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
static void diagnosePointerIncompatibility(Sema &S, SourceLocation Loc, Expr *LHSExpr, Expr *RHSExpr)
Emit error when two pointers are incompatible.
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. Note that this does not always yield a canonical...
EvaluatedStmt * ensureEvaluatedStmt() const
ExprResult ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, MultiExprArg ArgExprs, SourceLocation RParenLoc, Expr *ExecConfig=nullptr, bool IsExecConfig=false)
void DefineImplicitMoveConstructor(SourceLocation CurrentLocation, CXXConstructorDecl *Constructor)
QualType getArrayDecayedType(QualType T) const
Return the properly qualified result of decaying the specified array type to a pointer.
static bool VectorTypesMatch(Sema &S, QualType srcTy, QualType destTy)
void MarkDeclarationsReferencedInType(SourceLocation Loc, QualType T)
void setCorrectionDecl(NamedDecl *CDecl)
Clears the list of NamedDecls before adding the new one.
Base wrapper for a particular "section" of type source info.
Expr * IgnoreImpCasts() LLVM_READONLY
void MarkAnyDeclReferenced(SourceLocation Loc, Decl *D, bool OdrUse)
Perform marking for a reference to an arbitrary declaration. It marks the declaration referenced...
static Sema::AssignConvertType checkObjCPointerTypesForAssignment(Sema &S, QualType LHSType, QualType RHSType)
unsigned getNumParams() const
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)
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). The function body might be in any of the (re-)d...
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)
ExprResult ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc, tok::TokenKind Kind, Expr *Input)
DeclarationName getName() const
getName - Returns the embedded declaration name.
FunctionType::ExtInfo ExtInfo
CanQualType getIntMaxType() const
Return the unique type for "intmax_t" (C99 7.18.1.5), defined in <stdint.h>.
Represents a class template specialization, which refers to a class template with a given set of temp...
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. Helper function of UsualArithmeticConversions() ...
bool isScalarType() const
bool hasPtrArgsOrResult(unsigned ID) const
Determines whether this builtin has a result or any arguments which are pointer types.
void DiagnoseUnusedExprResult(const Stmt *S)
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)
static bool captureInCapturedRegion(CapturedRegionScopeInfo *RSI, VarDecl *Var, SourceLocation Loc, const bool BuildAndDiagnose, QualType &CaptureType, QualType &DeclRefType, const bool RefersToCapturedVariable, Sema &S)
Capture the given variable in the captured region.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
A C++ nested-name-specifier augmented with source location information.
static bool checkArithmeticOpPointerOperand(Sema &S, SourceLocation Loc, Expr *Operand)
Check the validity of an arithmetic pointer operand.
Converts between different integral complex types. _Complex char -> _Complex long long _Complex unsig...
ArrayRef< QualType > getParamTypes() const
SourceLocation getPointOfInstantiation() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
ObjCMethodFamily
A family of Objective-C methods.
QualType getAddrSpaceQualType(QualType T, unsigned AddressSpace) const
Return the uniqued reference to the type for an address space qualified type with the specified type ...
static Sema::AssignConvertType checkPointerTypesForAssignment(Sema &S, QualType LHSType, QualType RHSType)
bool isReferenceType() const
TypeSourceInfo * getTypeSourceInfo(ASTContext &Context, QualType T)
Creates a TypeSourceInfo for the given type.
QualType getReturnType() const
QualType getExtVectorType(QualType VectorType, unsigned NumElts) const
Return the unique reference to an extended vector type of the specified element type and size...
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
bool isAnyPointerType() const
void diagnoseARCUnbridgedCast(Expr *e)
void setBOOLDecl(TypedefDecl *TD)
Save declaration of 'BOOL' typedef.
void setNumArgs(const ASTContext &C, unsigned NumArgs)
bool isOverloaded() const
UnaryExprOrTypeTrait
Names for the "expression or type" traits.
static void checkUnusedDeclAttributes(Sema &S, const AttributeList *A)
ExprResult CreateOverloadedBinOp(SourceLocation OpLoc, unsigned Opc, const UnresolvedSetImpl &Fns, Expr *LHS, Expr *RHS)
Create a binary operation that may resolve to an overloaded operator.
SourceLocation getLocEnd() const LLVM_READONLY
void setCaptures(ASTContext &Context, const Capture *begin, const Capture *end, bool capturesCXXThis)
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.
[ARC] Causes a value of block type to be copied to the heap, if it is not already there...
static DeclRefExpr * Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *D, bool RefersToEnclosingVariableOrCapture, SourceLocation NameLoc, QualType T, ExprValueKind VK, NamedDecl *FoundD=nullptr, const TemplateArgumentListInfo *TemplateArgs=nullptr)
static void addAsFieldToClosureType(Sema &S, LambdaScopeInfo *LSI, VarDecl *Var, QualType FieldType, QualType DeclRefType, SourceLocation Loc, bool RefersToCapturedVariable)
Create a field within the lambda class for the variable being captured.
const RecordType * getAsUnionType() const
NOTE: getAs*ArrayType are methods on ASTContext.
static void diagnoseArithmeticOnTwoVoidPointers(Sema &S, SourceLocation Loc, Expr *LHSExpr, Expr *RHSExpr)
Diagnose invalid arithmetic on two void pointers.
void setKind(tok::TokenKind K)
VarDecl * getVariable() const
SourceLocation getLocStart() const LLVM_READONLY
ExprResult ActOnObjCBoolLiteral(SourceLocation OpLoc, tok::TokenKind Kind)
ActOnObjCBoolLiteral - Parse {__objc_yes,__objc_no} literals.
bool ConversionToObjCStringLiteralCheck(QualType DstType, Expr *&SrcExpr)
bool isOpenMPPrivateVar(VarDecl *VD, unsigned Level)
QualType CheckConditionalOperands(ExprResult &Cond, ExprResult &LHS, ExprResult &RHS, ExprValueKind &VK, ExprObjectKind &OK, SourceLocation QuestionLoc)
bool isForRedeclaration() const
True if this lookup is just looking for an existing declaration.
bool isParamConsumed(unsigned I) const
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)
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
SourceRange getExprRange(Expr *E) const
No entity found met the criteria within the current instantiation,, but there were dependent base cla...
void NoteDeletedFunction(FunctionDecl *FD)
Emit a note explaining that this function is deleted.
static OffsetOfExpr * Create(const ASTContext &C, QualType type, SourceLocation OperatorLoc, TypeSourceInfo *tsi, ArrayRef< OffsetOfNode > comps, ArrayRef< Expr * > exprs, SourceLocation RParenLoc)
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
static InitializedEntity InitializeBlock(SourceLocation BlockVarLoc, QualType Type, bool NRVO)
Provides information about a function template specialization, which is a FunctionDecl that has been ...
Converts a floating point complex to bool by comparing against 0+0i.
ExprResult ActOnBooleanCondition(Scope *S, SourceLocation Loc, Expr *SubExpr)
static bool checkCondition(Sema &S, Expr *Cond, SourceLocation QuestionLoc)
Return false if the condition expression is valid, true otherwise.
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)
static bool IsTypeModifiable(QualType Ty, bool IsDereference)
uint32_t getCodeUnit(size_t i) const
QualType getCallResultType(ASTContext &Context) const
Determine the type of an expression that calls a function of this type.
ExprResult ActOnBlockStmtExpr(SourceLocation CaretLoc, Stmt *Body, Scope *CurScope)
ExprResult ActOnGenericSelectionExpr(SourceLocation KeyLoc, SourceLocation DefaultLoc, SourceLocation RParenLoc, Expr *ControllingExpr, ArrayRef< ParsedType > ArgTypes, ArrayRef< Expr * > ArgExprs)
static bool CheckVecStepTraitOperandType(Sema &S, QualType T, SourceLocation Loc, SourceRange ArgRange)
Represents a C++ unqualified-id that has been parsed.
static void MarkExprReferenced(Sema &SemaRef, SourceLocation Loc, Decl *D, Expr *E, bool OdrUse)
param_type_range param_types() const
The current expression is potentially evaluated, but any declarations referenced inside that expressi...
SmallVectorImpl< PartialDiagnosticAt > * Diag
void setNameLoc(SourceLocation Loc)
Represents the results of name lookup.
static QualType OpenCLArithmeticConversions(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation QuestionLoc)
Simple conversion between integer and floating point types.
ExprResult CallExprUnaryConversions(Expr *E)
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)
static bool isVariableCapturable(CapturingScopeInfo *CSI, VarDecl *Var, SourceLocation Loc, const bool Diagnose, Sema &S)
const LangOptions & getLangOpts() const
void ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope)
ActOnBlockStart - This callback is invoked when a block literal is started.
ObjCMethodDecl * getCurMethodDecl()
bool HasFormOfMemberPointer
unsigned getLength() const
APValue Val
Val - This is the value the expression can be folded to.
Qualifiers withoutObjCGCAttr() const
bool ValidateCandidate(const TypoCorrection &candidate) override
Simple predicate used by the default RankCandidate to determine whether to return an edit distance of...
ObjCMethodFamily getMethodFamily() const
Determines the family of this method.
Keeps track of the mangled names of lambda expressions and block literals within a particular context...
QualType getReturnType() const
AssignConvertType CheckAssignmentConstraints(SourceLocation Loc, QualType LHSType, QualType RHSType)
unsigned getMinRequiredArguments() const
const CXXRecordDecl * getParent() const
void DefineInheritingConstructor(SourceLocation UseLoc, CXXConstructorDecl *Constructor)
Define the specified inheriting constructor.
field_range fields() const
bool isObjCLifetimeType() const
static void DiagnoseSelfAssignment(Sema &S, Expr *LHSExpr, Expr *RHSExpr, SourceLocation OpLoc)
const ArrayType * getAsArrayType(QualType T) const
static Expr * recoverFromMSUnqualifiedLookup(Sema &S, ASTContext &Context, DeclarationNameInfo &NameInfo, SourceLocation TemplateKWLoc, const TemplateArgumentListInfo *TemplateArgs)
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
RecordDecl * getDecl() const
LiteralOperatorLookupResult LookupLiteralOperator(Scope *S, LookupResult &R, ArrayRef< QualType > ArgTys, bool AllowRaw, bool AllowTemplate, bool AllowStringTemplate)
ParsedTemplateArgument * getTemplateArgs()
Retrieves a pointer to the template arguments.
bool isUnsignedIntegerType() const
bool isOverloadedOperator() const
ExprResult ActOnUnaryExprOrTypeTraitExpr(SourceLocation OpLoc, UnaryExprOrTypeTrait ExprKind, bool IsType, void *TyOrEx, const SourceRange &ArgRange)
Expr * IgnoreParenCasts() LLVM_READONLY
QualType getCapturedDeclRefType(VarDecl *Var, SourceLocation Loc)
Given a variable, determine the type that a reference to that variable will have in the given scope...
DeclContext * getLambdaAwareParentOfDeclContext(DeclContext *DC)
QualType getTypeAsWritten() const
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.
bool CanUseDecl(NamedDecl *D)
Determine whether the use of this declaration is valid, without emitting diagnostics.
Represents a C++ nested-name-specifier or a global scope specifier.
TypeClass getTypeClass() const
static QualType CheckIndirectionOperand(Sema &S, Expr *Op, ExprValueKind &VK, SourceLocation OpLoc)
CheckIndirectionOperand - Type check unary indirection (prefix '*').
Represents an Objective-C protocol declaration.
QualType getDestroyedType() const
Retrieve the type being destroyed.
bool isIncompleteType(NamedDecl **Def=nullptr) const
Def If non-NULL, and the type refers to some kind of declaration that can be completed (such as a C s...
Represents binding an expression to a temporary.
DeclContext * getLexicalDeclContext()
tok::TokenKind getKind() const
CXXTemporary * getTemporary()
std::string getAsString() const
getNameAsString - Retrieve the human-readable string for this name.
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 ActOnNumericConstant(const Token &Tok, Scope *UDLScope=nullptr)
An ordinary object is located at an address in memory.
bool isLambdaCallOperator(const CXXMethodDecl *MD)
Represents a C++ member access expression where the actual member referenced could not be resolved be...
static void DiagnoseLogicalAndInLogicalOrRHS(Sema &S, SourceLocation OpLoc, Expr *LHSExpr, Expr *RHSExpr)
Look for '&&' in the right hand of a '||' expr.
A class that does preorder depth-first traversal on the entire Clang AST and visits each node...
Represents an ObjC class declaration.
SmallVector< LambdaExpr *, 2 > Lambdas
The lambdas that are present within this context, if it is indeed an unevaluated context.
bool isExtVectorType() const
void addDecl(NamedDecl *D)
Add a declaration to these results with its natural access. Does not test the acceptance criteria...
static SourceLocation AdvanceToTokenCharacter(SourceLocation TokStart, unsigned Character, const SourceManager &SM, const LangOptions &LangOpts)
CastKind PrepareScalarCast(ExprResult &src, QualType destType)
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). Note that this should not be used directly for normal expressions referring to VarDecl.
CanQualType UnsignedCharTy
A default argument (C++ [dcl.fct.default]).
void setStmt(LabelStmt *T)
static FunctionDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation NLoc, DeclarationName N, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool isInlineSpecified=false, bool hasWrittenPrototype=true, bool isConstexprSpecified=false)
const LangOptions & LangOpts
CXXMethodDecl * getCorrespondingMethodInClass(const CXXRecordDecl *RD, bool MayBeBase=false)
Find the method in RD that corresponds to this one.
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
bool IsStringLiteralToNonConstPointerConversion(Expr *From, QualType ToType)
static void CheckForNullPointerDereference(Sema &S, Expr *E)
NestedNameSpecifier * getQualifier() const
If the name was qualified, retrieves the nested-name-specifier that precedes the name. Otherwise, returns NULL.
TypeSpecTypeLoc pushTypeSpec(QualType T)
bool isUnevaluatedContext() const
Determines whether we are currently in a context that is not evaluated as per C++ [expr] p5...
bool isDefined(const FunctionDecl *&Definition) const
Represents the this expression in C++.
void ActOnStmtExprError()
TyLocType push(QualType T)
unsigned NumCleanupObjects
The number of active cleanup objects when we entered this expression evaluation context.
bool hasPrototype() const
Whether this function has a prototype, either because one was explicitly written or because it was "i...
static ObjCPropertyDecl * findPropertyDecl(const DeclContext *DC, const IdentifierInfo *propertyID)
Lookup a property by name in the specified DeclContext.
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
AvailabilityResult
Captures the result of checking the availability of a declaration.
ImplicitCaptureStyle ImpCaptureStyle
EnumDecl * getDecl() const
bool isBlockCapture() const
CXXSpecialMember
Kinds of C++ special members.
FunctionDecl * getOperatorDelete() const
AvailabilityResult getAvailability(std::string *Message=nullptr) const
Determine the availability of the given declaration.
ExtInfo getExtInfo() const
IdentifierInfo * IdentInfo
Sema - This implements semantic analysis and AST building for C.
static void DiagnoseBinOpPrecedence(Sema &Self, BinaryOperatorKind Opc, SourceLocation OpLoc, Expr *LHSExpr, Expr *RHSExpr)
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)
bool Mutable
Whether this is a mutable lambda.
const DeclarationNameInfo & getLookupNameInfo() const
Gets the name info to look up.
void checkVariadicArgument(const Expr *E, VariadicCallType CT)
QualType getParamType(unsigned i) const
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
SourceLocation getLocStart() const LLVM_READONLY
static NamedDecl * getDeclFromExpr(Expr *E)
ExprResult CreateBuiltinBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr)
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
getObjCLifetime - Returns lifetime attribute of this type.
void DefineImplicitCopyAssignment(SourceLocation CurrentLocation, CXXMethodDecl *MethodDecl)
Defines an implicitly-declared copy assignment operator.
bool EvaluateAsRValue(EvalResult &Result, const ASTContext &Ctx) const
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 getLogicalOperationType() const
The result type of logical operations, '<', '>', '!=', etc.
static StringRef getOpcodeStr(Opcode Op)
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.
VAArgExpr, used for the builtin function __builtin_va_arg.
static CXXDefaultArgExpr * Create(const ASTContext &C, SourceLocation Loc, ParmVarDecl *Param)
FunctionDecl * getOperatorDelete() const
ID
Defines the set of possible language-specific address spaces.
static QualType handleIntegerConversion(Sema &S, ExprResult &LHS, ExprResult &RHS, QualType LHSType, QualType RHSType, bool IsCompAssign)
Handle integer arithmetic conversions. Helper function of UsualArithmeticConversions() ...
QualType getPointeeType() const
bool isUnarySelector() const
SourceLocation getOpLoc() const
bool isCXXClassMember() const
Determine whether this declaration is a C++ class member.
Converts between different floating point complex types. _Complex float -> _Complex double...
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.
bool isRealFloatingType() const
Floating point categories.
ExprResult ActOnCompoundLiteral(SourceLocation LParenLoc, ParsedType Ty, SourceLocation RParenLoc, Expr *InitExpr)
const ObjCMethodDecl * getMethodDecl() const
void DiagnoseAssignmentAsCondition(Expr *E)
ExprResult ActOnBinOp(Scope *S, SourceLocation TokLoc, tok::TokenKind Kind, Expr *LHSExpr, Expr *RHSExpr)
LabelDecl * getDecl() const
unsigned getNumExprs() const
Retains information about a block that is currently being parsed.
DeclContext * getLexicalParent()
bool isDeleted() const
Whether this function has been deleted.
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
const Type * getTypeForDecl() const
unsigned param_size() const
ExprResult BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, SourceLocation LParenLoc, ArrayRef< Expr * > Arg, SourceLocation RParenLoc, Expr *Config=nullptr, bool IsExecConfig=false)
bool DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R, std::unique_ptr< CorrectionCandidateCallback > CCC, TemplateArgumentListInfo *ExplicitTemplateArgs=nullptr, ArrayRef< Expr * > Args=None, TypoExpr **Out=nullptr)
bool isOrdinaryOrBitFieldObject() const
DeclarationName getLookupName() const
Gets the name to look up.
static SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset, const SourceManager &SM, const LangOptions &LangOpts)
Computes the source location just past the end of the token at this source location.
void DefineImplicitCopyConstructor(SourceLocation CurrentLocation, CXXConstructorDecl *Constructor)
const Expr * getExpr(unsigned Init) const
Converts an integral complex to an integral real of the source's element type by discarding the imagi...
Represents a character-granular source range.
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
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. the class which was looked into to find these result...
Expr * stripARCUnbridgedCast(Expr *e)
static DeclContext * getParentOfCapturingContextOrNull(DeclContext *DC, VarDecl *Var, SourceLocation Loc, const bool Diagnose, Sema &S)
bool isAnyComplexType() const
bool isObjCClassType() const
static bool EvaluatesAsTrue(Sema &S, Expr *E)
Returns true if the given expression can be evaluated as a constant 'true'.
static FindResult find(Expr *E)
Finds the overloaded expression in the given expression E of OverloadTy.
NestedNameSpecifier * getCorrectionSpecifier() const
Gets the NestedNameSpecifier needed to use the typo correction.
SourceLocation getNameLoc() const
This file defines the classes used to store parsed information about declaration-specifiers and decla...
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 Expr * maybeRebuildARCConsumingStmt(Stmt *Statement)
Represents a C++ destructor within a class.
SourceRange getSourceRange() const
TranslationUnitDecl * getTranslationUnitDecl() const
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup. Asserts that one was found.
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)
ArgKind getKind() const
Return the kind of stored template argument.
const ParmVarDecl * getParamDecl(unsigned i) const
ExtProtoInfo getExtProtoInfo() const
bool isImplicitlyInstantiable() const
Determines whether this function is a function template specialization or a member of a class templat...
Defines the classes clang::DelayedDiagnostic and clang::AccessedEntity.
static void emitEmptyLookupTypoDiagnostic(const TypoCorrection &TC, Sema &SemaRef, const CXXScopeSpec &SS, DeclarationName Typo, SourceLocation TypoLoc, ArrayRef< Expr * > Args, unsigned DiagnosticID, unsigned DiagnosticSuggestID)
static void DiagnoseShiftCompare(Sema &S, SourceLocation OpLoc, Expr *LHSExpr, Expr *RHSExpr)
DeclContext * getDeclContext()
Overload resolution succeeded.
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given unary opcode. ...
bool isFloatingType() const
static ExprResult BuildOverloadedBinOp(Sema &S, Scope *Sc, SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHS, Expr *RHS)
Build an overloaded binary operator expression in the given scope.
bool DiagnoseAssignmentResult(AssignConvertType ConvTy, SourceLocation Loc, QualType DstType, QualType SrcType, Expr *SrcExpr, AssignmentAction Action, bool *Complained=nullptr)
static ValueDecl * getCompareDecl(Expr *E)
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
ImplicitParamDecl * getSelfDecl() const
ExprResult CheckPlaceholderExpr(Expr *E)
static FloatingLiteral * Create(const ASTContext &C, const llvm::APFloat &V, bool isexact, QualType Type, SourceLocation L)
Represents a C++ template name within the type system.
static DependentScopeDeclRefExpr * Create(const ASTContext &C, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs)
isModifiableLvalueResult isModifiableLvalue(ASTContext &Ctx, SourceLocation *Loc=nullptr) const
bool RequireCompleteType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
llvm::DenseMap< NamedDecl *, SourceLocation > UndefinedButUsed
Defines the clang::TypeLoc interface and its subclasses.
bool isObjCIdType() const
bool hasCustomTypechecking(unsigned ID) const
Determines whether this builtin has custom typechecking.
unsigned getIntMaxTWidth() const
Return the size of intmax_t and uintmax_t for this target, in bits.
bool isInlined() const
Determine whether this function should be inlined, because it is either marked "inline" or "constexpr...
void DiscardCleanupsInEvaluationContext()
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file. ...
Specifies that a value-dependent expression of integral or dependent type should be considered a null...
ASTMutationListener * getASTMutationListener() const
QualType getType() const
Get the type for which this source info wrapper provides information.
Expr * getUninstantiatedDefaultArg()
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)
const SourceRange & getRange() const
void DefineImplicitMoveAssignment(SourceLocation CurrentLocation, CXXMethodDecl *MethodDecl)
Defines an implicitly-declared move assignment operator.
SmallVector< sema::FunctionScopeInfo *, 4 > FunctionScopes
Stack containing information about each of the nested function, block, and method scopes that are cur...
bool isDependentType() const
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 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
QualType getCXXNameType() const
QualType getObjCIdType() const
Represents the Objective-CC id type.
const TemplateArgument * data() const
Retrieve a pointer to the template argument list.
An expression that sends a message to the given Objective-C object or class.
Data structure that captures multiple levels of template argument lists for use in template instantia...
bool isExternallyVisible() const
Converts from an integral complex to a floating complex. _Complex unsigned -> _Complex float...
static UnaryOperatorKind ConvertTokenKindToUnaryOpcode(tok::TokenKind Kind)
SmallVector< ActiveTemplateInstantiation, 16 > ActiveTemplateInstantiations
List of active template instantiations.
ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc, Expr *CondExpr, Expr *LHSExpr, Expr *RHSExpr, SourceLocation RPLoc)
DeclarationName getDeclName() const
void CleanupVarDeclMarking()
QualType CheckVectorCompareOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool isRelational)
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. Entities in anonymous namespaces are external (in c++9...
QualType getElementType() const
Represents a C++ conversion function within a class.
bool isComplexIntegerType() const
The result type of a method or function.
NamedDecl * LookupSingleName(Scope *S, DeclarationName Name, SourceLocation Loc, LookupNameKind NameKind, RedeclarationKind Redecl=NotForRedeclaration)
Look up a name, looking for a single declaration. Return null if the results were absent...
ExprResult DefaultFunctionArrayLvalueConversion(Expr *E)
bool ParentNeedsCleanups
Whether the enclosing context needed a cleanup.
ExprResult BuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo, SourceLocation RParenLoc, Expr *LiteralExpr)
void setBlockMangling(unsigned Number, Decl *Ctx)
void removeCVRQualifiers(unsigned mask)
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
static bool checkArgsForPlaceholders(Sema &S, MultiExprArg args)
UnresolvedSetImpl::iterator decls_iterator
void DefineImplicitDefaultConstructor(SourceLocation CurrentLocation, CXXConstructorDecl *Constructor)
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. In C++, this returns the unique wchar_t type. In C99...
const Expr * getAnyInitializer() const
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.
ExprResult BuildQualifiedDeclarationNameExpr(CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, bool IsAddressOfOperand, TypeSourceInfo **RecoveryTSI=nullptr)
static InitializationKind CreateCopy(SourceLocation InitLoc, SourceLocation EqualLoc, bool AllowExplicitConvs=false)
Create a copy initialization.
static void DiagnoseCalleeStaticArrayParam(Sema &S, ParmVarDecl *PVD)
static bool isPlaceholderToRemoveAsArg(QualType type)
QualType FindCompositePointerType(SourceLocation Loc, Expr *&E1, Expr *&E2, bool *NonStandardCompositeType=nullptr)
Find a merged pointer type and convert the two expressions to it.
ivar_iterator ivar_begin() const
static CharSourceRange getCharRange(SourceRange R)
ExprResult ActOnParenExpr(SourceLocation L, SourceLocation R, Expr *E)
static void diagnoseAddressOfInvalidType(Sema &S, SourceLocation Loc, Expr *E, unsigned Type)
Diagnose invalid operand for address of operations.
param_iterator param_begin()
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
bool isClassMethod() const
bool getNoReturnAttr() const
Determine whether this function type includes the GNU noreturn attribute. The C++11 [[noreturn]] attr...
ArrayRef< ParmVarDecl * > parameters() const
static bool isBitwiseOp(Opcode Opc)
Stmt * getBody(const FunctionDecl *&Definition) const
bool isInMainFile(SourceLocation Loc) const
Returns whether the PresumedLoc for a given SourceLocation is in the main file.
void initializeFullCopy(TypeLoc Other) const
Initializes this by copying its information from another TypeLoc of the same type.
static Opcode getOverloadedOpcode(OverloadedOperatorKind OO)
Retrieve the binary opcode that corresponds to the given overloaded operator.
static QualType checkConditionalObjectPointersCompatibility(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc)
Return the resulting type when the operands are both pointers.
Wrapper for source info for arrays.
TypeSourceInfo * CreateTypeSourceInfo(QualType T, unsigned Size=0) const
Allocate an uninitialized TypeSourceInfo.
Expr * IgnoreConversionOperator() LLVM_READONLY
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. This may omit quali...
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)
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl. It will iterate at least once ...
bool EvaluateAsBooleanCondition(bool &Result, const ASTContext &Ctx) const
int getIntegerTypeOrder(QualType LHS, QualType RHS) const
Return the highest ranked integer type, see C99 6.3.1.8p1.
DeclarationNameInfo getNameForTemplate(TemplateName Name, SourceLocation NameLoc) const
A reference to an overloaded function set, either an UnresolvedLookupExpr or an UnresolvedMemberExpr...
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
bool CheckCaseExpression(Expr *E)
ExprResult LookupInObjCMethod(LookupResult &LookUp, Scope *S, IdentifierInfo *II, bool AllowBuiltinCreation=false)
decl_type * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
A stack object to be created when performing template instantiation.
ExprResult CreateGenericSelectionExpr(SourceLocation KeyLoc, SourceLocation DefaultLoc, SourceLocation RParenLoc, Expr *ControllingExpr, ArrayRef< TypeSourceInfo * > Types, ArrayRef< Expr * > Exprs)
SourceLocation getOuterLocStart() const
Encodes a location in the source. The SourceManager can decode this to get at the full include stack...
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.
void NoteAllOverloadCandidates(Expr *E, QualType DestType=QualType())
llvm::APFloat::opStatus GetFloatValue(llvm::APFloat &Result)
const Type * getTypePtr() const
llvm::SmallPtrSet< Expr *, 2 > SavedMaybeODRUseExprs
CastKind PrepareCastToObjCObjectPointer(ExprResult &E)
QualType getElementType() const
QualType withCVRQualifiers(unsigned CVR) const
Expression is not a Null pointer constant.
VarArgKind isValidVarArgType(const QualType &Ty)
static void SuggestParentheses(Sema &Self, SourceLocation Loc, const PartialDiagnostic &Note, SourceRange ParenRange)
CXXRecordDecl * Lambda
The class that describes the lambda.
const TemplateArgumentListInfo & getTemplateArgsInfo() const
void DiagnoseAssignmentEnum(QualType DstType, QualType SrcType, Expr *SrcExpr)
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 isComplexType() const
bool isValid() const
Return true if this is a valid SourceLocation object.
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)"...
static ValueDecl * getPrimaryDecl(Expr *E)
void setLastStmt(Stmt *S)
static void warnOnSizeofOnArrayDecay(Sema &S, SourceLocation Loc, QualType T, Expr *E)
Check whether E is a pointer from a decayed array type (the decayed pointer type is equal to T) and e...
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
StringRef getNameForSlot(unsigned argIndex) const
Retrieve the name at a given position in the selector.
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location, which defaults to the empty location.
ASTContext & getASTContext() const
bool refersToEnclosingVariableOrCapture() const
Does this DeclRefExpr refer to an enclosing local or a captured variable?
void setReferenced(bool R=true)
QualType CheckCompareOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, unsigned OpaqueOpc, bool isRelational)
void DefineImplicitDestructor(SourceLocation CurrentLocation, CXXDestructorDecl *Destructor)
VectorKind getVectorKind() const
llvm::APSInt EvaluateKnownConstInt(const ASTContext &Ctx, SmallVectorImpl< PartialDiagnosticAt > *Diag=nullptr) const
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)
QualType CheckShiftOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, unsigned Opc, bool IsCompAssign=false)
ExprResult TransformToPotentiallyEvaluated(Expr *E)
const CXXRecordDecl * getBestDynamicClassType() const
For an expression of class type or pointer to class type, return the most derived class decl the expr...
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
ExprResult DefaultLvalueConversion(Expr *E)
static InitializedEntity InitializeCompoundLiteralInit(TypeSourceInfo *TSI)
Create the entity for a compound literal initializer.
ExtInfo withNoReturn(bool noReturn) const
bool isInvalid() const
An error occurred during parsing of the scope specifier.
QualType getObjCSelRedefinitionType() const
Retrieve the type that 'SEL' has been defined to, which may be different from the built-in 'SEL' if '...
const ConstantArrayType * getAsConstantArrayType(QualType T) const
bool isIntegerConstantExpr(llvm::APSInt &Result, const ASTContext &Ctx, SourceLocation *Loc=nullptr, bool isEvaluated=true) const
ExprResult ActOnInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList, SourceLocation RBraceLoc)
Specifies that a value-dependent expression should be considered to never be a null pointer constant...
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
Describes the kind of initialization being performed, along with location information for tokens rela...
AssignConvertType CheckTransparentUnionArgumentConstraints(QualType ArgType, ExprResult &RHS)
SmallVector< Capture, 4 > Captures
Captures - The captures.
Converts from an integral real to an integral complex whose element type matches the source...
unsigned NumTypos
The number of typos encountered during this expression evaluation context (i.e. the number of TypoExp...
Represents one property declaration in an Objective-C interface.
static QualType findBoundMemberType(const Expr *expr)
Given an expression of bound-member type, find the type of the member. Returns null if this is an ove...
QualType getReturnType() const
SourceLocation getBegin() const
virtual void diagnoseFold(Sema &S, SourceLocation Loc, SourceRange SR)
bool isTypeDependent() const
SourceLocation getBeginLoc() const
void setKind(IdKind kind)
void MarkVTableUsed(SourceLocation Loc, CXXRecordDecl *Class, bool DefinitionRequired=false)
Note that the vtable for the given class was used at the given location.
bool typesAreBlockPointerCompatible(QualType, QualType)
bool isVectorType() const
unsigned getBuiltinID() const
Returns a value indicating whether this function corresponds to a builtin function.
bool isPromotableIntegerType() const
More type predicates useful for type checking/promotion.
sema::FunctionScopeInfo * getCurFunction() const
Assigning into this object requires a lifetime extension.
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
const ArgList & getInnermost() const
Retrieve the innermost template argument list.
QualType CheckLogicalOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, unsigned Opc)
ExprResult HandleExprEvaluationContextForTypeof(Expr *E)
const BlockDecl * getBlockDecl() const
bool refersToBitField() const
Returns true if this expression is a gl-value that potentially refers to a bit-field.
void setLAngleLoc(SourceLocation Loc)
QualType getType() const
Return the type wrapped by this type source info.
void addArgument(const TemplateArgumentLoc &Loc)
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
ExprResult ActOnStmtExpr(SourceLocation LPLoc, Stmt *SubStmt, SourceLocation RPLoc)
SourceLocation getExprLoc() const LLVM_READONLY
QualType getPointeeType() const
SourceLocation getOperatorLoc() const
getOperatorLoc - Return the location of the operator.
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)
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.
AddrLabelExpr - The GNU address of label extension, representing &&label.
void diagnoseTypo(const TypoCorrection &Correction, const PartialDiagnostic &TypoDiag, bool ErrorRecovery=true)
void MarkMemberReferenced(MemberExpr *E)
Perform reference-marking and odr-use handling for a MemberExpr.
Base class for declarations which introduce a typedef-name.
sema::LambdaScopeInfo * getCurLambda()
Retrieve the current lambda scope info, if any.
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T-> getSizeExpr()))
Represents a template argument.
Converts a floating point complex to floating point real of the source's element type. Just discards the imaginary component. _Complex long double -> long double.
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)
FunctionTemplateDecl * getPrimaryTemplate() const
Retrieve the primary template that this function template specialization either specializes or was in...
static void ConstructTransparentUnion(Sema &S, ASTContext &C, ExprResult &EResult, QualType UnionType, FieldDecl *Field)
Constructs a transparent union from an expression that is used to initialize the transparent union...
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
static const Type * getElementType(const Expr *BaseExpr)
void setBody(CompoundStmt *B)
ExprResult ActOnBuiltinOffsetOf(Scope *S, SourceLocation BuiltinLoc, SourceLocation TypeLoc, ParsedType ParsedArgTy, OffsetOfComponent *CompPtr, unsigned NumComponents, SourceLocation RParenLoc)
StringRef getOpcodeStr() const
const Expr * getExpr() const
TemplatedKind getTemplatedKind() const
What kind of templated function this is.
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.
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. "delete[] pArray"...
static ImplicitConversionSequence TryImplicitConversion(Sema &S, Expr *From, QualType ToType, bool SuppressUserConversions, bool AllowExplicit, bool InOverloadResolution, bool CStyle, bool AllowObjCWritebackConversion, bool AllowObjCConversionOnExplicit)
static void diagnoseStringPlusInt(Sema &Self, SourceLocation OpLoc, Expr *LHSExpr, Expr *RHSExpr)
bool isSentinelNullExpr(const Expr *E)
Converts an integral complex to bool by comparing against 0+0i.
The base class of all kinds of template declarations (e.g., class, function, etc.).
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
bool hasUnparsedDefaultArg() const
bool isZero() const
isZero - Test whether the quantity equals zero.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return 0.
QualType GetSignedVectorType(QualType V)
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_RValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CCK_ImplicitConversion)
static bool CheckAlignOfExpr(Sema &S, Expr *E)
bool isInvalidDecl() const
ObjCLiteralKind CheckLiteralKind(Expr *FromE)
static bool IsVariableNonDependentAndAConstantExpression(VarDecl *Var, ASTContext &Context)
static bool tryVectorConvertAndSplat(Sema &S, ExprResult *scalar, QualType scalarTy, QualType vectorEltTy, QualType vectorTy)
void HandleFunctionTypeMismatch(PartialDiagnostic &PDiag, QualType FromType, QualType ToType)
TypeLoc IgnoreParens() const
ExprResult ActOnAsTypeExpr(Expr *E, ParsedType ParsedDestTy, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
__builtin_astype(...)
bool DiagRuntimeBehavior(SourceLocation Loc, const Stmt *Statement, const PartialDiagnostic &PD)
Conditionally issue a diagnostic based on the current evaluation context.
static void checkArithmeticNull(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompare)
CanQualType UnsignedLongLongTy
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
void CheckCompatibleReinterpretCast(QualType SrcType, QualType DestType, bool IsDereference, SourceRange Range)
const ObjCInterfaceType * getInterfaceType() const
unsigned CXXThisCaptureIndex
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.
const internal::VariadicDynCastAllOfMatcher< Stmt, CUDAKernelCallExpr > CUDAKernelCallExpr
Matches CUDA kernel call expression.
static ExprResult BuildCookedLiteralOperatorCall(Sema &S, Scope *Scope, IdentifierInfo *UDSuffix, SourceLocation UDSuffixLoc, ArrayRef< Expr * > Args, SourceLocation LitEndLoc)
static ExprResult rebuildUnknownAnyFunction(Sema &S, Expr *fn)
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. Returns true if recovery was attempted or...
OverloadExpr * Expression
bool isUsed(bool CheckUsedAttr=true) const
Whether this declaration was used, meaning that a definition is required.
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...
ExpressionEvaluationContext Context
The expression evaluation context.
virtual void HandleCXXImplicitFunctionInstantiation(FunctionDecl *D)
Invoked when a function is implicitly instantiated. Note that at this point point it does not have a ...
union clang::Sema::OffsetOfComponent::@207 U
A set of unresolved declarations.
bool isCopyCapture() const
SourceLocation getLocStart() const LLVM_READONLY
bool isDefinedOutsideFunctionOrMethod() const
virtual void diagnoseNotICE(Sema &S, SourceLocation Loc, SourceRange SR)=0
Expression is a C++11 nullptr.
static void EmitDiagnosticForLogicalAndInLogicalOr(Sema &Self, SourceLocation OpLoc, BinaryOperator *Bop)
It accepts a '&&' expr that is inside a '||' one. Emit a diagnostic together with a fixit hint that w...
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
unsigned getNumArgs() const
bool isSingleResult() const
static InitializationKind CreateCStyleCast(SourceLocation StartLoc, SourceRange TypeRange, bool InitList)
Create a direct initialization for a C-style cast.
virtual bool hasInt128Type() const
Determine whether the __int128 type is supported on this target.
A conversion of a floating point real to a floating point complex of the original type...
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
ExprResult DefaultFunctionArrayConversion(Expr *E)
DefaultFunctionArrayConversion (C99 6.3.2.1p3, C99 6.3.2.1p4).
bool hasAnyDependentBases() const
Determine whether this class has any dependent base classes which are not the current instantiation...
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)
void setInitializedFieldInUnion(FieldDecl *FD)
NamedDecl * getCurFunctionOrMethodDecl()
static bool IsLogicOp(BinaryOperatorKind Opc)
QualType getCorrespondingUnsignedType(QualType T) const
ExprResult ActOnConstantExpression(ExprResult Res)
DeclarationName getCorrection() const
Gets the DeclarationName of the typo correction.
bool areComparableObjCPointerTypes(QualType LHS, QualType RHS)
QualType getBuiltinVaListType() const
Retrieve the type of the __builtin_va_list type.
void InstantiateFunctionDefinition(SourceLocation PointOfInstantiation, FunctionDecl *Function, bool Recursive=false, bool DefinitionRequired=false)
Instantiate the definition of the given function from its template.
Expr * IgnoreParenImpCasts() LLVM_READONLY
QualType getPointeeType() const
QualType getNonReferenceType() const
ExprResult checkPseudoObjectRValue(Expr *E)
ExprResult IgnoredValueConversions(Expr *E)
void LookupOverloadedOperatorName(OverloadedOperatorKind Op, Scope *S, QualType T1, QualType T2, UnresolvedSetImpl &Functions)
SourceLocation getMemberLoc() const
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
bool IsOpenMPCapturedVar(VarDecl *VD)
Check if the specified variable is used in a private clause in Checks if the specified variable is us...
CanQualType ObjCBuiltinBoolTy
ObjCMethodDecl * LookupInstanceMethodInGlobalPool(Selector Sel, SourceRange R, bool receiverIdOrClass=false)
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.
bool isObjCObjectType() const
NamedDecl * getCorrectionDecl() const
Gets the pointer to the declaration of the typo correction.
Not an overloaded operator.
RecordDecl * TheRecordDecl
The captured record type.
ExprResult CheckCXXBooleanCondition(Expr *CondExpr)
CheckCXXBooleanCondition - Returns true if conversion to bool is invalid.
QualType getPointerDiffType() const
Return the unique type for "ptrdiff_t" (C99 7.17) defined in <stddef.h>. Pointer - pointer requires t...
SourceManager & getSourceManager() const
FunctionDecl * getOperatorNew() const
ExprResult BuildLiteralOperatorCall(LookupResult &R, DeclarationNameInfo &SuffixInfo, ArrayRef< Expr * > Args, SourceLocation LitEndLoc, TemplateArgumentListInfo *ExplicitTemplateArgs=nullptr)
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)
bool isAddressSpaceOverlapping(const PointerType &other) const
Returns true if address spaces of pointers overlap. OpenCL v2.0 defines conversion rules for pointers...
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)
CanQualType UnsignedLongTy
ObjCInterfaceDecl * getInterfaceDecl() const
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
bool areCompatibleVectorTypes(QualType FirstVec, QualType SecondVec)
Return true if the given vector types are of the same unqualified type or if they are equivalent to t...
ExprResult CheckExtVectorCast(SourceRange R, QualType DestTy, Expr *CastExpr, CastKind &Kind)
static void DiagnoseAdditionInShift(Sema &S, SourceLocation OpLoc, Expr *SubExpr, StringRef Shift)
FunctionDecl * getCurFunctionDecl()
static bool checkArithmeticBinOpPointerOperands(Sema &S, SourceLocation Loc, Expr *LHSExpr, Expr *RHSExpr)
Check the validity of a binary arithmetic operation w.r.t. pointer operands.
bool isObjCQualifiedIdType() const
SourceLocation getLocStart() const LLVM_READONLY
static SourceLocation getUDSuffixLoc(Sema &S, SourceLocation TokLoc, unsigned Offset)
bool isFunctionType() const
Converts from T to _Atomic(T).
DeclContext * getRedeclContext()
CXXConstructorDecl * getConstructor() const
CanQualType BoundMemberTy
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
unsigned getAddressSpace() const
static Sema::AssignConvertType checkBlockPointerTypesForAssignment(Sema &S, QualType LHSType, QualType RHSType)
Converts from a floating complex to an integral complex. _Complex float -> _Complex int...
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)
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)
static bool isInvalid(SourceLocation Loc, bool *Invalid)
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
void addDecl(Decl *D)
Add the declaration D into this context.
bool canAssignObjCInterfaces(const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT)
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream...
unsigned getIntWidth() const
unsigned getLongLongWidth() const
A template-id, e.g., f<int>.
llvm::DenseMap< VarDecl *, unsigned > CaptureMap
CaptureMap - A map of captured variables to (index+1) into Captures.
ExprResult BuildBuiltinOffsetOf(SourceLocation BuiltinLoc, TypeSourceInfo *TInfo, OffsetOfComponent *CompPtr, unsigned NumComponents, SourceLocation RParenLoc)
__builtin_offsetof(type, a.b[123][456].c)
SmallVector< BlockDecl *, 8 > ExprCleanupObjects
bool isUnevaluated() const
A bitfield object is a bitfield on a C or C++ record.
void markUsed(ASTContext &C)
Mark the declaration used, in the sense of odr-use.
void DiagnoseSentinelCalls(NamedDecl *D, SourceLocation Loc, ArrayRef< Expr * > Args)
ObjCIvarRefExpr - A reference to an ObjC instance variable.
static void diagnoseDistinctPointerComparison(Sema &S, SourceLocation Loc, ExprResult &LHS, ExprResult &RHS, bool IsError)
Diagnose bad pointer comparisons.
QualType InvalidOperands(SourceLocation Loc, ExprResult &LHS, ExprResult &RHS)
type checking binary operators (subroutines of CreateBuiltinBinOp).
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)
Scope * getScopeForContext(DeclContext *Ctx)
Determines the active Scope associated with the given declaration context.
A template argument list.
static void DiagnoseBitwiseAndInBitwiseOr(Sema &S, SourceLocation OpLoc, Expr *OrArg)
Look for '&' in the left or right hand of a '|' expr.
const DeclContext * getCurObjCLexicalContext() const
SourceRange getCorrectionRange() const
static BlockDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L)
AccessControl getAccessControl() const
Reading or writing from this object requires a barrier call.
ExprResult CreateUnaryExprOrTypeTraitExpr(TypeSourceInfo *TInfo, SourceLocation OpLoc, UnaryExprOrTypeTrait ExprKind, SourceRange R)
Build a sizeof or alignof expression given a type operand.
void DefineImplicitLambdaToBlockPointerConversion(SourceLocation CurrentLoc, CXXConversionDecl *Conv)
Define the "body" of the conversion from a lambda object to a block pointer.
bool isPODType(ASTContext &Context) const
Determine whether this is a Plain Old Data (POD) type (C++ 3.9p10).
unsigned getFullDataSize() const
Returns the size of the type source info data block.
bool hasAddressSpace() const
ExprResult DefaultVariadicArgumentPromotion(Expr *E, VariadicCallType CT, FunctionDecl *FDecl)
Expression is a Null pointer constant built from a literal zero.
Expr * MaybeCreateExprWithCleanups(Expr *SubExpr)
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)
FunctionTemplateSpecializationInfo * getTemplateSpecializationInfo() const
If this function is actually a function template specialization, retrieve information about this func...
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. A pseudo-__strong variable has a ...
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
static QualType handleFloatConversion(Sema &S, ExprResult &LHS, ExprResult &RHS, QualType LHSType, QualType RHSType, bool IsCompAssign)
Handle arithmethic conversion with floating point types. Helper function of UsualArithmeticConversion...
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
SourceLocation getLocStart() const LLVM_READONLY
static bool IsArithmeticBinaryExpr(Expr *E, BinaryOperatorKind *Opcode, Expr **RHSExprs)
Optional< sema::TemplateDeductionInfo * > isSFINAEContext() const
Determines whether we are currently in a context where template argument substitution failures are no...
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
bool hasQualifier() const
Determines whether this member expression actually had a C++ nested-name-specifier prior to the name ...
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 known vector types?
bool NeedToCaptureVariable(VarDecl *Var, SourceLocation Loc)
Checks if the variable must be captured.
bool isObjCSelType(QualType T) const
QualType CheckMultiplyDivideOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign, bool IsDivide)
bool isOverloadableType() const
Determines whether this is a type for which one can define an overloaded operator.
Builtin::Context & BuiltinInfo
Location information for a TemplateArgument.
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
void MaybeSuggestAddingStaticToDecl(const FunctionDecl *D)
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string...
void addVLATypeCapture(SourceLocation Loc, QualType CaptureType)
SmallVectorImpl< NamedDecl * >::iterator decl_iterator
LookupResultKind getResultKind() const
unsigned getLongWidth() const
void setParameterCFAudited()
Converts from _Atomic(T) to T.
ExpressionEvaluationContext
Describes how the expressions currently being parsed are evaluated at run-time, if at all...
OverloadingResult BestViableFunction(Sema &S, SourceLocation Loc, OverloadCandidateSet::iterator &Best, bool UserDefinedConversion=false)
Find the best viable function on this overload set, if it exists.
static Expr * BuildFloatingLiteral(Sema &S, NumericLiteralParser &Literal, QualType Ty, SourceLocation Loc)
Defines the clang::TargetInfo interface.
QualType CheckVectorOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign, bool AllowBothBool, bool AllowBoolConversion)
type checking for vector binary operators.
void UpdateMarkingForLValueToRValue(Expr *E)
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC...
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
bool HasImplicitReturnType
Whether the target type of return statements in this context is deduced (e.g. a lambda or block with ...
ObjCInterfaceDecl * getSuperClass() const
AvailabilityResult getCurContextAvailability() const
static bool hasAnyTypeDependentArguments(ArrayRef< Expr * > Exprs)
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)
decl_type * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
bool isValid() const
A scope specifier is present, and it refers to a real scope.
A reference to a declared variable, function, enum, etc. [C99 6.5.1p2].
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
NamedDecl * getMostRecentDecl()
ExprResult BuildVAArgExpr(SourceLocation BuiltinLoc, Expr *E, TypeSourceInfo *TInfo, SourceLocation RPLoc)
unsigned getLength() const
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7)...
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type...
QualType getElementType() const
void MarkFunctionReferenced(SourceLocation Loc, FunctionDecl *Func, bool OdrUse=true)
Mark a function referenced, and check whether it is odr-used (C++ [basic.def.odr]p2, C99 6.9p3)
bool hasQualifiers() const
Determine whether this type has any qualifiers.
void setSubStmt(Stmt *SS)
ExprResult ActOnStringLiteral(ArrayRef< Token > StringToks, Scope *UDLScope=nullptr)
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given binary opcode.
static bool HasRedeclarationWithoutAvailabilityInCategory(const Decl *D)
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
const Expr * getSubExpr() const
void addCapture(VarDecl *Var, bool isBlock, bool isByref, bool isNested, SourceLocation Loc, SourceLocation EllipsisLoc, QualType CaptureType, Expr *Cpy)
void InstantiateVariableDefinition(SourceLocation PointOfInstantiation, VarDecl *Var, bool Recursive=false, bool DefinitionRequired=false)
void suppressDiagnostics()
void setLocation(SourceLocation L)
An l-value expression is a reference to an object with independent storage.
static bool anyDependentTemplateArguments(const TemplateArgumentLoc *Args, unsigned NumArgs, bool &InstantiationDependent)
Determine whether any of the given template arguments are dependent.
bool isUnresolvedExceptionSpec(ExceptionSpecificationType ESpecType)
const llvm::fltSemantics & getFloatTypeSemantics(QualType T) const
Return the APFloat 'semantics' for the specified scalar floating point type.
A trivial tuple used to represent a source range.
SourceLocation getLocation() const
TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, std::unique_ptr< CorrectionCandidateCallback > CCC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr, bool RecordFailure=true)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
void setIdentifier(const IdentifierInfo *Id, SourceLocation IdLoc)
Specify that this unqualified-id was parsed as an identifier.
bool isInvalidType() const
FunctionDecl * getInstantiatedFromMemberFunction() const
If this function is an instantiation of a member function of a class template specialization, retrieves the function from which it was instantiated.
ExprResult BuildVectorLiteral(SourceLocation LParenLoc, SourceLocation RParenLoc, Expr *E, TypeSourceInfo *TInfo)
Build an altivec or OpenCL literal.
bool ResolveAndFixSingleFunctionTemplateSpecialization(ExprResult &SrcExpr, bool DoFunctionPointerConverion=false, bool Complain=false, const SourceRange &OpRangeForComplaining=SourceRange(), QualType DestTypeForComplaining=QualType(), unsigned DiagIDForComplaining=0)
void setAccess(AccessSpecifier AS)
bool CheckCallReturnType(QualType ReturnType, SourceLocation Loc, CallExpr *CE, FunctionDecl *FD)
bool isArithmeticType() const
No keyword precedes the qualified type name.
bool ObjCQualifiedIdTypesAreCompatible(QualType LHS, QualType RHS, bool ForCompare)
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
isNull - 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
static void DiagnoseUnusedOfDecl(Sema &S, NamedDecl *D, SourceLocation Loc)
static bool checkOpenCLConditionVector(Sema &S, Expr *Cond, SourceLocation QuestionLoc)
Return false if this is a valid OpenCL condition vector.
void setType(QualType newType)
static bool isComparisonOp(Opcode Opc)
static OpaquePtr getFromOpaquePtr(void *P)
SourceLocation ColonLoc
Location of ':'.
void EmitAvailabilityWarning(AvailabilityDiagnostic AD, NamedDecl *D, StringRef Message, SourceLocation Loc, const ObjCInterfaceDecl *UnknownObjCClass, const ObjCPropertyDecl *ObjCProperty, bool ObjCPropertyAccess)
QualType getSingleStepDesugaredType(const ASTContext &Context) const
Return the specified type with one level of "sugar" removed from the type.
void WillReplaceSpecifier(bool ForceReplacement)
The lookup resulted in an error.
static void checkObjCPointerIntrospection(Sema &S, ExprResult &L, ExprResult &R, SourceLocation OpLoc)
bool isIntegralType(ASTContext &Ctx) const
Determine whether this type is an integral type.
static bool IsArithmeticOp(BinaryOperatorKind Opc)
const CXXDestructorDecl * getDestructor() const
Preprocessor & getPreprocessor() const
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
Declaration of a template function.
void clear()
Clears out any current state.
QualType getBOOLType() const
type of 'BOOL' type.
NullPointerConstantKind
Enumeration used to describe the kind of Null pointer constant returned from isNullPointerConstant()...
SourceLocation getLocStart() const LLVM_READONLY
void setElaboratedKeywordLoc(SourceLocation Loc)
bool isOverloadedResult() const
Determines if the results are overloaded.
Attr - This represents one attribute.
ScalarTypeKind getScalarTypeKind() const
getScalarTypeKind - Given that this is a scalar type, classify it.
QualType UsualArithmeticConversions(ExprResult &LHS, ExprResult &RHS, bool IsCompAssign=false)
void startToken()
Reset all flags to cleared.
ExprResult ActOnAddrLabel(SourceLocation OpLoc, SourceLocation LabLoc, LabelDecl *TheDecl)
ActOnAddrLabel - Parse the GNU address of label extension: "&&foo".
QualType CheckAddressOfOperand(ExprResult &Operand, SourceLocation OpLoc)
bool isIntegerType() const
bool hasLocalStorage() const
ParsedTemplateTy Template
const RecordDecl * getParent() const
void ActOnBlockError(SourceLocation CaretLoc, Scope *CurScope)
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
CanQualType UnsignedIntTy
bool isAddressSpaceSupersetOf(Qualifiers other) const
Returns true if this address space is a superset of the other one. OpenCL v2.0 defines conversion rul...
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
bool isPointerType() const
static void RecordModifiableNonNullParam(Sema &S, const Expr *Exp)
Structure used to store a statement, the constant value to which it was evaluated (if any)...
VariadicCallType getVariadicCallType(FunctionDecl *FDecl, const FunctionProtoType *Proto, Expr *Fn)
OverloadedOperatorKind getOverloadedOperator() const
bool isIncompleteOrObjectType() const
SourceLocation getLocStart() const LLVM_READONLY
static QualType CheckRealImagOperand(Sema &S, ExprResult &V, SourceLocation Loc, bool IsReal)