46 #include "llvm/Support/ConvertUTF.h"
47 using namespace clang;
54 if (ParsingInitForAutoVars.count(D))
64 if (getLangOpts().CPlusPlus14 && FD->getReturnType()->isUndeducedType() &&
79 if (
const auto *A = D->
getAttr<UnusedAttr>()) {
82 if (A->getSemanticSpelling() != UnusedAttr::CXX11_maybe_unused) {
84 if (DC && !DC->
hasAttr<UnusedAttr>())
96 if (Method && Method->isDeleted() && Method->isDefaulted()) {
98 if (!Method->isImplicit())
104 if (CSM != CXXInvalid)
105 ShouldDeleteSpecialMember(Method, CSM,
nullptr,
true);
111 if (Ctor && Ctor->isInheritingConstructor())
112 return NoteDeletedInheritingConstructor(Ctor);
122 if (
I->getStorageClass() !=
SC_None)
167 if (!DowngradeWarning && UsedFn)
170 S.
Diag(Loc, DowngradeWarning ? diag::ext_internal_in_extern_inline_quiet
171 : diag::ext_internal_in_extern_inline)
176 S.
Diag(D->getCanonicalDecl()->getLocation(), diag::note_entity_declared_at)
186 Diag(DeclBegin, diag::note_convert_inline_to_static)
205 bool ObjCPropertyAccess,
206 bool AvoidPartialAvailabilityChecks) {
207 if (getLangOpts().
CPlusPlus && isa<FunctionDecl>(D)) {
211 if (Pos != SuppressedDiagnostics.end()) {
213 Diag(Suppressed.first, Suppressed.second);
224 if (cast<FunctionDecl>(D)->isMain())
225 Diag(Loc, diag::ext_main_used);
229 if (ParsingInitForAutoVars.count(D)) {
230 if (isa<BindingDecl>(D)) {
231 Diag(Loc, diag::err_binding_cannot_appear_in_own_initializer)
234 Diag(Loc, diag::err_auto_variable_cannot_appear_in_own_initializer)
235 << D->
getDeclName() << cast<VarDecl>(D)->getType();
242 if (FD->isDeleted()) {
244 if (Ctor && Ctor->isInheritingConstructor())
245 Diag(Loc, diag::err_deleted_inherited_ctor_use)
247 << Ctor->getInheritedConstructor().getConstructor()->getParent();
249 Diag(Loc, diag::err_deleted_function_use);
250 NoteDeletedFunction(FD);
256 if (getLangOpts().
CPlusPlus14 && FD->getReturnType()->isUndeducedType() &&
257 DeduceReturnType(FD, Loc))
260 if (getLangOpts().CUDA && !CheckCUDACall(Loc, FD))
264 auto getReferencedObjCProp = [](
const NamedDecl *D) ->
266 if (
const auto *MD = dyn_cast<ObjCMethodDecl>(D))
271 if (diagnoseArgIndependentDiagnoseIfAttrs(ObjCPDecl, Loc))
273 }
else if (diagnoseArgIndependentDiagnoseIfAttrs(D, Loc)) {
282 if (LangOpts.OpenMP && DRD && !CurContext->containsDecl(D) &&
284 Diag(Loc, diag::err_omp_wrong_var_in_declare_reduction)
285 << getCurFunction()->HasOMPDeclareReductionCombiner;
290 DiagnoseAvailabilityOfDecl(D, Loc, UnknownObjCClass, ObjCPropertyAccess,
291 AvoidPartialAvailabilityChecks);
306 return ": " + Message;
308 return std::string();
317 const SentinelAttr *attr = D->
getAttr<SentinelAttr>();
322 unsigned numFormalParams;
326 enum CalleeType { CT_Function, CT_Method, CT_Block } calleeType;
329 numFormalParams = MD->param_size();
330 calleeType = CT_Method;
331 }
else if (
FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
332 numFormalParams = FD->param_size();
333 calleeType = CT_Function;
334 }
else if (isa<VarDecl>(D)) {
340 calleeType = CT_Function;
343 calleeType = CT_Block;
349 numFormalParams = proto->getNumParams();
361 unsigned nullPos = attr->getNullPos();
362 assert((nullPos == 0 || nullPos == 1) &&
"invalid null position on sentinel");
363 numFormalParams = (nullPos > numFormalParams ? 0 : numFormalParams - nullPos);
366 unsigned numArgsAfterSentinel = attr->getSentinel();
370 if (Args.size() < numFormalParams + numArgsAfterSentinel + 1) {
377 Expr *sentinelExpr = Args[Args.size() - numArgsAfterSentinel - 1];
378 if (!sentinelExpr)
return;
387 = getLocForEndOfToken(sentinelExpr->
getLocEnd());
388 std::string NullValue;
389 if (calleeType == CT_Method && PP.isMacroDefined(
"nil"))
391 else if (getLangOpts().CPlusPlus11)
392 NullValue =
"nullptr";
393 else if (PP.isMacroDefined(
"NULL"))
396 NullValue =
"(void*) 0";
399 Diag(Loc, diag::warn_missing_sentinel) << int(calleeType);
401 Diag(MissingNilLoc, diag::warn_missing_sentinel)
425 assert(!Ty.
isNull() &&
"DefaultFunctionArrayConversion - missing type");
430 if (getLangOpts().OpenCL) {
437 if (
auto *FD = dyn_cast<FunctionDecl>(DRE->getDecl()))
442 CK_FunctionToPointerDecay).
get();
455 if (getLangOpts().C99 || getLangOpts().CPlusPlus || E->
isLValue())
457 CK_ArrayToPointerDecay).
get();
469 if (UO->getOpcode() == UO_Deref &&
470 UO->getSubExpr()->IgnoreParenCasts()->
472 !UO->getType().isVolatileQualified()) {
474 S.
PDiag(diag::warn_indirection_through_null)
475 << UO->getSubExpr()->getSourceRange());
477 S.
PDiag(diag::note_indirection_through_null));
490 if (!Member || !Member->
isStr(
"isa"))
500 ObjCIvarDecl *IV = IDecl->lookupInstanceVariable(Member, ClassDeclared);
508 if (ObjectSetClass) {
551 assert(!T.
isNull() &&
"r-value conversion on typeless expression?");
555 if (getLangOpts().CPlusPlus &&
570 if (getLangOpts().OpenCL && !getOpenCLOptions().isEnabled(
"cl_khr_fp16") &&
579 NamedDecl *ObjectGetClass = LookupSingleName(TUScope,
586 SourceRange(OISA->getOpLoc(), OISA->getIsaMemberLoc()),
")");
611 UpdateMarkingForLValueToRValue(E);
616 Cleanup.setExprNeedsCleanups(
true);
625 T = Atomic->getValueType().getUnqualifiedType();
634 ExprResult Res = DefaultFunctionArrayConversion(E, Diagnose);
637 Res = DefaultLvalueConversion(Res.
get());
652 CK_FunctionToPointerDecay).
get();
656 Res = DefaultLvalueConversion(Res.
get());
669 ExprResult Res = DefaultFunctionArrayLvalueConversion(E);
675 assert(!Ty.
isNull() &&
"UsualUnaryConversions - missing type");
678 if (Ty->
isHalfType() && !getLangOpts().NativeHalfType)
700 E = ImpCastExprToType(E, PTy, CK_IntegralCast).get();
705 E = ImpCastExprToType(E, PT, CK_IntegralCast).get();
718 assert(!Ty.
isNull() &&
"DefaultArgumentPromotion - missing type");
728 if (BTy && (BTy->
getKind() == BuiltinType::Half ||
729 BTy->
getKind() == BuiltinType::Float)) {
730 if (getLangOpts().OpenCL &&
731 !getOpenCLOptions().isEnabled(
"cl_khr_fp64")) {
732 if (BTy->
getKind() == BuiltinType::Half) {
794 if (!Record->hasNonTrivialCopyConstructor() &&
795 !Record->hasNonTrivialMoveConstructor() &&
796 !Record->hasNonTrivialDestructor())
797 return VAK_ValidInCXX11;
805 if (getLangOpts().MSVCCompat)
806 return VAK_MSVCUndefined;
810 return VAK_Undefined;
820 case VAK_ValidInCXX11:
823 PDiag(diag::warn_cxx98_compat_pass_non_pod_arg_to_vararg)
831 PDiag(diag::warn_pass_class_arg_to_vararg)
832 << Ty << CT << hasCStrMethod(E) <<
".c_str()");
837 case VAK_MSVCUndefined:
840 PDiag(diag::warn_cannot_pass_non_pod_arg_to_vararg)
841 << getLangOpts().CPlusPlus11 << Ty << CT);
848 PDiag(diag::err_cannot_pass_objc_interface_to_vararg)
852 << isa<InitListExpr>(E) << Ty << CT;
863 if (PlaceholderTy->getKind() == BuiltinType::ARCUnbridgedCast &&
864 (CT == VariadicMethod ||
865 (FDecl && FDecl->
hasAttr<CFAuditedTransferAttr>()))) {
866 E = stripARCUnbridgedCast(E);
877 ExprResult ExprRes = DefaultArgumentPromotion(E);
884 if (isValidVarArgType(E->
getType()) == VAK_Undefined) {
891 ExprResult TrapFn = ActOnIdExpression(TUScope, SS, TemplateKWLoc,
911 diag::err_call_incomplete_argument))
928 if (SkipCast)
return false;
930 QualType fpTy = cast<ComplexType>(ComplexTy)->getElementType();
933 CK_FloatingRealToComplex);
937 CK_IntegralComplexToFloatingComplex);
970 auto *LHSComplexType = dyn_cast<
ComplexType>(LHSType);
971 auto *RHSComplexType = dyn_cast<
ComplexType>(RHSType);
973 LHSComplexType ? LHSComplexType->getElementType() : LHSType;
975 RHSComplexType ? RHSComplexType->getElementType() : RHSType;
988 }
else if (Order > 0) {
1003 bool ConvertFloat,
bool ConvertInt) {
1008 CK_IntegralToFloating);
1019 CK_IntegralComplexToFloatingComplex);
1024 CK_FloatingRealToComplex);
1033 QualType RHSType,
bool IsCompAssign) {
1039 if (LHSFloat && RHSFloat) {
1046 assert(order < 0 &&
"illegal float comparison");
1080 "The remaining types must be floating point types.");
1085 QualType LHSElemType = LHSComplex ?
1086 LHSComplex->getElementType() : LHSType;
1087 QualType RHSElemType = RHSComplex ?
1104 return Float128AndLongDouble &&
1106 &llvm::APFloat::IEEEdouble());
1120 CK_IntegralComplexCast);
1126 template <PerformCastFn doLHSCast, PerformCastFn doRHSCast>
1129 QualType RHSType,
bool IsCompAssign) {
1134 if (LHSSigned == RHSSigned) {
1137 RHS = (*doRHSCast)(
S, RHS.
get(), LHSType);
1139 }
else if (!IsCompAssign)
1140 LHS = (*doLHSCast)(
S, LHS.
get(), RHSType);
1142 }
else if (order != (LHSSigned ? 1 : -1)) {
1146 RHS = (*doRHSCast)(
S, RHS.
get(), LHSType);
1148 }
else if (!IsCompAssign)
1149 LHS = (*doLHSCast)(
S, LHS.
get(), RHSType);
1156 RHS = (*doRHSCast)(
S, RHS.
get(), LHSType);
1158 }
else if (!IsCompAssign)
1159 LHS = (*doLHSCast)(
S, LHS.
get(), RHSType);
1168 RHS = (*doRHSCast)(
S, RHS.
get(), result);
1170 LHS = (*doLHSCast)(
S, LHS.
get(), result);
1180 bool IsCompAssign) {
1184 if (LHSComplexInt && RHSComplexInt) {
1188 handleIntegerConversion<doComplexIntegralCast, doComplexIntegralCast>
1189 (
S, LHS, RHS, LHSEltType, RHSEltType, IsCompAssign);
1191 return S.Context.getComplexType(ScalarType);
1194 if (LHSComplexInt) {
1197 handleIntegerConversion<doComplexIntegralCast, doIntegralCast>
1198 (
S, LHS, RHS, LHSEltType, RHSType, IsCompAssign);
1200 RHS = S.ImpCastExprToType(RHS.get(), ComplexType,
1201 CK_IntegralRealToComplex);
1206 assert(RHSComplexInt);
1210 handleIntegerConversion<doIntegralCast, doComplexIntegralCast>
1211 (
S, LHS, RHS, LHSType, RHSEltType, IsCompAssign);
1215 LHS = S.ImpCastExprToType(LHS.get(), ComplexType,
1216 CK_IntegralRealToComplex);
1225 bool IsCompAssign) {
1226 if (!IsCompAssign) {
1227 LHS = UsualUnaryConversions(LHS.
get());
1232 RHS = UsualUnaryConversions(RHS.
get());
1245 LHSType = AtomicLHS->getValueType();
1248 if (LHSType == RHSType)
1257 QualType LHSUnpromotedType = LHSType;
1261 if (!LHSBitfieldPromoteTy.
isNull())
1262 LHSType = LHSBitfieldPromoteTy;
1263 if (LHSType != LHSUnpromotedType && !IsCompAssign)
1264 LHS = ImpCastExprToType(LHS.
get(), LHSType, CK_IntegralCast);
1267 if (LHSType == RHSType)
1293 return handleIntegerConversion<doIntegralCast, doIntegralCast>
1294 (*
this, LHS, RHS, LHSType, RHSType, IsCompAssign);
1307 Expr *ControllingExpr,
1310 unsigned NumAssocs = ArgTypes.size();
1311 assert(NumAssocs == ArgExprs.size());
1314 for (
unsigned i = 0; i < NumAssocs; ++i) {
1316 (void) GetTypeFromParser(ArgTypes[i], &Types[i]);
1321 ExprResult ER = CreateGenericSelectionExpr(KeyLoc, DefaultLoc, RParenLoc,
1323 llvm::makeArrayRef(Types, NumAssocs),
1333 Expr *ControllingExpr,
1336 unsigned NumAssocs = Types.size();
1337 assert(NumAssocs == Exprs.size());
1344 ExprResult R = DefaultFunctionArrayLvalueConversion(ControllingExpr);
1347 ControllingExpr = R.
get();
1352 if (!inTemplateInstantiation() &&
1355 diag::warn_side_effects_unevaluated_context);
1357 bool TypeErrorFound =
false,
1359 ContainsUnexpandedParameterPack
1362 for (
unsigned i = 0; i < NumAssocs; ++i) {
1363 if (Exprs[i]->containsUnexpandedParameterPack())
1364 ContainsUnexpandedParameterPack =
true;
1367 if (Types[i]->getType()->containsUnexpandedParameterPack())
1368 ContainsUnexpandedParameterPack =
true;
1370 if (Types[i]->getType()->isDependentType()) {
1371 IsResultDependent =
true;
1376 if (Types[i]->getType()->isIncompleteType())
1377 D = diag::err_assoc_type_incomplete;
1378 else if (!Types[i]->getType()->isObjectType())
1379 D = diag::err_assoc_type_nonobject;
1380 else if (Types[i]->getType()->isVariablyModifiedType())
1381 D = diag::err_assoc_type_variably_modified;
1384 Diag(Types[i]->getTypeLoc().getBeginLoc(), D)
1385 << Types[i]->getTypeLoc().getSourceRange()
1386 << Types[i]->getType();
1387 TypeErrorFound =
true;
1392 for (
unsigned j = i+1; j < NumAssocs; ++j)
1393 if (Types[j] && !Types[j]->getType()->isDependentType() &&
1395 Types[j]->getType())) {
1396 Diag(Types[j]->getTypeLoc().getBeginLoc(),
1397 diag::err_assoc_compatible_types)
1398 << Types[j]->getTypeLoc().getSourceRange()
1399 << Types[j]->getType()
1400 << Types[i]->getType();
1401 Diag(Types[i]->getTypeLoc().getBeginLoc(),
1402 diag::note_compat_assoc)
1403 << Types[i]->getTypeLoc().getSourceRange()
1404 << Types[i]->getType();
1405 TypeErrorFound =
true;
1415 if (IsResultDependent)
1417 Context, KeyLoc, ControllingExpr, Types, Exprs, DefaultLoc, RParenLoc,
1418 ContainsUnexpandedParameterPack);
1421 unsigned DefaultIndex = -1U;
1422 for (
unsigned i = 0; i < NumAssocs; ++i) {
1426 Types[i]->getType()))
1427 CompatIndices.push_back(i);
1433 if (CompatIndices.size() > 1) {
1437 Diag(ControllingExpr->
getLocStart(), diag::err_generic_sel_multi_match)
1439 << (
unsigned) CompatIndices.size();
1440 for (
unsigned I : CompatIndices) {
1441 Diag(Types[
I]->getTypeLoc().getBeginLoc(),
1442 diag::note_compat_assoc)
1443 << Types[
I]->getTypeLoc().getSourceRange()
1444 << Types[
I]->getType();
1452 if (DefaultIndex == -1U && CompatIndices.size() == 0) {
1466 unsigned ResultIndex =
1467 CompatIndices.size() ? CompatIndices[0] : DefaultIndex;
1470 Context, KeyLoc, ControllingExpr, Types, Exprs, DefaultLoc, RParenLoc,
1471 ContainsUnexpandedParameterPack, ResultIndex);
1489 assert(Args.size() <= 2 &&
"too many arguments for literal operator");
1492 for (
unsigned ArgIdx = 0; ArgIdx != Args.size(); ++ArgIdx) {
1493 ArgTy[ArgIdx] = Args[ArgIdx]->getType();
1494 if (ArgTy[ArgIdx]->isArrayType())
1520 assert(!StringToks.empty() &&
"Must have at least one string!");
1523 if (Literal.hadError)
1527 for (
const Token &Tok : StringToks)
1528 StringTokLocs.push_back(Tok.getLocation());
1532 if (Literal.isWide()) {
1535 }
else if (Literal.isUTF8()) {
1537 }
else if (Literal.isUTF16()) {
1540 }
else if (Literal.isUTF32()) {
1543 }
else if (Literal.isPascal()) {
1549 if (getLangOpts().CPlusPlus || getLangOpts().ConstStrings)
1556 llvm::APInt(32, Literal.GetNumStringChars()+1),
1560 if (getLangOpts().OpenCL) {
1566 Kind, Literal.Pascal, StrTy,
1568 StringTokLocs.size());
1569 if (Literal.getUDSuffix().empty())
1576 Literal.getUDSuffixOffset());
1580 return ExprError(
Diag(UDSuffixLoc, diag::err_invalid_string_udl));
1595 LookupResult R(*
this, OpName, UDSuffixLoc, LookupOrdinaryName);
1596 switch (LookupLiteralOperator(UDLScope, R, ArgTy,
1604 Expr *Args[] = { Lit, LenArg };
1606 return BuildLiteralOperatorCall(R, OpNameInfo, Args, StringTokLocs.back());
1609 case LOLR_StringTemplate: {
1614 llvm::APSInt
Value(CharBits, CharIsUnsigned);
1620 for (
unsigned I = 0, N = Lit->
getLength();
I != N; ++
I) {
1626 return BuildLiteralOperatorCall(R, OpNameInfo,
None, StringTokLocs.back(),
1631 llvm_unreachable(
"unexpected literal operator lookup result");
1635 llvm_unreachable(
"unexpected literal operator lookup result");
1643 return BuildDeclRefExpr(D, Ty, VK, NameInfo, SS);
1653 bool RefersToCapturedVariable =
1655 NeedToCaptureVariable(cast<VarDecl>(D), NameInfo.
getLoc());
1658 if (isa<VarTemplateSpecializationDecl>(D)) {
1660 cast<VarTemplateSpecializationDecl>(D);
1665 RefersToCapturedVariable, NameInfo.
getLoc(), Ty, VK,
1666 FoundD, TemplateArgs);
1668 assert(!TemplateArgs &&
"No template arguments for non-variable"
1669 " template specialization references");
1673 NameInfo, Ty, VK, FoundD);
1676 MarkDeclRefReferenced(E);
1678 if (getLangOpts().ObjCWeak && isa<VarDecl>(D) &&
1680 !Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, E->getLocStart()))
1681 recordUseOfEvaluatedWeak(E);
1685 FD = IFD->getAnonField();
1687 UnusedPrivateFields.remove(FD);
1695 if (
auto *BD = dyn_cast<BindingDecl>(D))
1696 if (
auto *BE = BD->getBinding())
1697 E->setObjectKind(BE->getObjectKind());
1722 translateTemplateArguments(TemplateArgsPtr, Buffer);
1729 NameInfo = GetNameFromUnqualifiedId(Id);
1730 TemplateArgs =
nullptr;
1737 unsigned DiagnosticID,
unsigned DiagnosticSuggestID) {
1744 SemaRef.
Diag(TypoLoc, diag::err_no_member) << Typo << Ctx
1747 SemaRef.
Diag(TypoLoc, DiagnosticID) <<
Typo;
1752 bool DroppedSpecifier =
1755 ? diag::note_implicit_param_decl
1756 : diag::note_previous_decl;
1759 SemaRef.
PDiag(NoteID));
1762 << Typo << Ctx << DroppedSpecifier
1764 SemaRef.
PDiag(NoteID));
1772 std::unique_ptr<CorrectionCandidateCallback> CCC,
1777 unsigned diagnostic = diag::err_undeclared_var_use;
1778 unsigned diagnostic_suggest = diag::err_undeclared_var_use_suggest;
1782 diagnostic = diag::err_undeclared_use;
1783 diagnostic_suggest = diag::err_undeclared_use_suggest;
1792 if (isa<CXXRecordDecl>(DC)) {
1793 LookupQualifiedName(R, DC);
1802 bool isDefaultArgument =
1803 !CodeSynthesisContexts.empty() &&
1804 CodeSynthesisContexts.back().Kind ==
1805 CodeSynthesisContext::DefaultFunctionArgumentInstantiation;
1807 bool isInstance = CurMethod &&
1809 DC == CurMethod->
getParent() && !isDefaultArgument;
1814 if (getLangOpts().MSVCCompat)
1815 diagnostic = diag::ext_found_via_dependent_bases_lookup;
1826 Diag(D->getLocation(), diag::note_dependent_var_use);
1832 if (isDefaultArgument && ((*R.begin())->isCXXInstanceMember())) {
1833 Diag(R.getNameLoc(), diag::err_member_call_without_object);
1848 if (getLangOpts().MSVCCompat && isa<FunctionDecl>(DC) &&
1849 cast<FunctionDecl>(DC)->getFriendObjectKind() &&
1860 assert(!ExplicitTemplateArgs &&
1861 "Diagnosing an empty lookup with explicit template args!");
1862 *Out = CorrectTypoDelayed(
1866 diagnostic, diagnostic_suggest);
1868 nullptr, CTK_ErrorRecovery);
1871 }
else if (S && (Corrected =
1873 &SS, std::move(CCC), CTK_ErrorRecovery))) {
1874 std::string CorrectedStr(Corrected.
getAsString(getLangOpts()));
1875 bool DroppedSpecifier =
1879 bool AcceptableWithRecovery =
false;
1880 bool AcceptableWithoutRecovery =
false;
1889 dyn_cast<FunctionTemplateDecl>(CD))
1890 AddTemplateOverloadCandidate(
1893 else if (
FunctionDecl *FD = dyn_cast<FunctionDecl>(CD))
1894 if (!ExplicitTemplateArgs || ExplicitTemplateArgs->
size() == 0)
1898 switch (OCS.BestViableFunction(*
this, R.
getNameLoc(), Best)) {
1900 ND = Best->FoundDecl;
1901 Corrected.setCorrectionDecl(ND);
1905 Corrected.setCorrectionDecl(ND);
1917 Record = cast<CXXRecordDecl>(
1923 AcceptableWithRecovery = isa<ValueDecl>(UnderlyingND) ||
1924 isa<FunctionTemplateDecl>(UnderlyingND);
1930 AcceptableWithoutRecovery =
1931 isa<TypeDecl>(UnderlyingND) || isa<ObjCInterfaceDecl>(UnderlyingND);
1935 AcceptableWithoutRecovery =
true;
1938 if (AcceptableWithRecovery || AcceptableWithoutRecovery) {
1940 ? diag::note_implicit_param_decl
1941 : diag::note_previous_decl;
1943 diagnoseTypo(Corrected, PDiag(diagnostic_suggest) <<
Name,
1944 PDiag(NoteID), AcceptableWithRecovery);
1946 diagnoseTypo(Corrected, PDiag(diag::err_no_member_suggest)
1947 << Name << computeDeclContext(SS,
false)
1948 << DroppedSpecifier << SS.getRange(),
1949 PDiag(NoteID), AcceptableWithRecovery);
1952 return !AcceptableWithRecovery;
1959 if (!SS.isEmpty()) {
1961 << Name << computeDeclContext(SS,
false)
1988 else if (
auto *MD = dyn_cast<CXXMethodDecl>(S.
CurContext))
1996 auto DB = S.
Diag(Loc, diag::ext_undeclared_unqual_id_with_dependent_base);
1997 DB << NameInfo.
getName() << RD;
1999 if (!ThisType.
isNull()) {
2002 Context,
nullptr, ThisType,
true,
2004 nullptr, NameInfo, TemplateArgs);
2021 bool HasTrailingLParen,
bool IsAddressOfOperand,
2022 std::unique_ptr<CorrectionCandidateCallback> CCC,
2023 bool IsInlineAsmIdentifier,
Token *KeywordReplacement) {
2024 assert(!(IsAddressOfOperand && HasTrailingLParen) &&
2025 "cannot be direct & operand and have a trailing lparen");
2034 DecomposeUnqualifiedId(Id, TemplateArgsBuffer, NameInfo, TemplateArgs);
2057 bool DependentID =
false;
2061 }
else if (SS.
isSet()) {
2062 if (
DeclContext *DC = computeDeclContext(SS,
false)) {
2063 if (RequireCompleteDeclContext(SS, DC))
2071 return ActOnDependentIdExpression(SS, TemplateKWLoc, NameInfo,
2072 IsAddressOfOperand, TemplateArgs);
2077 ? LookupObjCImplicitSelfParam : LookupOrdinaryName);
2084 bool MemberOfUnknownSpecialization;
2085 LookupTemplateName(R, S, SS,
QualType(),
false,
2086 MemberOfUnknownSpecialization);
2088 if (MemberOfUnknownSpecialization ||
2090 return ActOnDependentIdExpression(SS, TemplateKWLoc, NameInfo,
2091 IsAddressOfOperand, TemplateArgs);
2093 bool IvarLookupFollowUp = II && !SS.
isSet() && getCurMethodDecl();
2094 LookupParsedName(R, S, &SS, !IvarLookupFollowUp);
2099 return ActOnDependentIdExpression(SS, TemplateKWLoc, NameInfo,
2100 IsAddressOfOperand, TemplateArgs);
2104 if (IvarLookupFollowUp) {
2119 if (R.
empty() && HasTrailingLParen && II && !getLangOpts().CPlusPlus) {
2120 NamedDecl *D = ImplicitlyDefineFunction(NameLoc, *II, S);
2126 bool ADL = UseArgumentDependentLookup(SS, R, HasTrailingLParen);
2128 if (R.
empty() && !ADL) {
2129 if (SS.
isEmpty() && getLangOpts().MSVCCompat) {
2131 TemplateKWLoc, TemplateArgs))
2136 if (IsInlineAsmIdentifier)
2142 auto DefaultValidator = llvm::make_unique<CorrectionCandidateCallback>(
2144 DefaultValidator->IsAddressOfOperand = IsAddressOfOperand;
2145 assert((!CCC || CCC->IsAddressOfOperand == IsAddressOfOperand) &&
2146 "Typo correction callback misconfigured");
2149 CCC->setTypoName(II);
2153 if (DiagnoseEmptyLookup(S, SS, R,
2154 CCC ? std::move(CCC) : std::move(DefaultValidator),
2155 nullptr,
None, &TE)) {
2156 if (TE && KeywordReplacement) {
2157 auto &
State = getTypoExprState(TE);
2158 auto BestTC =
State.Consumer->getNextCorrection();
2159 if (BestTC.isKeyword()) {
2160 auto *II = BestTC.getCorrectionAsIdentifierInfo();
2161 if (
State.DiagHandler)
2162 State.DiagHandler(BestTC);
2164 KeywordReplacement->
setKind(II->getTokenID());
2166 KeywordReplacement->
setLocation(BestTC.getCorrectionRange().getBegin());
2169 clearDelayedTypo(TE);
2172 return (
Expr*)
nullptr;
2174 State.Consumer->resetCorrectionStream();
2179 assert(!R.
empty() &&
2180 "DiagnoseEmptyLookup returned false but added no results");
2187 ExprResult E(LookupInObjCMethod(R, S, Ivar->getIdentifier()));
2197 assert(!R.
empty() || ADL);
2223 if (!R.
empty() && (*R.
begin())->isCXXClassMember()) {
2224 bool MightBeImplicitMember;
2225 if (!IsAddressOfOperand)
2226 MightBeImplicitMember =
true;
2228 MightBeImplicitMember =
false;
2230 MightBeImplicitMember =
false;
2232 MightBeImplicitMember =
true;
2234 MightBeImplicitMember = isa<FieldDecl>(R.
getFoundDecl()) ||
2238 if (MightBeImplicitMember)
2239 return BuildPossibleImplicitMemberExpr(SS, TemplateKWLoc,
2240 R, TemplateArgs, S);
2243 if (TemplateArgs || TemplateKWLoc.
isValid()) {
2251 "There should only be one declaration found.");
2254 return BuildTemplateIdExpr(SS, TemplateKWLoc, R, ADL, TemplateArgs);
2257 return BuildDeclarationNameExpr(SS, R, ADL);
2272 if (RequireCompleteDeclContext(SS, DC))
2276 LookupQualifiedName(R, DC);
2295 unsigned DiagID = diag::err_typename_missing;
2296 if (RecoveryTSI && getLangOpts().MSVCCompat)
2297 DiagID = diag::ext_typename_missing;
2299 auto D =
Diag(Loc, DiagID);
2330 if (!R.
empty() && (*R.
begin())->isCXXClassMember() && !IsAddressOfOperand)
2331 return BuildPossibleImplicitMemberExpr(SS,
2335 return BuildDeclarationNameExpr(SS, R,
false);
2369 LookForIvars =
true;
2370 else if (IsClassMethod)
2371 LookForIvars =
false;
2383 return ExprError(
Diag(Loc, diag::err_ivar_use_in_class_method)
2392 if (DiagnoseUseOfDecl(IV, Loc))
2398 !getLangOpts().DebuggerSupport)
2409 ExprResult SelfExpr = ActOnIdExpression(S, SelfScopeSpec, TemplateKWLoc,
2410 SelfName,
false,
false);
2414 SelfExpr = DefaultLvalueConversion(SelfExpr.
get());
2418 MarkAnyDeclReferenced(Loc, IV,
true);
2422 !IvarBacksCurrentMethodAccessor(IFace, CurMethod, IV))
2430 if (!Diags.isIgnored(diag::warn_arc_repeated_use_of_weak, Loc))
2431 recordUseOfEvaluatedWeak(Result);
2433 if (getLangOpts().ObjCAutoRefCount) {
2434 if (CurContext->isClosure())
2435 Diag(Loc, diag::warn_implicitly_retains_self)
2448 Diag(Loc, diag::warn_ivar_use_hidden) << IV->getDeclName();
2455 return ExprError(
Diag(Loc, diag::err_ivar_use_in_class_method)
2456 << IV->getDeclName());
2459 if (Lookup.
empty() && II && AllowBuiltinCreation) {
2505 bool PointerConversions =
false;
2506 if (isa<FieldDecl>(Member)) {
2512 PointerConversions =
true;
2514 DestType = DestRecordType;
2515 FromRecordType = FromType;
2517 }
else if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Member)) {
2518 if (Method->isStatic())
2521 DestType = Method->getThisType(
Context);
2526 PointerConversions =
true;
2528 FromRecordType = FromType;
2529 DestType = DestRecordType;
2566 if (Qualifier && Qualifier->
getAsType()) {
2568 assert(QType->
isRecordType() &&
"lookup done with non-record type");
2575 if (IsDerivedFrom(FromLoc, FromRecordType, QRecordType)) {
2577 if (CheckDerivedToBaseConversion(FromRecordType, QRecordType,
2578 FromLoc, FromRange, &BasePath))
2581 if (PointerConversions)
2583 From = ImpCastExprToType(From, QType, CK_UncheckedDerivedToBase,
2584 VK, &BasePath).get();
2587 FromRecordType = QRecordType;
2596 bool IgnoreAccess =
false;
2604 assert(isa<UsingShadowDecl>(FoundDecl));
2611 assert(IsDerivedFrom(FromLoc, FromRecordType, URecordType));
2613 if (CheckDerivedToBaseConversion(FromRecordType, URecordType,
2614 FromLoc, FromRange, &BasePath))
2618 if (PointerConversions)
2620 From = ImpCastExprToType(From, UType, CK_UncheckedDerivedToBase,
2621 VK, &BasePath).get();
2623 FromRecordType = URecordType;
2628 IgnoreAccess =
true;
2632 if (CheckDerivedToBaseConversion(FromRecordType, DestRecordType,
2633 FromLoc, FromRange, &BasePath,
2637 return ImpCastExprToType(From, DestType, CK_UncheckedDerivedToBase,
2643 bool HasTrailingLParen) {
2645 if (!HasTrailingLParen)
2653 if (!getLangOpts().CPlusPlus)
2663 if (D->isCXXClassMember())
2672 if (isa<UsingShadowDecl>(D))
2673 D = cast<UsingShadowDecl>(D)->getTargetDecl();
2674 else if (D->getLexicalDeclContext()->isFunctionOrMethod())
2681 if (isa<FunctionDecl>(D)) {
2687 }
else if (!isa<FunctionTemplateDecl>(D))
2703 if (isa<TypedefNameDecl>(D)) {
2708 if (isa<ObjCInterfaceDecl>(D)) {
2713 if (isa<NamespaceDecl>(D)) {
2723 bool AcceptInvalidDecl) {
2761 bool AcceptInvalidDecl) {
2762 assert(D &&
"Cannot refer to a NULL declaration");
2763 assert(!isa<FunctionTemplateDecl>(D) &&
2764 "Cannot refer unambiguously to a function template");
2770 if (
TemplateDecl *Template = dyn_cast<TemplateDecl>(D)) {
2773 Diag(Loc, diag::err_template_decl_ref) << (isa<VarTemplateDecl>(D) ? 1 : 0)
2775 Diag(Template->getLocation(), diag::note_template_decl_here);
2782 Diag(Loc, diag::err_ref_non_value)
2792 if (DiagnoseUseOfDecl(VD, Loc))
2803 if (!indirectField->isCXXClassMember())
2804 return BuildAnonymousStructUnionMemberReference(SS, NameInfo.
getLoc(),
2814 ResolveExceptionSpec(Loc, FPT);
2821 #define ABSTRACT_DECL(kind)
2822 #define VALUE(type, base)
2823 #define DECL(type, base) \
2825 #include "clang/AST/DeclNodes.inc"
2826 llvm_unreachable(
"invalid value decl kind");
2829 case Decl::ObjCAtDefsField:
2830 case Decl::ObjCIvar:
2831 llvm_unreachable(
"forming non-member reference to ivar?");
2835 case Decl::EnumConstant:
2836 case Decl::UnresolvedUsingValue:
2837 case Decl::OMPDeclareReduction:
2846 case Decl::IndirectField:
2848 "building reference to field in C?");
2858 case Decl::NonTypeTemplateParm: {
2873 case Decl::VarTemplateSpecialization:
2874 case Decl::VarTemplatePartialSpecialization:
2875 case Decl::Decomposition:
2876 case Decl::OMPCapturedExpr:
2886 case Decl::ImplicitParam:
2887 case Decl::ParmVar: {
2895 if (!isUnevaluatedContext()) {
2896 QualType CapturedType = getCapturedDeclRefType(cast<VarDecl>(VD), Loc);
2897 if (!CapturedType.
isNull())
2898 type = CapturedType;
2904 case Decl::Binding: {
2910 auto *BD = cast<BindingDecl>(VD);
2911 if (BD->getDeclContext()->isFunctionOrMethod() &&
2912 BD->getDeclContext() != CurContext)
2917 case Decl::Function: {
2918 if (
unsigned BID = cast<FunctionDecl>(VD)->getBuiltinID()) {
2937 if (getLangOpts().CPlusPlus) {
2947 if (!cast<FunctionDecl>(VD)->hasPrototype() &&
2948 isa<FunctionProtoType>(fty))
2957 case Decl::CXXDeductionGuide:
2958 llvm_unreachable(
"building reference to deduction guide");
2960 case Decl::MSProperty:
2964 case Decl::CXXMethod:
2969 = dyn_cast<FunctionProtoType>(VD->
getType()))
2977 if (cast<CXXMethodDecl>(VD)->isStatic()) {
2983 case Decl::CXXConversion:
2984 case Decl::CXXDestructor:
2985 case Decl::CXXConstructor:
2990 return BuildDeclRefExpr(VD, type, valueKind, NameInfo, &SS, FoundD,
2997 Target.resize(CharByteWidth * (Source.size() + 1));
2998 char *ResultPtr = &Target[0];
2999 const llvm::UTF8 *ErrorPtr;
3001 llvm::ConvertUTF8toWide(CharByteWidth, Source, ResultPtr, ErrorPtr);
3004 Target.resize(ResultPtr - &Target[0]);
3010 Decl *currentDecl =
nullptr;
3012 currentDecl = BSI->TheDecl;
3014 currentDecl = LSI->CallOperator;
3016 currentDecl = CSI->TheCapturedDecl;
3018 currentDecl = getCurFunctionOrMethodDecl();
3021 Diag(Loc, diag::ext_predef_outside_function);
3027 if (cast<DeclContext>(currentDecl)->isDependentContext())
3033 unsigned Length = Str.length();
3035 llvm::APInt LengthI(32, Length + 1);
3061 default: llvm_unreachable(
"Unknown simple primary expr!");
3070 return BuildPredefinedExpr(Loc, IT);
3075 bool Invalid =
false;
3076 StringRef ThisTok = PP.getSpelling(Tok, CharBuffer, &Invalid);
3082 if (Literal.hadError())
3086 if (Literal.isWide())
3088 else if (Literal.isUTF16())
3090 else if (Literal.isUTF32())
3092 else if (!getLangOpts().CPlusPlus || Literal.isMultiChar())
3098 if (Literal.isWide())
3100 else if (Literal.isUTF16())
3102 else if (Literal.isUTF32())
3104 else if (Literal.isUTF8())
3110 if (Literal.getUDSuffix().empty())
3120 return ExprError(
Diag(UDSuffixLoc, diag::err_invalid_character_udl));
3138 using llvm::APFloat;
3139 APFloat Val(Format);
3145 if ((result & APFloat::opOverflow) ||
3146 ((result & APFloat::opUnderflow) && Val.isZero())) {
3147 unsigned diagnostic;
3149 if (result & APFloat::opOverflow) {
3150 diagnostic = diag::warn_float_overflow;
3151 APFloat::getLargest(Format).toString(buffer);
3153 diagnostic = diag::warn_float_underflow;
3154 APFloat::getSmallest(Format).toString(buffer);
3157 S.
Diag(Loc, diagnostic)
3159 << StringRef(buffer.data(), buffer.size());
3162 bool isExact = (result == APFloat::opOK);
3167 assert(E &&
"Invalid expression");
3174 Diag(E->
getExprLoc(), diag::err_pragma_loop_invalid_argument_type) << QT;
3178 llvm::APSInt ValueAPS;
3179 ExprResult R = VerifyIntegerConstantExpression(E, &ValueAPS);
3184 bool ValueIsPositive = ValueAPS.isStrictlyPositive();
3185 if (!ValueIsPositive || ValueAPS.getActiveBits() > 31) {
3186 Diag(E->
getExprLoc(), diag::err_pragma_loop_invalid_argument_value)
3187 << ValueAPS.toString(10) << ValueIsPositive;
3198 const char Val = PP.getSpellingOfSingleCharacterNumericConstant(Tok);
3199 return ActOnIntegerConstant(Tok.
getLocation(), Val-
'0');
3207 SpellingBuffer.resize(Tok.
getLength() + 1);
3210 bool Invalid =
false;
3211 StringRef TokSpelling = PP.getSpelling(Tok, SpellingBuffer, &Invalid);
3216 if (Literal.hadError)
3219 if (Literal.hasUDSuffix()) {
3227 return ExprError(
Diag(UDSuffixLoc, diag::err_invalid_numeric_udl));
3230 if (Literal.isFloatingLiteral()) {
3251 LookupResult R(*
this, OpName, UDSuffixLoc, LookupOrdinaryName);
3252 switch (LookupLiteralOperator(UDLScope, R, CookedTy,
3260 if (Literal.isFloatingLiteral()) {
3264 if (Literal.GetIntegerValue(ResultVal))
3270 return BuildLiteralOperatorCall(R, OpNameInfo, Lit, TokLoc);
3277 unsigned Length = Literal.getUDSuffixOffset();
3283 false, StrTy, &TokLoc, 1);
3284 return BuildLiteralOperatorCall(R, OpNameInfo, Lit, TokLoc);
3287 case LOLR_Template: {
3294 bool CharIsUnsigned =
Context.
CharTy->isUnsignedIntegerType();
3295 llvm::APSInt
Value(CharBits, CharIsUnsigned);
3296 for (
unsigned I = 0, N = Literal.getUDSuffixOffset();
I != N; ++
I) {
3297 Value = TokSpelling[
I];
3302 return BuildLiteralOperatorCall(R, OpNameInfo,
None, TokLoc,
3305 case LOLR_StringTemplate:
3306 llvm_unreachable(
"unexpected literal operator lookup result");
3312 if (Literal.isFloatingLiteral()) {
3314 if (Literal.isHalf){
3315 if (getOpenCLOptions().isEnabled(
"cl_khr_fp16"))
3321 }
else if (Literal.isFloat)
3323 else if (Literal.isLong)
3325 else if (Literal.isFloat128)
3333 if (getLangOpts().SinglePrecisionConstants) {
3335 if (BTy->
getKind() != BuiltinType::Float) {
3336 Res = ImpCastExprToType(Res,
Context.
FloatTy, CK_FloatingCast).get();
3338 }
else if (getLangOpts().
OpenCL &&
3339 !getOpenCLOptions().
isEnabled(
"cl_khr_fp64")) {
3342 Res = ImpCastExprToType(Res,
Context.
FloatTy, CK_FloatingCast).get();
3345 }
else if (!Literal.isIntegerLiteral()) {
3351 if (!getLangOpts().
C99 && Literal.isLongLong) {
3353 Diag(Tok.getLocation(),
3354 getLangOpts().CPlusPlus11 ?
3355 diag::warn_cxx98_compat_longlong : diag::ext_cxx11_longlong);
3357 Diag(Tok.getLocation(), diag::ext_c99_longlong);
3362 llvm::APInt ResultVal(MaxWidth, 0);
3364 if (Literal.GetIntegerValue(ResultVal)) {
3366 Diag(Tok.getLocation(), diag::err_integer_literal_too_large)
3370 "long long is not intmax_t?");
3377 bool AllowUnsigned = Literal.isUnsigned || Literal.getRadix() != 10;
3383 if (Literal.MicrosoftInteger) {
3384 if (Literal.MicrosoftInteger == 8 && !Literal.isUnsigned) {
3388 Width = Literal.MicrosoftInteger;
3390 !Literal.isUnsigned);
3394 if (Ty.isNull() && !Literal.isLong && !Literal.isLongLong) {
3399 if (ResultVal.isIntN(IntSize)) {
3401 if (!Literal.isUnsigned && ResultVal[IntSize-1] == 0)
3403 else if (AllowUnsigned)
3410 if (Ty.isNull() && !Literal.isLongLong) {
3414 if (ResultVal.isIntN(LongSize)) {
3416 if (!Literal.isUnsigned && ResultVal[LongSize-1] == 0)
3418 else if (AllowUnsigned)
3422 else if (!getLangOpts().C99 && !getLangOpts().CPlusPlus11) {
3423 const unsigned LongLongSize =
3425 Diag(Tok.getLocation(),
3426 getLangOpts().CPlusPlus
3428 ? diag::warn_old_implicitly_unsigned_long_cxx
3430 ext_old_implicitly_unsigned_long_cxx
3431 : diag::warn_old_implicitly_unsigned_long)
3432 << (LongLongSize > LongSize ? 0
3445 if (ResultVal.isIntN(LongLongSize)) {
3449 if (!Literal.isUnsigned && (ResultVal[LongLongSize-1] == 0 ||
3450 (getLangOpts().MSVCCompat && Literal.isLongLong)))
3452 else if (AllowUnsigned)
3454 Width = LongLongSize;
3461 Diag(Tok.getLocation(), diag::ext_integer_literal_too_large_for_signed);
3466 if (ResultVal.getBitWidth() != Width)
3467 ResultVal = ResultVal.trunc(Width);
3473 if (Literal.isImaginary)
3481 assert(E &&
"ActOnParenExpr() missing expr");
3493 S.
Diag(Loc, diag::err_vecstep_non_scalar_vector_type)
3499 "Scalar types should always be complete");
3515 S.
Diag(Loc, diag::ext_sizeof_alignof_function_type)
3516 << TraitKind << ArgRange;
3523 unsigned DiagID = S.
LangOpts.OpenCL ? diag::err_opencl_sizeof_alignof_type
3524 : diag::ext_sizeof_alignof_void_type;
3525 S.
Diag(Loc, DiagID) << TraitKind << ArgRange;
3539 S.
Diag(Loc, diag::err_sizeof_nonfragile_interface)
3558 if (!ICE || ICE->
getCastKind() != CK_ArrayToPointerDecay)
3594 diag::err_sizeof_alignof_incomplete_type, ExprKind,
3617 Diag(E->
getExprLoc(), diag::warn_side_effects_unevaluated_context);
3625 if (
ParmVarDecl *PVD = dyn_cast<ParmVarDecl>(DeclRef->getFoundDecl())) {
3626 QualType OType = PVD->getOriginalType();
3631 Diag(PVD->getLocation(), diag::note_declared_at);
3696 diag::err_sizeof_alignof_incomplete_type,
3697 ExprKind, ExprRange))
3701 Diag(OpLoc, diag::err_sizeof_alignof_function_type)
3702 << ExprKind << ExprRange;
3721 S.
Diag(E->
getExprLoc(), diag::err_sizeof_alignof_typeof_bitfield)
3727 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
3729 }
else if (
MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
3730 D = ME->getMemberDecl();
3750 if (
FieldDecl *FD = dyn_cast_or_null<FieldDecl>(D)) {
3753 if (!FD->getParent()->isCompleteDefinition()) {
3754 S.
Diag(E->
getExprLoc(), diag::err_alignof_member_of_incomplete_type)
3763 if (!FD->getType()->isReferenceType())
3783 assert(CSI !=
nullptr);
3789 #define TYPE(Class, Base)
3790 #define ABSTRACT_TYPE(Class, Base)
3791 #define NON_CANONICAL_TYPE(Class, Base)
3792 #define DEPENDENT_TYPE(Class, Base) case Type::Class:
3793 #define NON_CANONICAL_UNLESS_DEPENDENT_TYPE(Class, Base)
3794 #include "clang/AST/TypeNodes.def"
3801 case Type::ExtVector:
3804 case Type::Elaborated:
3805 case Type::TemplateSpecialization:
3806 case Type::ObjCObject:
3807 case Type::ObjCInterface:
3808 case Type::ObjCObjectPointer:
3809 case Type::ObjCTypeParam:
3811 llvm_unreachable(
"type class is never variably-modified!");
3812 case Type::Adjusted:
3813 T = cast<AdjustedType>(Ty)->getOriginalType();
3816 T = cast<DecayedType>(Ty)->getPointeeType();
3819 T = cast<PointerType>(Ty)->getPointeeType();
3821 case Type::BlockPointer:
3822 T = cast<BlockPointerType>(Ty)->getPointeeType();
3824 case Type::LValueReference:
3825 case Type::RValueReference:
3826 T = cast<ReferenceType>(Ty)->getPointeeType();
3828 case Type::MemberPointer:
3829 T = cast<MemberPointerType>(Ty)->getPointeeType();
3831 case Type::ConstantArray:
3832 case Type::IncompleteArray:
3834 T = cast<ArrayType>(Ty)->getElementType();
3836 case Type::VariableArray: {
3845 if (
auto LSI = dyn_cast<LambdaScopeInfo>(CSI)) {
3846 CapRecord = LSI->Lambda;
3847 }
else if (
auto CRSI = dyn_cast<CapturedRegionScopeInfo>(CSI)) {
3848 CapRecord = CRSI->TheRecordDecl;
3851 auto ExprLoc = Size->getExprLoc();
3856 nullptr, SizeType,
nullptr,
3859 Field->setImplicit(
true);
3861 Field->setCapturedVLAType(VAT);
3871 case Type::FunctionProto:
3872 case Type::FunctionNoProto:
3873 T = cast<FunctionType>(Ty)->getReturnType();
3877 case Type::UnaryTransform:
3878 case Type::Attributed:
3879 case Type::SubstTemplateTypeParm:
3880 case Type::PackExpansion:
3885 T = cast<TypedefType>(Ty)->desugar();
3887 case Type::Decltype:
3888 T = cast<DecltypeType>(Ty)->desugar();
3891 case Type::DeducedTemplateSpecialization:
3892 T = cast<DeducedType>(Ty)->getDeducedType();
3894 case Type::TypeOfExpr:
3895 T = cast<TypeOfExprType>(Ty)->getUnderlyingExpr()->getType();
3898 T = cast<AtomicType>(Ty)->getValueType();
3928 if (
auto *LSI = dyn_cast<LambdaScopeInfo>(CSI))
3929 DC = LSI->CallOperator;
3930 else if (
auto *CRSI = dyn_cast<CapturedRegionScopeInfo>(CSI))
3931 DC = CRSI->TheCapturedDecl;
3932 else if (
auto *BSI = dyn_cast<BlockScopeInfo>(CSI))
3971 Diag(E->
getExprLoc(), diag::err_sizeof_alignof_typeof_bitfield) << 0;
4026 return CT->getElementType();
4035 if (PR.
get() != V.
get()) {
4041 S.
Diag(Loc, diag::err_realimag_invalid_type) << V.
get()->
getType()
4042 << (IsReal ?
"__real" :
"__imag");
4053 default: llvm_unreachable(
"Unknown unary op!");
4054 case tok::plusplus: Opc = UO_PostInc;
break;
4055 case tok::minusminus: Opc = UO_PostDec;
break;
4061 Input = Result.
get();
4074 !S.
LangOpts.ObjCSubscriptingLegacyRuntime)
4077 S.
Diag(opLoc, diag::err_arithmetic_nonfragile_interface)
4085 if (
auto *MSProp = dyn_cast<MSPropertyRefExpr>(BaseNoParens))
4087 return isa<MSPropertySubscriptExpr>(BaseNoParens);
4099 if (isa<ParenListExpr>(base)) {
4102 base = result.
get();
4110 bool IsMSPropertySubscript =
false;
4113 if (!IsMSPropertySubscript) {
4117 base = result.
get();
4141 if (IsMSPropertySubscript) {
4172 BuiltinType::OMPArraySection)) {
4176 Base = Result.
get();
4185 LowerBound = Result.
get();
4194 Length = Result.
get();
4223 if (Res.isInvalid())
4225 diag::err_omp_typecheck_section_not_integer)
4227 LowerBound = Res.get();
4237 if (Res.isInvalid())
4239 diag::err_omp_typecheck_section_not_integer)
4260 diag::err_omp_section_incomplete_type, Base))
4264 llvm::APSInt LowerBoundValue;
4268 if (LowerBoundValue.isNegative()) {
4269 Diag(LowerBound->
getExprLoc(), diag::err_omp_section_not_subset_of_array)
4277 llvm::APSInt LengthValue;
4281 if (LengthValue.isNegative()) {
4282 Diag(Length->
getExprLoc(), diag::err_omp_section_length_negative)
4283 << LengthValue.toString(10,
true)
4288 }
else if (ColonLoc.
isValid() &&
4294 Diag(ColonLoc, diag::err_omp_section_length_undefined)
4300 BuiltinType::OMPArraySection)) {
4304 Base = Result.
get();
4314 Expr *LHSExp = Base;
4332 LHSExp = Result.
get();
4337 RHSExp = Result.
get();
4345 Expr *BaseExpr, *IndexExpr;
4379 Diag(LLoc, diag::err_subscript_nonfragile_interface)
4391 ResultType = VTy->getElementType();
4401 CK_ArrayToPointerDecay).
get();
4407 }
else if (RHSTy->isArrayType()) {
4412 CK_ArrayToPointerDecay).
get();
4419 return ExprError(
Diag(LLoc, diag::err_typecheck_subscript_value)
4424 return ExprError(
Diag(LLoc, diag::err_typecheck_subscript_not_integer)
4444 Diag(LLoc, diag::ext_gnu_subscript_void_type)
4452 diag::err_subscript_incomplete_type, BaseExpr))
4466 diag::err_use_of_default_argument_to_function_declared_later) <<
4469 diag::note_default_argument_declared_here);
4485 if (Inst.isInvalid())
4487 if (Inst.isAlreadyInstantiating()) {
4488 Diag(Param->
getLocStart(), diag::err_recursive_default_argument) << FD;
4516 Result = InitSeq.Perform(*
this, Entity, Kind, ResultE);
4528 L->DefaultArgumentInstantiated(Param);
4534 Diag(Param->
getLocStart(), diag::err_recursive_default_argument) << FD;
4546 if (
auto Init = dyn_cast<ExprWithCleanups>(Param->
getInit())) {
4554 assert(!Init->getNumObjects() &&
4555 "default argument expression has capturing blocks?");
4577 if (dyn_cast_or_null<CXXConstructorDecl>(FDecl))
4582 if (
CXXMethodDecl *Method = dyn_cast_or_null<CXXMethodDecl>(FDecl))
4583 if (Method->isInstance())
4598 FunctionName(FuncName) {}
4600 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
4624 llvm::make_unique<FunctionCallCCC>(
S, FuncName.getAsIdentifierInfo(),
4627 if (
NamedDecl *ND = Corrected.getFoundDecl()) {
4628 if (Corrected.isOverloaded()) {
4638 ND = Best->FoundDecl;
4639 Corrected.setCorrectionDecl(ND);
4645 ND = ND->getUnderlyingDecl();
4646 if (isa<ValueDecl>(ND) || isa<FunctionTemplateDecl>(ND))
4665 bool IsExecConfig) {
4675 bool Invalid =
false;
4684 if (Args.size() < NumParams) {
4685 if (Args.size() < MinArgs) {
4690 ? diag::err_typecheck_call_too_few_args_suggest
4691 : diag::err_typecheck_call_too_few_args_at_least_suggest;
4693 << static_cast<unsigned>(Args.size())
4698 ? diag::err_typecheck_call_too_few_args_one
4699 : diag::err_typecheck_call_too_few_args_at_least_one)
4703 ? diag::err_typecheck_call_too_few_args
4704 : diag::err_typecheck_call_too_few_args_at_least)
4705 << FnKind << MinArgs << static_cast<unsigned>(Args.size())
4709 if (!TC && FDecl && !FDecl->
getBuiltinID() && !IsExecConfig)
4720 if (Args.size() > NumParams) {
4726 ? diag::err_typecheck_call_too_many_args_suggest
4727 : diag::err_typecheck_call_too_many_args_at_most_suggest;
4729 << static_cast<unsigned>(Args.size())
4731 }
else if (NumParams == 1 && FDecl &&
4733 Diag(Args[NumParams]->getLocStart(),
4734 MinArgs == NumParams
4735 ? diag::err_typecheck_call_too_many_args_one
4736 : diag::err_typecheck_call_too_many_args_at_most_one)
4740 Args.back()->getLocEnd());
4742 Diag(Args[NumParams]->getLocStart(),
4743 MinArgs == NumParams
4744 ? diag::err_typecheck_call_too_many_args
4745 : diag::err_typecheck_call_too_many_args_at_most)
4746 << FnKind << NumParams << static_cast<unsigned>(Args.size())
4749 Args.back()->getLocEnd());
4752 if (!TC && FDecl && !FDecl->
getBuiltinID() && !IsExecConfig)
4765 Proto, 0, Args, AllArgs, CallType);
4768 unsigned TotalNumArgs = AllArgs.size();
4769 for (
unsigned i = 0; i < TotalNumArgs; ++i)
4770 Call->
setArg(i, AllArgs[i]);
4780 bool IsListInitialization) {
4782 bool Invalid =
false;
4785 for (
unsigned i = FirstParam; i < NumParams; i++) {
4790 if (ArgIx < Args.size()) {
4791 Arg = Args[ArgIx++];
4795 diag::err_call_incomplete_argument, Arg))
4799 bool CFAudited =
false;
4801 FDecl && FDecl->
hasAttr<CFAuditedTransferAttr>() &&
4802 (!Param || !Param->
hasAttr<CFConsumedAttr>()))
4805 FDecl && FDecl->
hasAttr<CFAuditedTransferAttr>() &&
4806 (!Param || !Param->
hasAttr<CFConsumedAttr>()))
4820 Entity,
SourceLocation(), Arg, IsListInitialization, AllowExplicit);
4826 assert(Param &&
"can't use default arguments without a known callee");
4839 CheckArrayAccess(Arg);
4844 AllArgs.push_back(Arg);
4853 for (
Expr *A : Args.slice(ArgIx)) {
4857 AllArgs.push_back(arg.
get());
4862 for (
Expr *A : Args.slice(ArgIx)) {
4865 AllArgs.push_back(Arg.
get());
4870 for (
Expr *A : Args.slice(ArgIx))
4871 CheckArrayAccess(A);
4879 TL = DTL.getOriginalLoc();
4882 << ATL.getLocalSourceRange();
4896 const Expr *ArgExpr) {
4924 Diag(CallLoc, diag::warn_static_array_too_small)
4941 if (!placeholder)
return false;
4943 switch (placeholder->
getKind()) {
4945 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
4946 case BuiltinType::Id:
4947 #include "clang/Basic/OpenCLImageTypes.def"
4948 #define PLACEHOLDER_TYPE(ID, SINGLETON_ID)
4949 #define BUILTIN_TYPE(ID, SINGLETON_ID) case BuiltinType::ID:
4950 #include "clang/AST/BuiltinTypes.def"
4955 case BuiltinType::Overload:
4960 case BuiltinType::ARCUnbridgedCast:
4964 case BuiltinType::PseudoObject:
4969 case BuiltinType::UnknownAny:
4973 case BuiltinType::BoundMember:
4974 case BuiltinType::BuiltinFn:
4975 case BuiltinType::OMPArraySection:
4979 llvm_unreachable(
"bad builtin type kind");
4987 bool hasInvalid =
false;
4988 for (
size_t i = 0, e = args.size(); i != e; i++) {
4991 if (result.
isInvalid()) hasInvalid =
true;
4992 else args[i] = result.
get();
4993 }
else if (hasInvalid) {
5022 bool NeedsNewDecl =
false;
5035 if (!ParamType->isPointerType() ||
5036 ParamType.getQualifiers().hasAddressSpace() ||
5039 OverloadParams.push_back(ParamType);
5043 NeedsNewDecl =
true;
5056 OverloadParams, EPI);
5067 FT = cast<FunctionProtoType>(OverloadTy);
5068 for (
unsigned i = 0, e = FT->
getNumParams(); i != e; ++i) {
5075 Params.push_back(Parm);
5077 OverloadDecl->setParams(Params);
5078 return OverloadDecl;
5096 isa<CXXMethodDecl>(Callee)
5097 ? diag::err_ovl_no_viable_member_function_in_call
5098 : diag::err_ovl_no_viable_function_in_call)
5101 diag::note_ovl_candidate_disabled_by_function_cond_attr)
5102 <<
Attr->getCond()->getSourceRange() <<
Attr->getMessage();
5112 Expr *ExecConfig,
bool IsExecConfig) {
5123 if (isa<CXXPseudoDestructorExpr>(Fn)) {
5124 if (!ArgExprs.empty()) {
5129 ArgExprs.back()->getLocEnd()));
5143 bool Dependent =
false;
5152 Context, Fn, cast<CallExpr>(ExecConfig), ArgExprs,
5189 Scope, Fn, ULE, LParenLoc, ArgExprs, RParenLoc, ExecConfig,
5205 bool CallingNDeclIndirectly =
false;
5207 if (
UnaryOperator *UnOp = dyn_cast<UnaryOperator>(NakedFn)) {
5208 if (UnOp->getOpcode() == UO_AddrOf) {
5209 CallingNDeclIndirectly =
true;
5214 if (isa<DeclRefExpr>(NakedFn)) {
5215 NDecl = cast<DeclRefExpr>(NakedFn)->getDecl();
5230 }
else if (isa<MemberExpr>(NakedFn))
5231 NDecl = cast<MemberExpr>(NakedFn)->getMemberDecl();
5233 if (
FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(NDecl)) {
5234 if (CallingNDeclIndirectly &&
5246 ExecConfig, IsExecConfig);
5262 diag::err_invalid_astype_of_different_size)
5293 Expr *Config,
bool IsExecConfig) {
5294 FunctionDecl *FDecl = dyn_cast_or_null<FunctionDecl>(NDecl);
5295 unsigned BuiltinID = (FDecl ? FDecl->
getBuiltinID() : 0);
5298 if (FDecl && FDecl->
hasAttr<AnyX86InterruptAttr>()) {
5308 if (Caller->hasAttr<ARMInterruptAttr>()) {
5310 if (VFP && (!FDecl || !FDecl->
hasAttr<ARMInterruptAttr>()))
5311 Diag(Fn->
getExprLoc(), diag::warn_arm_interrupt_calling_convention);
5321 CK_BuiltinFnToFnPtr).
get();
5334 cast<CallExpr>(Config), Args,
5349 if (!TheCall)
return Result;
5355 return CheckBuiltinFunctionCall(FDecl, BuiltinID, TheCall);
5364 return ExprError(
Diag(LParenLoc, diag::err_typecheck_call_not_function)
5379 return ExprError(
Diag(LParenLoc, diag::err_typecheck_call_not_function)
5386 if (FDecl && !FDecl->
hasAttr<CUDAGlobalAttr>())
5387 return ExprError(
Diag(LParenLoc,diag::err_kern_call_not_global_function)
5392 return ExprError(
Diag(LParenLoc, diag::err_kern_type_not_void_return)
5396 if (FDecl && FDecl->
hasAttr<CUDAGlobalAttr>())
5397 return ExprError(
Diag(LParenLoc, diag::err_global_call_not_config)
5417 assert(isa<FunctionNoProtoType>(FuncT) &&
"Unknown FunctionType!");
5426 Diag(RParenLoc, diag::warn_call_wrong_number_of_arguments)
5437 for (
unsigned i = 0, e = Args.size(); i != e; i++) {
5438 Expr *Arg = Args[i];
5440 if (Proto && i < Proto->getNumParams()) {
5445 if (ArgE.isInvalid())
5448 Arg = ArgE.getAs<
Expr>();
5461 diag::err_call_incomplete_argument, Arg))
5468 if (
CXXMethodDecl *Method = dyn_cast_or_null<CXXMethodDecl>(FDecl))
5469 if (!Method->isStatic())
5470 return ExprError(
Diag(LParenLoc, diag::err_member_call_without_object)
5479 if (CheckFunctionCall(FDecl, TheCall, Proto))
5483 return CheckBuiltinFunctionCall(FDecl, BuiltinID, TheCall);
5485 if (CheckPointerCall(NDecl, TheCall, Proto))
5488 if (CheckOtherCall(TheCall, Proto))
5498 assert(Ty &&
"ActOnCompoundLiteral(): missing type");
5499 assert(InitExpr &&
"ActOnCompoundLiteral(): missing expression");
5516 diag::err_illegal_decl_array_incomplete_type,
5521 return ExprError(
Diag(LParenLoc, diag::err_variable_object_no_init)
5525 diag::err_typecheck_decl_incomplete_type,
5540 LiteralExpr = Result.
get();
5576 VK, LiteralExpr, isFileScope));
5584 for (
unsigned I = 0,
E = InitArgList.size();
I !=
E; ++
I) {
5585 if (InitArgList[
I]->getType()->isNonOverloadPlaceholderType()) {
5592 InitArgList[
I] = result.
get();
5614 CK_ARCExtendBlockObject, E.
get(),
5627 return CK_BlockPointerToObjCPointerCast;
5630 return CK_CPointerToObjCPointerCast;
5647 llvm_unreachable(
"member pointer type in C");
5656 if (SrcAS != DestAS)
5657 return CK_AddressSpaceConversion;
5662 ? CK_BitCast : CK_AnyPointerToBlockPointerCast);
5667 return CK_CPointerToObjCPointerCast;
5669 return CK_BlockPointerToObjCPointerCast;
5671 return CK_PointerToBoolean;
5673 return CK_PointerToIntegral;
5678 llvm_unreachable(
"illegal cast from pointer");
5680 llvm_unreachable(
"Should have returned before this");
5690 return CK_NullToPointer;
5691 return CK_IntegralToPointer;
5693 return CK_IntegralToBoolean;
5695 return CK_IntegralCast;
5697 return CK_IntegralToFloating;
5702 return CK_IntegralRealToComplex;
5706 CK_IntegralToFloating);
5707 return CK_FloatingRealToComplex;
5709 llvm_unreachable(
"member pointer type in C");
5711 llvm_unreachable(
"Should have returned before this");
5716 return CK_FloatingCast;
5718 return CK_FloatingToBoolean;
5720 return CK_FloatingToIntegral;
5725 return CK_FloatingRealToComplex;
5729 CK_FloatingToIntegral);
5730 return CK_IntegralRealToComplex;
5734 llvm_unreachable(
"valid float->pointer cast?");
5736 llvm_unreachable(
"member pointer type in C");
5738 llvm_unreachable(
"Should have returned before this");
5743 return CK_FloatingComplexCast;
5745 return CK_FloatingComplexToIntegralComplex;
5749 return CK_FloatingComplexToReal;
5751 return CK_FloatingCast;
5754 return CK_FloatingComplexToBoolean;
5758 CK_FloatingComplexToReal);
5759 return CK_FloatingToIntegral;
5763 llvm_unreachable(
"valid complex float->pointer cast?");
5765 llvm_unreachable(
"member pointer type in C");
5767 llvm_unreachable(
"Should have returned before this");
5772 return CK_IntegralComplexToFloatingComplex;
5774 return CK_IntegralComplexCast;
5778 return CK_IntegralComplexToReal;
5780 return CK_IntegralCast;
5783 return CK_IntegralComplexToBoolean;
5787 CK_IntegralComplexToReal);
5788 return CK_IntegralToFloating;
5792 llvm_unreachable(
"valid complex int->pointer cast?");
5794 llvm_unreachable(
"member pointer type in C");
5796 llvm_unreachable(
"Should have returned before this");
5799 llvm_unreachable(
"Unhandled scalar cast");
5806 len = vecType->getNumElements();
5807 eltType = vecType->getElementType();
5839 uint64_t srcLen, destLen;
5850 return (srcLen * srcEltSize == destLen * destEltSize);
5865 assert(VectorTy->
isVectorType() &&
"Not a vector type!");
5871 diag::err_invalid_conversion_between_vectors :
5872 diag::err_invalid_conversion_between_vector_and_integer)
5873 << VectorTy << Ty << R;
5876 diag::err_invalid_conversion_between_vector_and_scalar)
5877 << VectorTy << Ty << R;
5886 if (DestElemTy == SplattedExpr->
getType())
5887 return SplattedExpr;
5900 CK_BooleanToSignedIntegral);
5901 SplattedExpr = CastExprRes.
get();
5902 CK = CK_IntegralToFloating;
5904 CK = CK_BooleanToSignedIntegral;
5911 SplattedExpr = CastExprRes.
get();
5926 if (SrcTy->isVectorType()) {
5930 Diag(R.
getBegin(),diag::err_invalid_conversion_between_ext_vectors)
5931 << DestTy << SrcTy << R;
5941 if (SrcTy->isPointerType())
5943 diag::err_invalid_conversion_between_vector_and_scalar)
5944 << DestTy << SrcTy << R;
5946 Kind = CK_VectorSplat;
5955 "ActOnCastExpr(): missing type or expr");
5969 CastExpr = Res.
get();
5977 bool isVectorLiteral =
false;
5985 if (PLE && PLE->getNumExprs() == 0) {
5986 Diag(PLE->getExprLoc(), diag::err_altivec_empty_initializer);
5989 if (PE || PLE->getNumExprs() == 1) {
5992 isVectorLiteral =
true;
5995 isVectorLiteral =
true;
6000 if (isVectorLiteral)
6006 if (isa<ParenListExpr>(CastExpr)) {
6009 CastExpr = Result.
get();
6028 assert((isa<ParenListExpr>(E) || isa<ParenExpr>(E)) &&
6029 "Expected paren or paren list expression");
6036 LiteralLParenLoc = PE->getLParenLoc();
6037 LiteralRParenLoc = PE->getRParenLoc();
6038 exprs = PE->getExprs();
6039 numExprs = PE->getNumExprs();
6041 LiteralLParenLoc = cast<ParenExpr>(
E)->getLParen();
6042 LiteralRParenLoc = cast<ParenExpr>(
E)->getRParen();
6043 subExpr = cast<ParenExpr>(
E)->getSubExpr();
6063 if (numExprs == 1) {
6072 else if (numExprs < numElems) {
6074 diag::err_incorrect_number_of_vector_initializers);
6078 initExprs.append(exprs, exprs + numExprs);
6095 initExprs.append(exprs, exprs + numExprs);
6100 initExprs, LiteralRParenLoc);
6136 Expr *NullExpr = LHSExpr;
6137 Expr *NonPointerExpr = RHSExpr;
6144 NonPointerExpr = LHSExpr;
6166 Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands_null)
6167 << NonPointerExpr->
getType() << DiagType
6178 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_nonfloat)
6186 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_scalar)
6237 bool IsBlockPointer =
false;
6241 IsBlockPointer =
true;
6259 unsigned ResultAddrSpace = 0;
6266 ResultAddrSpace = LAddrSpace;
6268 ResultAddrSpace = RAddrSpace;
6271 diag::err_typecheck_op_on_nonoverlapping_address_space_pointers)
6279 auto LHSCastKind = CK_BitCast, RHSCastKind = CK_BitCast;
6294 LHSCastKind = LAddrSpace == ResultAddrSpace
6296 : CK_AddressSpaceConversion;
6297 RHSCastKind = RAddrSpace == ResultAddrSpace
6299 : CK_AddressSpaceConversion;
6309 if (CompositeTy.
isNull()) {
6325 S.
Diag(Loc, diag::ext_typecheck_cond_incompatible_pointers)
6335 QualType ResultTy = [&, ResultAddrSpace]() {
6341 .withCVRQualifiers(MergedCVRQual);
6370 S.
Diag(Loc, diag::err_typecheck_cond_incompatible_operands)
6423 bool IsIntFirstExpr) {
6428 Expr *Expr1 = IsIntFirstExpr ? Int.
get() : PointerExpr;
6429 Expr *Expr2 = IsIntFirstExpr ? PointerExpr : Int.
get();
6431 S.
Diag(Loc, diag::ext_typecheck_cond_pointer_integer_mismatch)
6435 CK_IntegralToPointer);
6469 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_int_float)
6475 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_int_float)
6481 if (LHSType == RHSType)
6490 return handleIntegerConversion<doIntegralCast, doIntegralCast>
6491 (
S, LHS, RHS, LHSType, RHSType,
false);
6525 llvm::raw_svector_ostream OS(Str);
6526 OS <<
"(vector of " << NumElements <<
" '" << EleTyName <<
"' values)";
6527 S.
Diag(QuestionLoc, diag::err_conditional_vector_element_size)
6528 << CondTy << OS.str();
6549 S.
Diag(QuestionLoc, diag::err_typecheck_cond_expect_nonfloat)
6567 S.
Diag(QuestionLoc, diag::err_conditional_vector_size)
6568 << CondTy << VecResTy;
6573 QualType RVE = RV->getElementType();
6576 S.
Diag(QuestionLoc, diag::err_conditional_vector_element_size)
6577 << CondTy << VecResTy;
6621 if (
const CallExpr *CE = dyn_cast<CallExpr>(E)) {
6622 QualType Ty = CE->getCallee()->getType();
6684 diag::err_typecheck_cond_incompatible_operands) << LHSTy << RHSTy
6709 if (LHSRT->getDecl() == RHSRT->getDecl())
6732 if (!compositeType.
isNull())
6733 return compositeType;
6762 Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands)
6834 if (!(compositeType =
6852 Diag(QuestionLoc, diag::ext_typecheck_cond_incompatible_operands)
6863 return compositeType;
6870 Diag(QuestionLoc, diag::err_cond_voidptr_arc) << LHSTy << RHSTy
6890 Diag(QuestionLoc, diag::err_cond_voidptr_arc) << LHSTy << RHSTy
6917 Self.
Diag(Loc, Note)
6922 Self.
Diag(Loc, Note) << ParenRange;
6946 *Opcode = OP->getOpcode();
6947 *RHSExprs = OP->getRHS();
6954 if (Call->getNumArgs() != 2)
6960 if (OO < OO_Plus || OO > OO_Arrow ||
6961 OO == OO_PlusPlus || OO == OO_MinusMinus)
6967 *RHSExprs = Call->getArg(1);
6984 return OP->isComparisonOp() || OP->isLogicalOp();
6986 return OP->getOpcode() == UO_LNot;
7013 Self.
Diag(OpLoc, diag::warn_precedence_conditional)
7018 Self.
PDiag(diag::note_precedence_silence)
7023 Self.
PDiag(diag::note_precedence_conditional_first),
7034 auto GetNullability = [&Ctx](
QualType Ty) {
7041 auto LHSKind = GetNullability(LHSTy), RHSKind = GetNullability(RHSTy);
7049 MergedKind = RHSKind;
7056 MergedKind = RHSKind;
7058 MergedKind = LHSKind;
7064 if (GetNullability(ResTy) == MergedKind)
7101 CondExpr = CondResult.
get();
7102 LHSExpr = LHSResult.
get();
7103 RHSExpr = RHSResult.
get();
7109 Expr *commonExpr =
nullptr;
7111 commonExpr = CondExpr;
7118 commonExpr = result.
get();
7132 commonExpr = commonRes.
get();
7140 LHSExpr = CondExpr = opaqueValue;
7146 ExprResult Cond = CondExpr, LHS = LHSExpr, RHS = RHSExpr;
7148 VK, OK, QuestionLoc);
7156 CheckBoolLikeConversion(Cond.
get(), QuestionLoc);
7164 RHS.get(), result, VK, OK);
7167 commonExpr, opaqueValue, Cond.
get(), LHS.get(), RHS.get(), QuestionLoc,
7178 assert(LHSType.
isCanonical() &&
"LHS not canonicalized!");
7179 assert(RHSType.
isCanonical() &&
"RHS not canonicalized!");
7182 const Type *lhptee, *rhptee;
7184 std::tie(lhptee, lhq) =
7185 cast<PointerType>(LHSType)->getPointeeType().split().asPair();
7186 std::tie(rhptee, rhq) =
7187 cast<PointerType>(RHSType)->getPointeeType().split().asPair();
7213 && (lhptee->isVoidType() || rhptee->isVoidType()))
7228 if (lhptee->isVoidType()) {
7229 if (rhptee->isIncompleteOrObjectType())
7233 assert(rhptee->isFunctionType());
7237 if (rhptee->isVoidType()) {
7238 if (lhptee->isIncompleteOrObjectType())
7242 assert(lhptee->isFunctionType());
7253 if (lhptee->isCharType())
7255 else if (lhptee->hasSignedIntegerRepresentation())
7258 if (rhptee->isCharType())
7260 else if (rhptee->hasSignedIntegerRepresentation())
7263 if (ltrans == rtrans) {
7277 if (isa<PointerType>(lhptee) && isa<PointerType>(rhptee)) {
7279 lhptee = cast<PointerType>(lhptee)->getPointeeType().getTypePtr();
7280 rhptee = cast<PointerType>(rhptee)->getPointeeType().getTypePtr();
7281 }
while (isa<PointerType>(lhptee) && isa<PointerType>(rhptee));
7283 if (lhptee == rhptee)
7303 assert(LHSType.
isCanonical() &&
"LHS not canonicalized!");
7304 assert(RHSType.
isCanonical() &&
"RHS not canonicalized!");
7309 lhptee = cast<BlockPointerType>(LHSType)->getPointeeType();
7310 rhptee = cast<BlockPointerType>(RHSType)->getPointeeType();
7319 Qualifiers LQuals = lhptee.getLocalQualifiers();
7320 Qualifiers RQuals = rhptee.getLocalQualifiers();
7325 if (LQuals != RQuals)
7354 assert(LHSType.
isCanonical() &&
"LHS was not canonicalized!");
7355 assert(RHSType.
isCanonical() &&
"RHS was not canonicalized!");
7428 if (LHSType == RHSType) {
7435 if (
const AtomicType *AtomicTy = dyn_cast<AtomicType>(LHSType)) {
7440 if (Kind != CK_NoOp && ConvertRHS)
7442 Kind = CK_NonAtomicToAtomic;
7455 Kind = CK_LValueBitCast;
7470 Kind = CK_VectorSplat;
7526 if (
const PointerType *LHSPointer = dyn_cast<PointerType>(LHSType)) {
7528 if (isa<PointerType>(RHSType)) {
7529 unsigned AddrSpaceL = LHSPointer->getPointeeType().getAddressSpace();
7531 Kind = AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion : CK_BitCast;
7537 Kind = CK_IntegralToPointer;
7543 if (isa<ObjCObjectPointerType>(RHSType)) {
7545 if (LHSPointer->getPointeeType()->isVoidType()) {
7564 if (LHSPointer->getPointeeType()->isVoidType()) {
7565 unsigned AddrSpaceL = LHSPointer->getPointeeType().getAddressSpace();
7570 AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion : CK_BitCast;
7579 if (isa<BlockPointerType>(LHSType)) {
7588 Kind = AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion : CK_BitCast;
7594 Kind = CK_IntegralToPointer;
7600 Kind = CK_AnyPointerToBlockPointerCast;
7606 if (RHSPT->getPointeeType()->isVoidType()) {
7607 Kind = CK_AnyPointerToBlockPointerCast;
7615 if (isa<ObjCObjectPointerType>(LHSType)) {
7621 if (
getLangOpts().allowsNonTrivialObjCLifetimeQualifiers() &&
7630 Kind = CK_IntegralToPointer;
7636 if (isa<PointerType>(RHSType)) {
7637 Kind = CK_CPointerToObjCPointerCast;
7659 Kind = CK_BlockPointerToObjCPointerCast;
7667 if (isa<PointerType>(RHSType)) {
7670 Kind = CK_PointerToBoolean;
7676 Kind = CK_PointerToIntegral;
7684 if (isa<ObjCObjectPointerType>(RHSType)) {
7687 Kind = CK_PointerToBoolean;
7693 Kind = CK_PointerToIntegral;
7701 if (isa<TagType>(LHSType) && isa<TagType>(RHSType)) {
7709 Kind = CK_IntToOCLSampler;
7726 Initializer->
setType(UnionType);
7751 for (
auto *it : UD->
fields()) {
7752 if (it->getType()->isPointerType()) {
7791 bool DiagnoseCFAudited,
7795 assert((ConvertRHS || !Diagnose) &&
"can't indicate whether we diagnosed");
7801 ExprResult &RHS = ConvertRHS ? CallerRHS : LocalRHS;
7843 RHS.
get(), LHSType,
false, DAP))
7855 if (Diagnose || ConvertRHS) {
7880 if (Diagnose && isa<ObjCProtocolExpr>(PRE)) {
7905 if (
getLangOpts().allowsNonTrivialObjCLifetimeQualifiers() &&
7907 Diagnose, DiagnoseCFAudited) !=
ACR_okay) {
7931 Diag(Loc, diag::err_typecheck_invalid_operands)
7948 if (!(LHSNatVec && RHSNatVec)) {
7949 Expr *Vector = LHSNatVec ? LHS.
get() : RHS.
get();
7950 Expr *NonVector = !LHSNatVec ? LHS.
get() : RHS.
get();
7951 Diag(Loc, diag::err_typecheck_logical_vector_expr_gnu_cpp_restrict)
7957 Diag(Loc, diag::err_typecheck_logical_vector_expr_gnu_cpp_restrict)
7989 DiagID = diag::err_opencl_scalar_type_rank_greater_than_vector_type;
7994 scalarCast = CK_IntegralCast;
7999 DiagID = diag::err_opencl_scalar_type_rank_greater_than_vector_type;
8002 scalarCast = CK_FloatingCast;
8005 scalarCast = CK_IntegralToFloating;
8039 unsigned NumBits = IntSigned
8040 ? (Result.isNegative() ? Result.getMinSignedBits()
8041 : Result.getActiveBits())
8042 : Result.getActiveBits();
8049 return (IntSigned != OtherIntSigned &&
8077 llvm::APFloat::rmTowardZero);
8080 bool Ignored =
false;
8081 Float.convertToInteger(ConvertBack, llvm::APFloat::rmNearestTiesToEven,
8083 if (Result != ConvertBack)
8089 unsigned FloatPrec = llvm::APFloat::semanticsPrecision(
8091 if (Bits > FloatPrec)
8108 assert(!isa<ExtVectorType>(VT) &&
8109 "ExtVectorTypes should not be handled here!");
8136 ScalarCast = CK_IntegralCast;
8142 llvm::APFloat
Result(0.0);
8145 if (!CstScalar && Order < 0)
8151 bool Truncated =
false;
8153 llvm::APFloat::rmNearestTiesToEven, &Truncated);
8158 ScalarCast = CK_FloatingCast;
8163 ScalarCast = CK_IntegralToFloating;
8170 if (ScalarCast != CK_NoOp)
8180 bool AllowBoolConversions) {
8181 if (!IsCompAssign) {
8197 assert(LHSVecType || RHSVecType);
8201 if (!AllowBothBool &&
8211 if (LHSVecType && RHSVecType &&
8213 if (isa<ExtVectorType>(LHSVecType)) {
8226 if (AllowBoolConversions && LHSVecType && RHSVecType &&
8236 if (!IsCompAssign &&
8239 RHSVecType->getElementType()->isIntegerType()) {
8247 unsigned DiagID = diag::err_typecheck_vector_not_convertable;
8249 if (isa<ExtVectorType>(LHSVecType)) {
8260 if (isa<ExtVectorType>(RHSVecType)) {
8262 LHSType, RHSVecType->getElementType(),
8275 QualType VecType = LHSVecType ? LHSType : RHSType;
8276 const VectorType *VT = LHSVecType ? LHSVecType : RHSVecType;
8277 QualType OtherType = LHSVecType ? RHSType : LHSType;
8278 ExprResult *OtherExpr = LHSVecType ? &RHS : &LHS;
8283 if (!IsCompAssign) {
8302 if ((!RHSVecType && !RHSType->
isRealType()) ||
8304 Diag(Loc, diag::err_typecheck_vector_not_convertable_non_scalar)
8305 << LHSType << RHSType
8315 RHSVecType && isa<ExtVectorType>(RHSVecType) &&
8316 LHSVecType && isa<ExtVectorType>(LHSVecType)) {
8317 Diag(Loc, diag::err_opencl_implicit_vector_conversion) << LHSType
8326 if ((RHSVecType && !isa<ExtVectorType>(RHSVecType)) ||
8327 (LHSVecType && !isa<ExtVectorType>(LHSVecType))) {
8328 QualType Scalar = LHSVecType ? RHSType : LHSType;
8329 QualType Vector = LHSVecType ? LHSType : RHSType;
8330 unsigned ScalarOrVector = LHSVecType && RHSVecType ? 1 : 0;
8332 diag::err_typecheck_vector_not_convertable_implict_truncation)
8333 << ScalarOrVector << Scalar << Vector;
8340 << LHSType << RHSType
8360 if ((!LHSNull && !RHSNull) || NonNullType->isBlockPointerType() ||
8361 NonNullType->isMemberPointerType() || NonNullType->isFunctionType())
8367 S.
Diag(Loc, diag::warn_null_in_arithmetic_operation)
8375 if (LHSNull == RHSNull || NonNullType->isAnyPointerType() ||
8376 NonNullType->canDecayToPointerType())
8379 S.
Diag(Loc, diag::warn_null_in_comparison_operation)
8380 << LHSNull << NonNullType
8388 llvm::APSInt RHSValue;
8392 S.
PDiag(diag::warn_remainder_division_by_zero)
8398 bool IsCompAssign,
bool IsDiv) {
8447 ? diag::err_typecheck_pointer_arith_void_type
8448 : diag::ext_gnu_void_ptr)
8457 ? diag::err_typecheck_pointer_arith_void_type
8458 : diag::ext_gnu_void_ptr)
8468 ? diag::err_typecheck_pointer_arith_function_type
8469 : diag::ext_gnu_ptr_func_arith)
8483 ? diag::err_typecheck_pointer_arith_function_type
8484 : diag::ext_gnu_ptr_func_arith)
8497 ResType = ResAtomicType->getValueType();
8502 diag::err_typecheck_arithmetic_incomplete_type,
8518 ResType = ResAtomicType->getValueType();
8550 if (!isLHSPointer && !isRHSPointer)
return true;
8552 QualType LHSPointeeTy, RHSPointeeTy;
8557 if (S.
getLangOpts().OpenCL && isLHSPointer && isRHSPointer) {
8562 diag::err_typecheck_op_on_nonoverlapping_address_space_pointers)
8570 bool isLHSVoidPtr = isLHSPointer && LHSPointeeTy->
isVoidType();
8571 bool isRHSVoidPtr = isRHSPointer && RHSPointeeTy->
isVoidType();
8572 if (isLHSVoidPtr || isRHSVoidPtr) {
8580 bool isLHSFuncPtr = isLHSPointer && LHSPointeeTy->
isFunctionType();
8581 bool isRHSFuncPtr = isRHSPointer && RHSPointeeTy->
isFunctionType();
8582 if (isLHSFuncPtr || isRHSFuncPtr) {
8604 Expr* IndexExpr = RHSExpr;
8607 IndexExpr = LHSExpr;
8610 bool IsStringPlusInt = StrExpr &&
8612 if (!IsStringPlusInt || IndexExpr->isValueDependent())
8616 if (IndexExpr->EvaluateAsInt(index, Self.
getASTContext())) {
8617 unsigned StrLenWithNull = StrExpr->
getLength() + 1;
8618 if (index.isNonNegative() &&
8619 index <= llvm::APSInt(llvm::APInt(index.getBitWidth(), StrLenWithNull),
8620 index.isUnsigned()))
8625 Self.
Diag(OpLoc, diag::warn_string_plus_int)
8626 << DiagRange << IndexExpr->IgnoreImpCasts()->getType();
8629 if (IndexExpr == RHSExpr) {
8631 Self.
Diag(OpLoc, diag::note_string_plus_scalar_silence)
8636 Self.
Diag(OpLoc, diag::note_string_plus_scalar_silence);
8642 const Expr *StringRefExpr = LHSExpr;
8648 StringRefExpr = RHSExpr;
8651 if (!CharExpr || !StringRefExpr)
8668 if (!CharType->isAnyCharacterType() &&
8669 CharType->isIntegerType() &&
8671 Self.
Diag(OpLoc, diag::warn_string_plus_char)
8672 << DiagRange << Ctx.
CharTy;
8674 Self.
Diag(OpLoc, diag::warn_string_plus_char)
8675 << DiagRange << CharExpr->
getType();
8681 Self.
Diag(OpLoc, diag::note_string_plus_scalar_silence)
8686 Self.
Diag(OpLoc, diag::note_string_plus_scalar_silence);
8695 S.
Diag(Loc, diag::err_typecheck_sub_ptr_compatible)
8709 LHS, RHS, Loc, CompLHSTy,
8712 if (CompLHSTy) *CompLHSTy = compType;
8721 if (Opc == BO_Add) {
8728 if (CompLHSTy) *CompLHSTy = compType;
8738 isObjCPointer =
false;
8740 isObjCPointer =
true;
8742 std::swap(PExp, IExp);
8744 isObjCPointer =
false;
8746 isObjCPointer =
true;
8753 if (!IExp->getType()->isIntegerType())
8763 CheckArrayAccess(PExp, IExp);
8787 LHS, RHS, Loc, CompLHSTy,
8790 if (CompLHSTy) *CompLHSTy = compType;
8802 if (CompLHSTy) *CompLHSTy = compType;
8821 CheckArrayAccess(LHS.
get(), RHS.
get(),
nullptr,
8824 if (CompLHSTy) *CompLHSTy = LHS.
get()->
getType();
8857 if (ElementSize.
isZero()) {
8858 Diag(Loc,diag::warn_sub_ptr_zero_size_types)
8864 if (CompLHSTy) *CompLHSTy = LHS.
get()->
getType();
8874 return ET->getDecl()->isScoped();
8892 if (Right.isNegative()) {
8894 S.
PDiag(diag::warn_shift_negative)
8898 llvm::APInt LeftBits(Right.getBitWidth(),
8900 if (Right.uge(LeftBits)) {
8902 S.
PDiag(diag::warn_shift_gt_typewidth)
8923 S.
PDiag(diag::warn_shift_lhs_negative)
8928 llvm::APInt ResultBits =
8929 static_cast<llvm::APInt&
>(Right) + Left.getMinSignedBits();
8930 if (LeftBits.uge(ResultBits))
8932 llvm::APSInt
Result = Left.extend(ResultBits.getLimitedValue());
8933 Result = Result.shl(Right);
8938 Result.toString(HexResult, 16,
false,
true);
8944 if (LeftBits == ResultBits - 1) {
8945 S.
Diag(Loc, diag::warn_shift_result_sets_sign_bit)
8946 << HexResult << LHSType
8951 S.
Diag(Loc, diag::warn_shift_result_gt_typewidth)
8952 << HexResult.str() << Result.getMinSignedBits() << LHSType
8964 S.
Diag(Loc, diag::err_shift_rhs_only_vector)
8970 if (!IsCompAssign) {
8990 if (!LHSEleType->isIntegerType()) {
8991 S.
Diag(Loc, diag::err_typecheck_expect_int)
8996 if (!RHSEleType->isIntegerType()) {
8997 S.
Diag(Loc, diag::err_typecheck_expect_int)
9006 if (LHSEleType != RHSEleType) {
9008 LHSEleType = RHSEleType;
9014 }
else if (RHSVecTy) {
9019 S.
Diag(Loc, diag::err_typecheck_vector_lengths_not_equal)
9027 if (LHSBT != RHSBT &&
9029 S.
Diag(Loc, diag::warn_typecheck_vector_element_sizes_not_equal)
9047 bool IsCompAssign) {
9077 if (IsCompAssign) LHS = OldLHS;
9105 if (isa<ClassTemplateSpecializationDecl>(DC))
9108 return FD->isFunctionTemplateSpecialization();
9135 S.
Diag(Loc, diag::warn_comparison_of_mixed_enum_types)
9136 << LHSStrippedType << RHSStrippedType
9144 S.
Diag(Loc, IsError ? diag::err_typecheck_comparison_of_distinct_pointers
9145 : diag::ext_typecheck_comparison_of_distinct_pointers)
9187 S.
Diag(Loc, IsError ? diag::err_typecheck_comparison_of_fptr_to_void
9188 : diag::ext_typecheck_comparison_of_fptr_to_void)
9195 case Stmt::ObjCArrayLiteralClass:
9196 case Stmt::ObjCDictionaryLiteralClass:
9197 case Stmt::ObjCStringLiteralClass:
9198 case Stmt::ObjCBoxedExprClass:
9257 case Stmt::ObjCStringLiteralClass:
9260 case Stmt::ObjCArrayLiteralClass:
9263 case Stmt::ObjCDictionaryLiteralClass:
9266 case Stmt::BlockExprClass:
9268 case Stmt::ObjCBoxedExprClass: {
9271 case Stmt::IntegerLiteralClass:
9272 case Stmt::FloatingLiteralClass:
9273 case Stmt::CharacterLiteralClass:
9274 case Stmt::ObjCBoolLiteralExprClass:
9275 case Stmt::CXXBoolLiteralExprClass:
9278 case Stmt::ImplicitCastExprClass: {
9279 CastKind CK = cast<CastExpr>(Inner)->getCastKind();
9281 if (CK == CK_IntegralToBoolean || CK == CK_IntegralCast)
9300 Literal = LHS.
get();
9303 Literal = RHS.
get();
9319 llvm_unreachable(
"Unknown Objective-C object literal kind");
9323 S.
Diag(Loc, diag::warn_objc_string_literal_comparison)
9326 S.
Diag(Loc, diag::warn_objc_literal_comparison)
9336 S.
Diag(Loc, diag::note_objc_literal_comparison_isequal)
9349 if (!UO || UO->
getOpcode() != UO_LNot)
return;
9359 bool IsBitwiseOp = Opc == BO_And || Opc == BO_Or || Opc == BO_Xor;
9361 << Loc << IsBitwiseOp;
9389 return DR->getDecl();
9391 if (Ivar->isFreeIvar())
9392 return Ivar->getDecl();
9394 if (
MemberExpr* Mem = dyn_cast<MemberExpr>(E)) {
9395 if (Mem->isImplicitAccess())
9396 return Mem->getMemberDecl();
9404 bool IsRelational) {
9448 char always_evals_to;
9451 always_evals_to = 0;
9454 always_evals_to = 1;
9458 always_evals_to = 2;
9463 << always_evals_to);
9466 if (isa<CastExpr>(LHSStripped))
9468 if (isa<CastExpr>(RHSStripped))
9473 Expr *literalString =
nullptr;
9474 Expr *literalStringStripped =
nullptr;
9475 if ((isa<StringLiteral>(LHSStripped) || isa<ObjCEncodeExpr>(LHSStripped)) &&
9478 literalString = LHS.
get();
9479 literalStringStripped = LHSStripped;
9480 }
else if ((isa<StringLiteral>(RHSStripped) ||
9481 isa<ObjCEncodeExpr>(RHSStripped)) &&
9484 literalString = RHS.
get();
9485 literalStringStripped = RHSStripped;
9488 if (literalString) {
9490 PDiag(diag::warn_stringcompare)
9491 << isa<ObjCEncodeExpr>(literalStringStripped)
9513 CheckFloatComparison(Loc, LHS.
get(), RHS.
get());
9526 if (!IsRelational && LHSIsNull != RHSIsNull) {
9527 bool IsEquality = Opc == BO_EQ;
9545 if (!IsRelational &&
9568 (IsRelational ? 2 : 1) &&
9591 Diag(Loc, diag::ext_typecheck_ordered_comparison_of_function_pointers)
9595 }
else if (!IsRelational &&
9599 && !LHSIsNull && !RHSIsNull)
9606 if (LCanPointeeTy != RCanPointeeTy) {
9612 diag::err_typecheck_op_on_nonoverlapping_address_space_pointers)
9613 << LHSType << RHSType << 0
9619 CastKind Kind = AddrSpaceL != AddrSpaceR ? CK_AddressSpaceConversion
9621 if (LHSIsNull && !RHSIsNull)
9633 if (!IsRelational && LHSIsNull && RHSIsNull) {
9666 if (isa<FunctionDecl>(DC))
9668 if (
auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(DC)) {
9669 if (CTSD->isInStdNamespace() &&
9670 llvm::StringSwitch<bool>(CTSD->getName())
9671 .Cases(
"less",
"less_equal",
"greater",
"greater_equal",
true)
9685 if (!IsRelational &&
9707 if (!LHSIsNull && !RHSIsNull &&
9709 Diag(Loc, diag::err_typecheck_comparison_of_distinct_blocks)
9721 if (!LHSIsNull && !RHSIsNull) {
9726 Diag(Loc, diag::err_typecheck_comparison_of_distinct_blocks)
9730 if (LHSIsNull && !RHSIsNull)
9733 : CK_AnyPointerToBlockPointerCast);
9737 : CK_AnyPointerToBlockPointerCast);
9747 bool RPtrToVoid = RPT ? RPT->getPointeeType()->isVoidType() :
false;
9749 if (!LPtrToVoid && !RPtrToVoid &&
9754 if (LHSIsNull && !RHSIsNull) {
9760 RPT ? CK_BitCast :CK_CPointerToObjCPointerCast);
9769 LPT ? CK_BitCast :CK_CPointerToObjCPointerCast);
9781 if (LHSIsNull && !RHSIsNull)
9790 unsigned DiagID = 0;
9791 bool isError =
false;
9800 isError ? diag::err_typecheck_ordered_comparison_of_pointer_and_zero
9801 : diag::ext_typecheck_ordered_comparison_of_pointer_and_zero;
9804 DiagID = diag::err_typecheck_comparison_of_pointer_integer;
9806 }
else if (IsRelational)
9807 DiagID = diag::ext_typecheck_ordered_comparison_of_pointer_integer;
9809 DiagID = diag::ext_typecheck_comparison_of_pointer_integer;
9821 LHSIsNull ? CK_NullToPointer : CK_IntegralToPointer);
9824 RHSIsNull ? CK_NullToPointer : CK_IntegralToPointer);
9829 if (!IsRelational && RHSIsNull
9834 if (!IsRelational && LHSIsNull
9841 if (LHSIsNull && RHSType->
isQueueT()) {
9846 if (LHSType->
isQueueT() && RHSIsNull) {
9864 if (isa<ExtVectorType>(VTy)) {
9874 "Unhandled vector element size in vector compare");
9891 "Unhandled vector element size in vector compare");
9902 bool IsRelational) {
9927 if (DRL->getDecl() == DRR->getDecl())
9929 PDiag(diag::warn_comparison_always)
9938 CheckFloatComparison(Loc, LHS.
get(), RHS.
get());
9973 Opc == BO_AndAssign || Opc == BO_OrAssign || Opc == BO_XorAssign;
9991 if (LHSResult.
isInvalid() || RHSResult.isInvalid())
9993 LHS = LHSResult.
get();
9994 RHS = RHSResult.
get();
10025 (Result != 0 && Result != 1)) {
10026 Diag(Loc, diag::warn_logical_instead_of_bitwise)
10028 << (Opc == BO_LAnd ?
"&&" :
"||");
10030 Diag(Loc, diag::note_logical_instead_of_bitwise_change_operator)
10031 << (Opc == BO_LAnd ?
"&" :
"|")
10034 Opc == BO_LAnd ?
"&" :
"|");
10035 if (Opc == BO_LAnd)
10037 Diag(Loc, diag::note_logical_instead_of_bitwise_remove_constant)
10093 if (!ME)
return false;
10097 if (!Base)
return false;
10118 assert(var->
hasLocalStorage() &&
"capture added 'const' to non-local?");
10126 if (
auto *FD = dyn_cast<FunctionDecl>(DC))
10168 bool DiagnosticEmitted =
false;
10172 bool IsDereference =
false;
10173 bool NextIsDereference =
false;
10177 IsDereference = NextIsDereference;
10180 if (
const MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
10181 NextIsDereference = ME->isArrow();
10182 const ValueDecl *VD = ME->getMemberDecl();
10183 if (
const FieldDecl *Field = dyn_cast<FieldDecl>(VD)) {
10185 if (Field->isMutable()) {
10186 assert(DiagnosticEmitted &&
"Expected diagnostic not emitted.");
10191 if (!DiagnosticEmitted) {
10192 S.
Diag(Loc, diag::err_typecheck_assign_const)
10193 << ExprRange << ConstMember <<
false << Field
10194 << Field->getType();
10195 DiagnosticEmitted =
true;
10198 << ConstMember <<
false << Field << Field->getType()
10199 << Field->getSourceRange();
10203 }
else if (
const VarDecl *VDecl = dyn_cast<VarDecl>(VD)) {
10204 if (VDecl->getType().isConstQualified()) {
10205 if (!DiagnosticEmitted) {
10206 S.
Diag(Loc, diag::err_typecheck_assign_const)
10207 << ExprRange << ConstMember <<
true << VDecl
10208 << VDecl->getType();
10209 DiagnosticEmitted =
true;
10212 << ConstMember <<
true << VDecl << VDecl->getType()
10213 << VDecl->getSourceRange();
10223 if (
const CallExpr *CE = dyn_cast<CallExpr>(E)) {
10227 if (!DiagnosticEmitted) {
10228 S.
Diag(Loc, diag::err_typecheck_assign_const) << ExprRange
10229 << ConstFunction << FD;
10230 DiagnosticEmitted =
true;
10233 diag::note_typecheck_assign_const)
10237 }
else if (
const DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
10239 if (
const ValueDecl *VD = DRE->getDecl()) {
10241 if (!DiagnosticEmitted) {
10242 S.
Diag(Loc, diag::err_typecheck_assign_const)
10243 << ExprRange << ConstVariable << VD << VD->getType();
10244 DiagnosticEmitted =
true;
10246 S.
Diag(VD->getLocation(), diag::note_typecheck_assign_const)
10247 << ConstVariable << VD << VD->getType() << VD->getSourceRange();
10250 }
else if (isa<CXXThisExpr>(E)) {
10252 if (
const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(DC)) {
10253 if (MD->isConst()) {
10254 if (!DiagnosticEmitted) {
10255 S.
Diag(Loc, diag::err_typecheck_assign_const) << ExprRange
10256 << ConstMethod << MD;
10257 DiagnosticEmitted =
true;
10259 S.
Diag(MD->getLocation(), diag::note_typecheck_assign_const)
10260 << ConstMethod << MD << MD->getSourceRange();
10266 if (DiagnosticEmitted)
10270 S.
Diag(Loc, diag::err_typecheck_assign_const) << ExprRange << ConstUnknown;
10288 unsigned DiagID = 0;
10289 bool NeedType =
false;
10296 DiagID = diag::err_block_decl_ref_not_modifiable_lvalue;
10298 DiagID = diag::err_lambda_decl_ref_not_modifiable_lvalue;
10306 if (declRef && isa<VarDecl>(declRef->
getDecl())) {
10319 ? diag::err_typecheck_arc_assign_self_class_method
10320 : diag::err_typecheck_arc_assign_self;
10324 DiagID = diag::err_typecheck_arr_assign_enumeration;
10327 if (Loc != OrigLoc)
10350 DiagID = diag::err_typecheck_array_not_modifiable_lvalue;
10354 DiagID = diag::err_typecheck_non_object_not_modifiable_lvalue;
10358 DiagID = diag::err_typecheck_lvalue_casts_not_supported;
10361 llvm_unreachable(
"did not take early return for MLV_Valid");
10365 DiagID = diag::err_typecheck_expression_not_modifiable_lvalue;
10370 diag::err_typecheck_incomplete_type_not_modifiable_lvalue,
E);
10372 DiagID = diag::err_typecheck_duplicate_vector_components_not_mlvalue;
10375 llvm_unreachable(
"readonly properties should be processed differently");
10377 DiagID = diag::err_readonly_message_assignment;
10380 DiagID = diag::err_no_subobject_property_setting;
10385 if (Loc != OrigLoc)
10400 if (ML && MR && ML->
getMemberDecl() == MR->getMemberDecl()) {
10401 if (isa<CXXThisExpr>(ML->
getBase()) && isa<CXXThisExpr>(MR->getBase()))
10402 Sema.
Diag(Loc, diag::warn_identity_field_assign) << 0;
10408 if (OL && OR && OL->
getDecl() == OR->getDecl()) {
10411 if (RL && RR && RL->
getDecl() == RR->getDecl())
10412 Sema.
Diag(Loc, diag::warn_identity_field_assign) << 1;
10434 Diag(Loc, diag::err_opencl_half_load_store) << 1
10440 if (CompoundType.
isNull()) {
10459 Diag(Loc, diag::err_objc_object_assignment)
10466 RHSCheck = ICE->getSubExpr();
10467 if (
UnaryOperator *UO = dyn_cast<UnaryOperator>(RHSCheck)) {
10468 if ((UO->getOpcode() == UO_Plus ||
10469 UO->getOpcode() == UO_Minus) &&
10470 Loc.
isFileID() && UO->getOperatorLoc().isFileID() &&
10476 UO->getSubExpr()->getLocStart().
isFileID()) {
10477 Diag(Loc, diag::warn_not_compound_assign)
10478 << (UO->getOpcode() == UO_Plus ?
"+" :
"-")
10479 <<
SourceRange(UO->getOperatorLoc(), UO->getOperatorLoc());
10539 if (
const CastExpr *CE = dyn_cast<CastExpr>(E)) {
10540 if (CE->getCastKind() == CK_ToVoid) {
10566 const unsigned ForIncrementFlags =
10570 if ((ScopeFlags & ForIncrementFlags) == ForIncrementFlags ||
10571 (ScopeFlags & ForInitFlags) == ForInitFlags)
10576 while (
const BinaryOperator *BO = dyn_cast<BinaryOperator>(LHS)) {
10577 if (BO->getOpcode() != BO_Comma)
10579 LHS = BO->getRHS();
10586 Diag(Loc, diag::warn_comma_operator);
10590 LangOpts.CPlusPlus ?
"static_cast<void>("
10622 diag::err_incomplete_type);
10637 bool IsInc,
bool IsPrefix) {
10646 ResType = ResAtomicType->getValueType();
10648 assert(!ResType.isNull() &&
"no type for increment/decrement expression");
10650 if (S.
getLangOpts().CPlusPlus && ResType->isBooleanType()) {
10658 : diag::warn_increment_bool)
10660 }
else if (S.
getLangOpts().CPlusPlus && ResType->isEnumeralType()) {
10662 S.
Diag(OpLoc, diag::err_increment_decrement_enum) << IsInc << ResType;
10664 }
else if (ResType->isRealType()) {
10666 }
else if (ResType->isPointerType()) {
10670 }
else if (ResType->isObjCObjectPointerType()) {
10676 }
else if (ResType->isAnyComplexType()) {
10678 S.
Diag(OpLoc, diag::ext_integer_increment_complex)
10680 }
else if (ResType->isPlaceholderType()) {
10685 }
else if (S.
getLangOpts().AltiVec && ResType->isVectorType()) {
10687 }
else if (S.
getLangOpts().ZVector && ResType->isVectorType() &&
10688 (ResType->getAs<
VectorType>()->getVectorKind() !=
10691 }
else if(S.
getLangOpts().OpenCL && ResType->isVectorType() &&
10695 S.
Diag(OpLoc, diag::err_typecheck_illegal_increment_decrement)
10712 return ResType.getUnqualifiedType();
10731 case Stmt::DeclRefExprClass:
10732 return cast<DeclRefExpr>(
E)->getDecl();
10733 case Stmt::MemberExprClass:
10737 if (cast<MemberExpr>(E)->isArrow())
10741 case Stmt::ArraySubscriptExprClass: {
10744 Expr*
Base = cast<ArraySubscriptExpr>(
E)->getBase();
10746 if (ICE->getSubExpr()->getType()->isArrayType())
10751 case Stmt::UnaryOperatorClass: {
10763 case Stmt::ParenExprClass:
10765 case Stmt::ImplicitCastExprClass:
10777 AO_Vector_Element = 1,
10778 AO_Property_Expansion = 2,
10779 AO_Register_Variable = 3,
10800 if (PTy->getKind() == BuiltinType::Overload) {
10802 if (!isa<OverloadExpr>(E)) {
10803 assert(cast<UnaryOperator>(E)->
getOpcode() == UO_AddrOf);
10804 Diag(OpLoc, diag::err_typecheck_invalid_lvalue_addrof_addrof_function)
10810 if (isa<UnresolvedMemberExpr>(Ovl))
10812 Diag(OpLoc, diag::err_invalid_form_pointer_member_function)
10820 if (PTy->getKind() == BuiltinType::UnknownAny)
10823 if (PTy->getKind() == BuiltinType::BoundMember) {
10824 Diag(OpLoc, diag::err_invalid_form_pointer_member_function)
10843 Diag(op->
getExprLoc(), diag::err_opencl_taking_function_address);
10850 if (uOp->getOpcode() == UO_Deref)
10853 return uOp->getSubExpr()->getType();
10860 if (
auto *FD = dyn_cast_or_null<FunctionDecl>(dcl))
10866 unsigned AddressOfError = AO_No_Error;
10871 : diag::ext_typecheck_addrof_temporary)
10878 }
else if (isa<ObjCSelectorExpr>(op)) {
10885 if (!isa<DeclRefExpr>(op)) {
10886 Diag(OpLoc, diag::err_invalid_form_pointer_member_function)
10894 if (OrigOp.
get() != DRE) {
10895 Diag(OpLoc, diag::err_parens_pointer_member_function)
10900 if (MD->getParent()->getName().empty())
10901 Diag(OpLoc, diag::err_unqualified_pointer_member_function)
10905 StringRef Qual = (MD->getParent()->getName() +
"::").toStringRef(Str);
10906 Diag(OpLoc, diag::err_unqualified_pointer_member_function)
10913 if (isa<CXXDestructorDecl>(MD))
10927 if (isa<PseudoObjectExpr>(op)) {
10928 AddressOfError = AO_Property_Expansion;
10930 Diag(OpLoc, diag::err_typecheck_invalid_lvalue_addrof)
10937 AddressOfError = AO_Bit_Field;
10940 AddressOfError = AO_Vector_Element;
10944 if (
const VarDecl *vd = dyn_cast<VarDecl>(dcl)) {
10949 AddressOfError = AO_Register_Variable;
10951 }
else if (isa<MSPropertyDecl>(dcl)) {
10952 AddressOfError = AO_Property_Expansion;
10953 }
else if (isa<FunctionTemplateDecl>(dcl)) {
10955 }
else if (isa<FieldDecl>(dcl) || isa<IndirectFieldDecl>(dcl)) {
10959 if (isa<DeclRefExpr>(op) && cast<DeclRefExpr>(op)->getQualifier()) {
10964 diag::err_cannot_form_pointer_to_member_of_reference_type)
10969 while (cast<RecordDecl>(Ctx)->isAnonymousStructOrUnion())
10981 }
else if (!isa<FunctionDecl>(dcl) && !isa<NonTypeTemplateParmDecl>(dcl) &&
10982 !isa<BindingDecl>(dcl))
10983 llvm_unreachable(
"Unknown/unexpected decl type");
10986 if (AddressOfError != AO_No_Error) {
11002 CheckAddressOfPackedMember(op);
11018 if (!FD->hasAttr<NonNullAttr>() && !Param->
hasAttr<NonNullAttr>())
11021 if (!FD->ModifiedNonNullParams.count(Param))
11022 FD->ModifiedNonNullParams.insert(Param);
11032 if (ConvResult.isInvalid())
11034 Op = ConvResult.get();
11038 if (isa<CXXReinterpretCastExpr>(Op)) {
11054 if (PR.
get() != Op)
11059 S.
Diag(OpLoc, diag::err_typecheck_indirection_requires_pointer)
11074 S.
Diag(OpLoc, diag::ext_typecheck_indirection_through_void_pointer)
11090 default: llvm_unreachable(
"Unknown binop!");
11091 case tok::periodstar: Opc = BO_PtrMemD;
break;
11092 case tok::arrowstar: Opc = BO_PtrMemI;
break;
11093 case tok::star: Opc = BO_Mul;
break;
11094 case tok::slash: Opc = BO_Div;
break;
11095 case tok::percent: Opc = BO_Rem;
break;
11096 case tok::plus: Opc = BO_Add;
break;
11097 case tok::minus: Opc = BO_Sub;
break;
11098 case tok::lessless: Opc = BO_Shl;
break;
11099 case tok::greatergreater: Opc = BO_Shr;
break;
11100 case tok::lessequal: Opc = BO_LE;
break;
11101 case tok::less: Opc = BO_LT;
break;
11102 case tok::greaterequal: Opc = BO_GE;
break;
11103 case tok::greater: Opc = BO_GT;
break;
11104 case tok::exclaimequal: Opc = BO_NE;
break;
11105 case tok::equalequal: Opc = BO_EQ;
break;
11106 case tok::amp: Opc = BO_And;
break;
11107 case tok::caret: Opc = BO_Xor;
break;
11108 case tok::pipe: Opc = BO_Or;
break;
11109 case tok::ampamp: Opc = BO_LAnd;
break;
11110 case tok::pipepipe: Opc = BO_LOr;
break;
11111 case tok::equal: Opc = BO_Assign;
break;
11112 case tok::starequal: Opc = BO_MulAssign;
break;
11113 case tok::slashequal: Opc = BO_DivAssign;
break;
11114 case tok::percentequal: Opc = BO_RemAssign;
break;
11115 case tok::plusequal: Opc = BO_AddAssign;
break;
11116 case tok::minusequal: Opc = BO_SubAssign;
break;
11117 case tok::lesslessequal: Opc = BO_ShlAssign;
break;
11118 case tok::greatergreaterequal: Opc = BO_ShrAssign;
break;
11119 case tok::ampequal: Opc = BO_AndAssign;
break;
11120 case tok::caretequal: Opc = BO_XorAssign;
break;
11121 case tok::pipeequal: Opc = BO_OrAssign;
break;
11122 case tok::comma: Opc = BO_Comma;
break;
11131 default: llvm_unreachable(
"Unknown unary op!");
11132 case tok::plusplus: Opc = UO_PreInc;
break;
11133 case tok::minusminus: Opc = UO_PreDec;
break;
11134 case tok::amp: Opc = UO_AddrOf;
break;
11135 case tok::star: Opc = UO_Deref;
break;
11136 case tok::plus: Opc = UO_Plus;
break;
11137 case tok::minus: Opc = UO_Minus;
break;
11138 case tok::tilde: Opc = UO_Not;
break;
11139 case tok::exclaim: Opc = UO_LNot;
break;
11140 case tok::kw___real: Opc = UO_Real;
break;
11141 case tok::kw___imag: Opc = UO_Imag;
break;
11142 case tok::kw___extension__: Opc = UO_Extension;
break;
11160 if (!LHSDeclRef || !RHSDeclRef ||
11162 RHSDeclRef->getLocation().isMacroID())
11167 cast<ValueDecl>(RHSDeclRef->getDecl()->getCanonicalDecl());
11168 if (LHSDecl != RHSDecl)
11173 if (RefTy->getPointeeType().isVolatileQualified())
11176 S.
Diag(OpLoc, diag::warn_self_assignment)
11188 const Expr *ObjCPointerExpr =
nullptr, *OtherExpr =
nullptr;
11193 ObjCPointerExpr = LHS;
11197 ObjCPointerExpr = RHS;
11205 if (ObjCPointerExpr && isa<IntegerLiteral>(OtherExpr->IgnoreParenCasts())) {
11206 unsigned Diag = diag::warn_objc_pointer_masking;
11215 if (SelArg0.startswith(
"performSelector"))
11216 Diag = diag::warn_objc_pointer_masking_performSelector;
11219 S.
Diag(OpLoc, Diag)
11227 if (
auto *DRE = dyn_cast<DeclRefExpr>(E))
11228 return DRE->getDecl();
11229 if (
auto *ME = dyn_cast<MemberExpr>(E))
11230 return ME->getMemberDecl();
11231 if (
auto *IRE = dyn_cast<ObjCIvarRefExpr>(E))
11232 return IRE->getDecl();
11254 ExprResult Init = InitSeq.Perform(*
this, Entity, Kind, RHSExpr);
11257 RHSExpr = Init.
get();
11274 if (Opc != BO_Assign)
11280 if (!LHS.
isUsable() || !RHS.isUsable())
11291 if (BO_Assign == Opc)
11292 Diag(OpLoc, diag::err_opencl_atomic_init) << 0 << SR;
11317 if (!ResultTy.
isNull()) {
11326 Opc == BO_PtrMemI);
11370 Opc == BO_DivAssign);
11371 CompLHSTy = CompResultTy;
11377 CompLHSTy = CompResultTy;
11394 CompLHSTy = CompResultTy;
11404 CompLHSTy = CompResultTy;
11411 VK = RHS.get()->getValueKind();
11412 OK = RHS.get()->getObjectKind();
11420 CheckArrayAccess(LHS.
get());
11421 CheckArrayAccess(RHS.get());
11427 if (ObjectSetClass && isa<ObjCIsaExpr>(LHS.
get())) {
11441 if (CompResultTy.
isNull())
11450 LHS.
get(), RHS.get(), Opc, ResultTy, VK, OK, CompLHSTy, CompResultTy,
11466 bool isRightComp = RHSBO && RHSBO->isComparisonOp();
11467 if (isLeftComp == isRightComp)
11472 bool isLeftBitwise = LHSBO && LHSBO->
isBitwiseOp();
11473 bool isRightBitwise = RHSBO && RHSBO->isBitwiseOp();
11474 if (isLeftBitwise || isRightBitwise)
11480 StringRef OpStr = isLeftComp ? LHSBO->
getOpcodeStr() : RHSBO->getOpcodeStr();
11485 Self.
Diag(OpLoc, diag::warn_precedence_bitwise_rel)
11488 Self.
PDiag(diag::note_precedence_silence) << OpStr,
11491 Self.
PDiag(diag::note_precedence_bitwise_first)
11506 Self.
PDiag(diag::note_precedence_silence)
11531 if (Bop->getOpcode() == BO_LAnd) {
11538 }
else if (Bop->getOpcode() == BO_LOr) {
11539 if (
BinaryOperator *RBop = dyn_cast<BinaryOperator>(Bop->getRHS())) {
11542 if (RBop->getOpcode() == BO_LAnd &&
EvaluatesAsTrue(S, RBop->getRHS()))
11553 if (Bop->getOpcode() == BO_LAnd) {
11570 if (Bop->isBitwiseOp() && Bop->getOpcode() < Opc) {
11571 S.
Diag(Bop->getOperatorLoc(), diag::warn_bitwise_op_in_bitwise_op)
11573 << Bop->getSourceRange() << OpLoc;
11575 S.
PDiag(diag::note_precedence_silence)
11576 << Bop->getOpcodeStr(),
11577 Bop->getSourceRange());
11585 if (Bop->getOpcode() == BO_Add || Bop->getOpcode() == BO_Sub) {
11586 StringRef Op = Bop->getOpcodeStr();
11587 S.
Diag(Bop->getOperatorLoc(), diag::warn_addition_in_bitshift)
11588 << Bop->getSourceRange() << OpLoc << Shift << Op;
11590 S.
PDiag(diag::note_precedence_silence) << Op,
11591 Bop->getSourceRange());
11607 if (Kind != OO_LessLess && Kind != OO_GreaterGreater)
11610 S.
Diag(OpLoc, diag::warn_overloaded_shift_in_comparison)
11612 << (Kind == OO_LessLess);
11614 S.
PDiag(diag::note_precedence_silence)
11615 << (Kind == OO_LessLess ?
"<<" :
">>"),
11618 S.
PDiag(diag::note_evaluate_comparison_first),
11633 if ((Opc == BO_Or || Opc == BO_Xor) &&
11641 if (Opc == BO_LOr && !OpLoc.
isMacroID()) {
11647 || Opc == BO_Shr) {
11664 assert(LHSExpr &&
"ActOnBinOp(): missing left expression");
11665 assert(RHSExpr &&
"ActOnBinOp(): missing right expression");
11670 return BuildBinOp(S, TokLoc, Opc, LHSExpr, RHSExpr);
11684 if (Sc && OverOp !=
OO_None && OverOp != OO_Equal)
11705 if (pty->getKind() == BuiltinType::PseudoObject &&
11710 if (
getLangOpts().CPlusPlus && pty->getKind() == BuiltinType::Overload) {
11718 RHSExpr = resolvedRHS.
get();
11732 (pty->getKind() == BuiltinType::BoundMember ||
11733 pty->getKind() == BuiltinType::Overload)) {
11735 if (OE && !OE->hasTemplateKeyword() && !OE->hasExplicitTemplateArgs() &&
11736 std::any_of(OE->decls_begin(), OE->decls_end(), [](
NamedDecl *ND) {
11737 return isa<FunctionTemplateDecl>(ND);
11739 Diag(OE->getQualifier() ? OE->getQualifierLoc().getBeginLoc()
11740 : OE->getNameLoc(),
11741 diag::err_template_kw_missing)
11742 << OE->getName().getAsString() <<
"";
11749 LHSExpr = LHS.
get();
11756 if (Opc == BO_Assign && pty->getKind() == BuiltinType::Overload) {
11772 RHSExpr = resolvedRHS.
get();
11807 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
11819 Opc == UO_PreInc ||
11821 Opc == UO_PreInc ||
11854 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
11867 Diag(OpLoc, diag::ext_integer_complement_complex)
11876 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
11879 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
11910 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
11920 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
11929 return ExprError(
Diag(OpLoc, diag::err_typecheck_unary_expr)
11961 "the co_await expression must be non-dependant before "
11962 "building operator co_await");
11972 if (Opc != UO_AddrOf && Opc != UO_Deref)
11973 CheckArrayAccess(Input.
get());
11983 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
11984 if (!DRE->getQualifier())
11991 if (isa<FieldDecl>(VD) || isa<IndirectFieldDecl>(VD))
11994 return Method->isInstance();
12000 if (!ULE->getQualifier())
12005 if (Method->isInstance())
12025 if (pty->getKind() == BuiltinType::PseudoObject &&
12030 if (Opc == UO_Extension)
12035 if (Opc == UO_AddrOf &&
12036 (pty->getKind() == BuiltinType::Overload ||
12037 pty->getKind() == BuiltinType::UnknownAny ||
12038 pty->getKind() == BuiltinType::BoundMember))
12044 Input = Result.
get();
12089 if (!cleanups)
return nullptr;
12092 if (!cast || cast->
getCastKind() != CK_ARCConsumeObject)
12119 assert(SubStmt && isa<CompoundStmt>(SubStmt) &&
"Invalid action invocation!");
12125 "cleanups within StmtExpr not correctly bound!");
12135 bool StmtExprMayBindToTemp =
false;
12141 LastLabelStmt =
Label;
12142 LastStmt =
Label->getSubStmt();
12145 if (
Expr *LastE = dyn_cast<Expr>(LastStmt)) {
12160 if (
Expr *rebuiltLastStmt
12162 LastExpr = rebuiltLastStmt;
12174 if (LastExpr.
get() !=
nullptr) {
12175 if (!LastLabelStmt)
12179 StmtExprMayBindToTemp =
true;
12188 if (StmtExprMayBindToTemp)
12190 return ResStmtExpr;
12205 return ExprError(
Diag(BuiltinLoc, diag::err_offsetof_record_type)
12206 << ArgTy << TypeRange);
12212 diag::err_offsetof_incomplete_type, TypeRange))
12219 if (Components.size() != 1)
12220 Diag(BuiltinLoc, diag::ext_offsetof_extended_field_designator)
12221 <<
SourceRange(Components[1].LocStart, Components.back().LocEnd);
12223 bool DidWarnAboutNonPOD =
false;
12228 if (OC.isBrackets) {
12233 return ExprError(
Diag(OC.LocEnd, diag::err_offsetof_array_type)
12249 diag::err_typecheck_subscript_not_integer)
12253 Comps.push_back(
OffsetOfNode(OC.LocStart, Exprs.size(), OC.LocEnd));
12254 Exprs.push_back(Idx);
12262 Comps.push_back(
OffsetOfNode(OC.LocStart, OC.U.IdentInfo, OC.LocEnd));
12269 diag::err_offsetof_incomplete_type))
12275 return ExprError(
Diag(OC.LocEnd, diag::err_offsetof_record_type)
12287 bool IsSafe =
LangOpts.CPlusPlus11? CRD->isStandardLayout() : CRD->isPOD();
12289 LangOpts.CPlusPlus11? diag::ext_offsetof_non_standardlayout_type
12290 : diag::ext_offsetof_non_pod_type;
12292 if (!IsSafe && !DidWarnAboutNonPOD &&
12295 <<
SourceRange(Components[0].LocStart, OC.LocEnd)
12297 DidWarnAboutNonPOD =
true;
12307 MemberDecl = IndirectMemberDecl->getAnonField();
12312 << OC.U.IdentInfo << RD <<
SourceRange(OC.LocStart,
12320 Diag(OC.LocEnd, diag::err_offsetof_bitfield)
12328 if (IndirectMemberDecl)
12329 Parent = cast<RecordDecl>(IndirectMemberDecl->getDeclContext());
12336 if (Paths.getDetectedVirtual()) {
12337 Diag(OC.LocEnd, diag::err_offsetof_field_of_virtual_base)
12348 if (IndirectMemberDecl) {
12349 for (
auto *FI : IndirectMemberDecl->chain()) {
12350 assert(isa<FieldDecl>(FI));
12352 cast<FieldDecl>(FI), OC.LocEnd));
12355 Comps.push_back(
OffsetOfNode(OC.LocStart, MemberDecl, OC.LocEnd));
12361 Comps, Exprs, RParenLoc);
12387 assert((CondExpr && LHSExpr && RHSExpr) &&
"Missing type argument(s)");
12392 bool ValueDependent =
false;
12393 bool CondIsTrue =
false;
12396 ValueDependent =
true;
12399 llvm::APSInt condEval(32);
12402 diag::err_typecheck_choose_expr_requires_constant,
false);
12405 CondExpr = CondICE.
get();
12406 CondIsTrue = condEval.getZExtValue();
12409 Expr *ActiveExpr = CondIsTrue ? LHSExpr : RHSExpr;
12411 resType = ActiveExpr->
getType();
12418 ChooseExpr(BuiltinLoc, CondExpr, LHSExpr, RHSExpr, resType, VK, OK, RPLoc,
12431 Decl *ManglingContextDecl;
12434 ManglingContextDecl)) {
12435 unsigned ManglingNumber = MCtx->getManglingNumber(Block);
12458 "block-id should have no identifier!");
12480 "GetTypeForDeclarator made a non-function block signature");
12491 if (ExplicitSignature.getLocalRangeBegin() ==
12492 ExplicitSignature.getLocalRangeEnd()) {
12504 CurBlock->TheDecl->setSignatureAsWritten(Sig);
12505 CurBlock->FunctionType = T;
12510 (isa<FunctionProtoType>(Fn) && cast<FunctionProtoType>(Fn)->isVariadic());
12512 CurBlock->TheDecl->setIsVariadic(isVariadic);
12519 CurBlock->ReturnType = RetTy;
12520 CurBlock->TheDecl->setBlockMissingReturnType(
false);
12521 CurBlock->HasImplicitReturnType =
false;
12526 if (ExplicitSignature) {
12527 for (
unsigned I = 0,
E = ExplicitSignature.getNumParams();
I !=
E; ++
I) {
12534 Params.push_back(Param);
12540 for (
const auto &
I : Fn->param_types()) {
12543 Params.push_back(Param);
12548 if (!Params.empty()) {
12549 CurBlock->TheDecl->setParams(Params);
12558 for (
auto AI : CurBlock->TheDecl->parameters()) {
12559 AI->setOwningFunction(CurBlock->TheDecl);
12562 if (AI->getIdentifier()) {
12588 Diag(CaretLoc, diag::err_blocks_disable) <<
LangOpts.OpenCL;
12594 "cleanups within block not correctly bound!");
12619 Captures.push_back(NewCap);
12628 if (NoReturn && !Ext.getNoReturn()) Ext = Ext.
withNoReturn(
true);
12631 if (isa<FunctionNoProtoType>(FTy)) {
12668 if (Body &&
getCurFunction()->HasPotentialAvailabilityViolations)
12692 const VarDecl *var = CI.getVariable();
12713 Expr *OrigExpr =
E;
12757 if (Init.isInvalid())
12759 E = Init.getAs<
Expr>();
12772 diag::err_first_argument_to_va_arg_not_of_type_va_list)
12777 diag::err_second_parameter_to_va_arg_incomplete,
12783 diag::err_second_parameter_to_va_arg_abstract,
12790 ? diag::warn_second_parameter_to_va_arg_ownership_qualified
12791 : diag::warn_second_parameter_to_va_arg_not_pod)
12808 PDiag(diag::warn_second_parameter_to_va_arg_never_compatible)
12830 llvm_unreachable(
"I don't know size of pointer!");
12857 if (OV->getSourceExpr())
12872 const Expr *SrcExpr) {
12894 bool *Complained) {
12896 *Complained =
false;
12899 bool CheckInferredResultType =
false;
12901 unsigned DiagKind = 0;
12904 bool MayHaveConvFixit =
false;
12905 bool MayHaveFunctionDiff =
false;
12915 DiagKind = diag::ext_typecheck_convert_pointer_int;
12917 MayHaveConvFixit =
true;
12920 DiagKind = diag::ext_typecheck_convert_int_pointer;
12922 MayHaveConvFixit =
true;
12926 DiagKind = diag::err_arc_typecheck_convert_incompatible_pointer;
12929 DiagKind = diag::ext_typecheck_convert_incompatible_function_pointer;
12931 DiagKind = diag::ext_typecheck_convert_incompatible_pointer;
12935 if (Hint.
isNull() && !CheckInferredResultType) {
12938 else if (CheckInferredResultType) {
12942 MayHaveConvFixit =
true;
12945 DiagKind = diag::ext_typecheck_convert_incompatible_pointer_sign;
12948 DiagKind = diag::ext_typecheck_convert_pointer_void_func;
12957 DiagKind = diag::err_typecheck_incompatible_address_space;
12962 DiagKind = diag::err_typecheck_incompatible_ownership;
12966 llvm_unreachable(
"unknown error case for discarding qualifiers!");
12982 DiagKind = diag::ext_typecheck_convert_discards_qualifiers;
12985 DiagKind = diag::ext_nested_pointer_qualifier_mismatch;
12988 DiagKind = diag::err_int_to_block_pointer;
12991 DiagKind = diag::err_typecheck_convert_incompatible_block_pointer;
12997 for (
auto *srcProto : srcOPT->
quals()) {
13003 IFace = IFaceT->getDecl();
13008 for (
auto *dstProto : dstOPT->
quals()) {
13014 IFace = IFaceT->getDecl();
13016 DiagKind = diag::warn_incompatible_qualified_id;
13020 DiagKind = diag::warn_incompatible_vectors;
13023 DiagKind = diag::err_arc_weak_unavailable_assign;
13028 *Complained =
true;
13032 DiagKind = diag::err_typecheck_convert_incompatible;
13034 MayHaveConvFixit =
true;
13036 MayHaveFunctionDiff =
true;
13045 FirstType = DstType;
13046 SecondType = SrcType;
13056 FirstType = SrcType;
13057 SecondType = DstType;
13065 FDiag << FirstType << SecondType << Action << SrcExpr->
getSourceRange();
13069 if (!ConvHints.
isNull()) {
13075 if (MayHaveConvFixit) { FDiag << (
unsigned) (ConvHints.
Kind); }
13077 if (MayHaveFunctionDiff)
13081 if (DiagKind == diag::warn_incompatible_qualified_id &&
13083 Diag(IFace->
getLocation(), diag::note_incomplete_class_and_qualified_id)
13090 if (CheckInferredResultType)
13097 *Complained =
true;
13102 llvm::APSInt *Result) {
13106 S.
Diag(Loc, diag::err_expr_not_ice) << S.
LangOpts.CPlusPlus << SR;
13114 llvm::APSInt *Result,
13121 IDDiagnoser(
unsigned DiagID)
13125 S.
Diag(Loc, DiagID) << SR;
13127 } Diagnoser(DiagID);
13134 S.
Diag(Loc, diag::ext_expr_not_ice) << SR << S.
LangOpts.CPlusPlus;
13152 CXX11ConvertDiagnoser(
bool Silent)
13158 return S.
Diag(Loc, diag::err_ice_not_integral) << T;
13163 return S.
Diag(Loc, diag::err_ice_incomplete_type) << T;
13168 return S.
Diag(Loc, diag::err_ice_explicit_conversion) << T << ConvTy;
13179 return S.
Diag(Loc, diag::err_ice_ambiguous_conversion) << T;
13190 llvm_unreachable(
"conversion functions are permitted");
13192 } ConvertDiagnoser(Diagnoser.
Suppress);
13198 E = Converted.
get();
13218 EvalResult.
Diag = &Notes;
13237 if (Notes.size() == 1 && Notes[0].second.getDiagID() ==
13238 diag::note_invalid_subexpr_in_const_expr) {
13239 DiagLoc = Notes[0].first;
13243 if (!Folded || !AllowFold) {
13265 class TransformToPE :
public TreeTransform<TransformToPE> {
13269 TransformToPE(
Sema &SemaRef) : BaseTransform(SemaRef) { }
13272 bool AlwaysRebuild() {
return true; }
13279 return BaseTransform::TransformLabelStmt(S);
13290 if (isa<FieldDecl>(E->
getDecl()) &&
13291 !SemaRef.isUnevaluatedContext())
13293 diag::err_invalid_non_static_member_use)
13296 return BaseTransform::TransformDeclRefExpr(E);
13304 return BaseTransform::TransformUnaryOperator(E);
13316 "Should only transform unevaluated expressions");
13321 return TransformToPE(*this).TransformExpr(E);
13326 Decl *LambdaContextDecl,
13329 LambdaContextDecl, IsDecltype);
13354 D = diag::err_lambda_unevaluated_operand;
13360 D = diag::err_lambda_in_constant_expression;
13370 for (
const auto *L : Rec.
Lambdas)
13371 Diag(L->getLocStart(), D);
13375 for (
auto *Lambda : Rec.
Lambdas) {
13376 for (
auto *C : Lambda->capture_inits())
13405 assert(NumTypos == 0 &&
"There are outstanding typos after popping the "
13406 "last ExpressionEvaluationContextRecord");
13446 llvm_unreachable(
"Invalid context");
13471 llvm_unreachable(
"Invalid context");
13483 bool MightBeOdrUse) {
13484 assert(Func &&
"No function?");
13506 bool NeedDefinition =
13515 if (NeedDefinition &&
13535 if ((Func->
isUsed(
false) || !OdrUse) &&
13536 (!NeedDefinition || Func->
getBody()))
13541 Constructor = cast<CXXConstructorDecl>(Constructor->getFirstDecl());
13542 if (Constructor->isDefaulted() && !Constructor->isDeleted()) {
13543 if (Constructor->isDefaultConstructor()) {
13544 if (Constructor->isTrivial() && !Constructor->hasAttr<DLLExportAttr>())
13547 }
else if (Constructor->isCopyConstructor()) {
13549 }
else if (Constructor->isMoveConstructor()) {
13552 }
else if (Constructor->getInheritedConstructor()) {
13556 dyn_cast<CXXDestructorDecl>(Func)) {
13557 Destructor = cast<CXXDestructorDecl>(Destructor->getFirstDecl());
13558 if (Destructor->isDefaulted() && !Destructor->isDeleted()) {
13559 if (Destructor->isTrivial() && !Destructor->hasAttr<DLLExportAttr>())
13563 if (Destructor->isVirtual() &&
getLangOpts().AppleKext)
13565 }
else if (
CXXMethodDecl *MethodDecl = dyn_cast<CXXMethodDecl>(Func)) {
13566 if (MethodDecl->isOverloadedOperator() &&
13567 MethodDecl->getOverloadedOperator() == OO_Equal) {
13568 MethodDecl = cast<CXXMethodDecl>(MethodDecl->getFirstDecl());
13569 if (MethodDecl->isDefaulted() && !MethodDecl->isDeleted()) {
13570 if (MethodDecl->isCopyAssignmentOperator())
13572 else if (MethodDecl->isMoveAssignmentOperator())
13575 }
else if (isa<CXXConversionDecl>(MethodDecl) &&
13576 MethodDecl->getParent()->isLambda()) {
13578 cast<CXXConversionDecl>(MethodDecl->getFirstDecl());
13583 }
else if (MethodDecl->isVirtual() &&
getLangOpts().AppleKext)
13594 bool AlreadyInstantiated =
false;
13598 if (SpecInfo->getPointOfInstantiation().isInvalid())
13599 SpecInfo->setPointOfInstantiation(Loc);
13600 else if (SpecInfo->getTemplateSpecializationKind()
13602 AlreadyInstantiated =
true;
13603 PointOfInstantiation = SpecInfo->getPointOfInstantiation();
13607 if (MSInfo->getPointOfInstantiation().isInvalid())
13608 MSInfo->setPointOfInstantiation(Loc);
13609 else if (MSInfo->getTemplateSpecializationKind()
13611 AlreadyInstantiated =
true;
13612 PointOfInstantiation = MSInfo->getPointOfInstantiation();
13616 if (!AlreadyInstantiated || Func->
isConstexpr()) {
13621 std::make_pair(Func, PointOfInstantiation));
13630 PointOfInstantiation));
13637 for (
auto i : Func->
redecls()) {
13638 if (!i->isUsed(
false) && i->isImplicitlyInstantiable())
13643 if (!OdrUse)
return;
13647 if (mightHaveNonExternalLinkage(Func))
13666 if (isa<ParmVarDecl>(var) &&
13667 isa<TranslationUnitDecl>(VarDC))
13680 unsigned ValueKind = isa<BindingDecl>(var) ? 1 : 0;
13682 if (isa<CXXMethodDecl>(VarDC) &&
13683 cast<CXXRecordDecl>(VarDC->
getParent())->isLambda()) {
13685 }
else if (isa<FunctionDecl>(VarDC)) {
13687 }
else if (isa<BlockDecl>(VarDC)) {
13691 S.
Diag(loc, diag::err_reference_to_local_in_enclosing_context)
13692 << var << ValueKind << ContextKind << VarDC;
13702 bool &SubCapturesAreNested,
13708 SubCapturesAreNested =
true;
13721 !(isa<LambdaScopeInfo>(CSI) && cast<LambdaScopeInfo>(CSI)->Mutable) &&
13722 !(isa<CapturedRegionScopeInfo>(CSI) &&
13723 cast<CapturedRegionScopeInfo>(CSI)->CapRegionKind ==
CR_OpenMP))
13734 const bool Diagnose,
Sema &S) {
13749 const bool Diagnose,
Sema &S) {
13751 bool IsBlock = isa<BlockScopeInfo>(CSI);
13752 bool IsLambda = isa<LambdaScopeInfo>(CSI);
13760 S.
Diag(Loc, diag::err_lambda_capture_anonymous_var);
13769 S.
Diag(Loc, diag::err_ref_vm_type);
13778 if (VTTy->getDecl()->hasFlexibleArrayMember()) {
13781 S.
Diag(Loc, diag::err_ref_flexarray_type);
13783 S.
Diag(Loc, diag::err_lambda_capture_flexarray_type)
13791 const bool HasBlocksAttr = Var->
hasAttr<BlocksAttr>();
13794 if (HasBlocksAttr && (IsLambda || isa<CapturedRegionScopeInfo>(CSI))) {
13796 S.
Diag(Loc, diag::err_capture_block_variable)
13807 S.
Diag(Loc, diag::err_opencl_block_ref_block);
13817 const bool BuildAndDiagnose,
13822 Expr *CopyExpr =
nullptr;
13823 bool ByRef =
false;
13827 if (BuildAndDiagnose) {
13828 S.
Diag(Loc, diag::err_ref_array_type);
13837 if (BuildAndDiagnose) {
13838 S.
Diag(Loc, diag::err_arc_autoreleasing_capture)
13852 auto IsObjCOwnershipAttributedType = [](
QualType Ty) {
13858 Ty = AttrTy->getModifiedType();
13868 !IsObjCOwnershipAttributedType(PointeeTy)) {
13869 if (BuildAndDiagnose) {
13871 S.
Diag(Loc, diag::warn_block_capture_autoreleasing);
13873 auto AddAutoreleaseNote =
13874 S.
Diag(VarLoc, diag::note_declare_parameter_autoreleasing);
13890 ?
" __autoreleasing "
13891 :
" __autoreleasing");
13896 S.
Diag(VarLoc, diag::note_declare_parameter_strong);
13901 const bool HasBlocksAttr = Var->
hasAttr<BlocksAttr>();
13910 DeclRefType = CaptureType;
13912 if (S.
getLangOpts().CPlusPlus && BuildAndDiagnose) {
13919 if (isa<ParmVarDecl>(Var))
13937 CaptureType,
false),
13944 !cast<CXXConstructExpr>(Result.
get())->getConstructor()
13947 CopyExpr = Result.
get();
13954 if (BuildAndDiagnose)
13955 BSI->
addCapture(Var, HasBlocksAttr, ByRef, Nested, Loc,
13967 const bool BuildAndDiagnose,
13970 const bool RefersToCapturedVariable,
13984 CaptureType = DeclRefType;
13986 Expr *CopyExpr =
nullptr;
13987 if (BuildAndDiagnose) {
14008 if (BuildAndDiagnose)
14009 RSI->
addCapture(Var,
false, ByRef, RefersToCapturedVariable, Loc,
14021 bool RefersToCapturedVariable) {
14038 const bool BuildAndDiagnose,
14041 const bool RefersToCapturedVariable,
14044 const bool IsTopScope,
14048 bool ByRef =
false;
14082 if (!RefType->getPointeeType()->isFunctionType())
14088 if (BuildAndDiagnose) {
14089 S.
Diag(Loc, diag::err_arc_autoreleasing_capture) << 1;
14097 if (BuildAndDiagnose) {
14100 diag::err_capture_of_incomplete_type,
14105 diag::err_capture_of_abstract_type))
14111 if (BuildAndDiagnose)
14113 RefersToCapturedVariable);
14130 if (BuildAndDiagnose)
14131 LSI->
addCapture(Var,
false, ByRef, RefersToCapturedVariable,
14132 Loc, EllipsisLoc, CaptureType,
nullptr);
14140 QualType &DeclRefType,
const unsigned *
const FunctionScopeIndexToStopAt) {
14148 const unsigned MaxFunctionScopesIndex = FunctionScopeIndexToStopAt
14152 if (FunctionScopeIndexToStopAt) {
14154 while (FSIndex != MaxFunctionScopesIndex) {
14163 if (VarDC == DC)
return true;
14179 CaptureType = Var->
getType();
14181 bool Nested =
false;
14183 unsigned FunctionScopesIndex = MaxFunctionScopesIndex;
14196 FunctionScopesIndex = MaxFunctionScopesIndex - 1;
14217 if (BuildAndDiagnose) {
14240 if (
ParmVarDecl *PVD = dyn_cast_or_null<ParmVarDecl>(Var))
14241 QTy = PVD->getOriginalType();
14246 if (
auto *RSI = dyn_cast<CapturedRegionScopeInfo>(CSI)) {
14256 FunctionScopesIndex--;
14259 Nested = !IsTargetCap;
14270 if (BuildAndDiagnose) {
14274 if (cast<LambdaScopeInfo>(CSI)->Lambda)
14275 Diag(cast<LambdaScopeInfo>(CSI)->Lambda->getLocStart(),
14276 diag::note_lambda_decl);
14292 FunctionScopesIndex--;
14295 }
while (!VarDC->
Equals(DC));
14302 for (
unsigned I = ++FunctionScopesIndex, N = MaxFunctionScopesIndex + 1;
I != N;
14308 BuildAndDiagnose, CaptureType,
14309 DeclRefType, Nested, *
this))
14314 BuildAndDiagnose, CaptureType,
14315 DeclRefType, Nested, *
this))
14321 BuildAndDiagnose, CaptureType,
14322 DeclRefType, Nested, Kind, EllipsisLoc,
14323 I == N - 1, *
this))
14337 DeclRefType,
nullptr);
14344 false, CaptureType,
14345 DeclRefType,
nullptr);
14354 false, CaptureType,
14355 DeclRefType,
nullptr))
14358 return DeclRefType;
14372 const VarDecl *DefVD =
nullptr;
14399 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(SansParensExpr))
14400 Var = dyn_cast<
VarDecl>(DRE->getFoundDecl());
14401 else if (
MemberExpr *ME = dyn_cast<MemberExpr>(SansParensExpr))
14402 Var = dyn_cast<VarDecl>(ME->getMemberDecl());
14405 LSI->markVariableExprAsNonODRUsed(SansParensExpr);
14427 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(E)) {
14428 Var = cast<VarDecl>(DRE->getDecl());
14429 Loc = DRE->getLocation();
14430 }
else if (
MemberExpr *ME = dyn_cast<MemberExpr>(E)) {
14431 Var = cast<VarDecl>(ME->getMemberDecl());
14432 Loc = ME->getMemberLoc();
14434 llvm_unreachable(
"Unexpected expression");
14441 MaybeODRUseExprs.clear();
14447 assert((!E || isa<DeclRefExpr>(E) || isa<MemberExpr>(E)) &&
14448 "Invalid Expr argument to DoMarkVarDeclReferenced");
14454 bool NeedDefinition =
14460 assert(!isa<VarTemplatePartialSpecializationDecl>(Var) &&
14461 "Can't instantiate a partial template specialization.");
14467 !isa<VarTemplateSpecializationDecl>(Var))
14477 if (TryInstantiating && !isa<VarTemplateSpecializationDecl>(Var)) {
14481 L->StaticDataMemberInstantiated(Var);
14485 TryInstantiating =
false;
14491 if (TryInstantiating) {
14493 bool InstantiationDependent =
false;
14494 bool IsNonDependent =
14500 if (IsNonDependent) {
14507 .push_back(std::make_pair(Var, PointOfInstantiation));
14521 if (OdrUseContext && E &&
14527 }
else if (OdrUseContext) {
14535 const bool RefersToEnclosingScope =
14538 if (RefersToEnclosingScope) {
14550 assert(E &&
"Capture variable should be used in an expression.");
14567 Decl *D,
Expr *E,
bool MightBeOdrUse) {
14571 if (
VarDecl *Var = dyn_cast<VarDecl>(D)) {
14587 bool IsVirtualCall = MD->
isVirtual() &&
14589 if (!IsVirtualCall)
14605 bool OdrUse =
true;
14607 if (Method->isVirtual() &&
14608 !Method->getDevirtualizedMethod(Base,
getLangOpts().AppleKext))
14621 bool MightBeOdrUse =
true;
14624 if (Method->isPure())
14625 MightBeOdrUse =
false;
14637 bool MightBeOdrUse) {
14638 if (MightBeOdrUse) {
14639 if (
auto *VD = dyn_cast<VarDecl>(D)) {
14644 if (
auto *FD = dyn_cast<FunctionDecl>(D)) {
14672 bool MarkReferencedDecls::TraverseTemplateArgument(
14680 S.MarkAnyDeclReferenced(Loc, D,
true);
14682 S.MarkDeclarationsReferencedInExpr(Arg.
getAsExpr(),
false);
14686 return Inherited::TraverseTemplateArgument(Arg);
14690 MarkReferencedDecls Marker(*
this, Loc);
14691 Marker.TraverseType(T);
14699 bool SkipLocalVariables;
14704 EvaluatedExprMarker(
Sema &S,
bool SkipLocalVariables)
14705 : Inherited(S.
Context), S(S), SkipLocalVariables(SkipLocalVariables) { }
14709 if (SkipLocalVariables) {
14711 if (VD->hasLocalStorage())
14715 S.MarkDeclRefReferenced(E);
14719 S.MarkMemberReferenced(E);
14720 Inherited::VisitMemberExpr(E);
14734 Inherited::VisitCXXNewExpr(E);
14742 CXXRecordDecl *Record = cast<CXXRecordDecl>(DestroyedRec->getDecl());
14744 S.LookupDestructor(Record));
14747 Inherited::VisitCXXDeleteExpr(E);
14752 Inherited::VisitCXXConstructExpr(E);
14760 Inherited::VisitImplicitCastExpr(E);
14763 S.UpdateMarkingForLValueToRValue(E->
getSubExpr());
14774 bool SkipLocalVariables) {
14775 EvaluatedExprMarker(*
this, SkipLocalVariables).Visit(E);
14835 class CallReturnIncompleteDiagnoser :
public TypeDiagnoser {
14841 : FD(FD), CE(CE) { }
14845 S.
Diag(Loc, diag::err_call_incomplete_return)
14850 S.
Diag(Loc, diag::err_call_function_incomplete_return)
14855 } Diagnoser(FD, CE);
14868 unsigned diagnostic = diag::warn_condition_is_assignment;
14869 bool IsOrAssign =
false;
14872 if (Op->getOpcode() != BO_Assign && Op->getOpcode() != BO_OrAssign)
14875 IsOrAssign = Op->getOpcode() == BO_OrAssign;
14879 = dyn_cast<ObjCMessageExpr>(Op->getRHS()->IgnoreParenCasts())) {
14884 diagnostic = diag::warn_condition_is_idiomatic_assignment;
14888 diagnostic = diag::warn_condition_is_idiomatic_assignment;
14891 Loc = Op->getOperatorLoc();
14893 if (Op->getOperator() != OO_Equal && Op->getOperator() != OO_PipeEqual)
14896 IsOrAssign = Op->getOperator() == OO_PipeEqual;
14897 Loc = Op->getOperatorLoc();
14909 Diag(Loc, diag::note_condition_assign_silence)
14914 Diag(Loc, diag::note_condition_or_assign_to_comparison)
14917 Diag(Loc, diag::note_condition_assign_to_comparison)
14935 if (opE->getOpcode() == BO_EQ &&
14936 opE->getLHS()->IgnoreParenImpCasts()->isModifiableLvalue(
Context)
14942 Diag(Loc, diag::note_equality_comparison_silence)
14945 Diag(Loc, diag::note_equality_comparison_to_assign)
14951 bool IsConstexpr) {
14953 if (
ParenExpr *parenE = dyn_cast<ParenExpr>(E))
14971 Diag(Loc, diag::err_typecheck_statement_requires_scalar)
14975 CheckBoolLikeConversion(E, Loc);
15006 if (!FullExpr.
get())
15016 struct RebuildUnknownAnyFunction
15017 :
StmtVisitor<RebuildUnknownAnyFunction, ExprResult> {
15021 RebuildUnknownAnyFunction(
Sema &S) : S(S) {}
15024 llvm_unreachable(
"unexpected statement!");
15028 S.Diag(E->
getExprLoc(), diag::err_unsupported_unknown_any_call)
15035 template <
class T>
ExprResult rebuildSugarExpr(T *E) {
15036 ExprResult SubResult = Visit(E->getSubExpr());
15039 Expr *SubExpr = SubResult.
get();
15040 E->setSubExpr(SubExpr);
15048 return rebuildSugarExpr(E);
15052 return rebuildSugarExpr(E);
15059 Expr *SubExpr = SubResult.
get();
15068 if (!isa<FunctionDecl>(VD))
return VisitExpr(E);
15073 if (S.getLangOpts().CPlusPlus &&
15074 !(isa<CXXMethodDecl>(VD) &&
15075 cast<CXXMethodDecl>(VD)->isInstance()))
15086 return resolveDecl(E, E->
getDecl());
15104 struct RebuildUnknownAnyExpr
15105 :
StmtVisitor<RebuildUnknownAnyExpr, ExprResult> {
15113 : S(S), DestType(CastType) {}
15116 llvm_unreachable(
"unexpected statement!");
15120 S.Diag(E->
getExprLoc(), diag::err_unsupported_unknown_any_expr)
15130 template <
class T>
ExprResult rebuildSugarExpr(T *E) {
15131 ExprResult SubResult = Visit(E->getSubExpr());
15133 Expr *SubExpr = SubResult.
get();
15134 E->setSubExpr(SubExpr);
15142 return rebuildSugarExpr(E);
15146 return rebuildSugarExpr(E);
15184 return resolveDecl(E, E->
getDecl());
15195 FK_FunctionPointer,
15201 if (CalleeType == S.Context.BoundMemberTy) {
15202 assert(isa<CXXMemberCallExpr>(E) || isa<CXXOperatorCallExpr>(E));
15203 Kind = FK_MemberFunction;
15207 Kind = FK_FunctionPointer;
15210 Kind = FK_BlockPointer;
15215 if (DestType->isArrayType() || DestType->isFunctionType()) {
15216 unsigned diagID = diag::err_func_returning_array_function;
15217 if (Kind == FK_BlockPointer)
15218 diagID = diag::err_block_returning_array_function;
15221 << DestType->isFunctionType() << DestType;
15226 E->
setType(DestType.getNonLValueExprType(S.Context));
15254 if (ParamTypes.empty() && Proto->isVariadic()) {
15256 for (
unsigned i = 0, e = E->
getNumArgs(); i != e; ++i) {
15260 ArgType = S.Context.getLValueReferenceType(ArgType);
15262 ArgType = S.Context.getRValueReferenceType(ArgType);
15264 ArgTypes.push_back(ArgType);
15266 ParamTypes = ArgTypes;
15268 DestType = S.Context.getFunctionType(DestType, ParamTypes,
15269 Proto->getExtProtoInfo());
15271 DestType = S.Context.getFunctionNoProtoType(DestType,
15277 case FK_MemberFunction:
15281 case FK_FunctionPointer:
15282 DestType = S.Context.getPointerType(DestType);
15285 case FK_BlockPointer:
15286 DestType = S.Context.getBlockPointerType(DestType);
15291 ExprResult CalleeResult = Visit(CalleeExpr);
15296 return S.MaybeBindToTemporary(E);
15301 if (DestType->isArrayType() || DestType->isFunctionType()) {
15302 S.Diag(E->
getExprLoc(), diag::err_func_returning_array_function)
15303 << DestType->isFunctionType() << DestType;
15309 assert(Method->getReturnType() == S.Context.UnknownAnyTy);
15310 Method->setReturnType(DestType);
15314 E->
setType(DestType.getNonReferenceType());
15317 return S.MaybeBindToTemporary(E);
15322 if (E->
getCastKind() == CK_FunctionToPointerDecay) {
15329 DestType = DestType->castAs<
PointerType>()->getPointeeType();
15336 }
else if (E->
getCastKind() == CK_LValueToRValue) {
15340 assert(isa<BlockPointerType>(E->
getType()));
15345 DestType = S.Context.getLValueReferenceType(DestType);
15353 llvm_unreachable(
"Unhandled cast type!");
15369 return S.ImpCastExprToType(Result.
get(), Type,
15374 S.Diag(E->
getExprLoc(), diag::err_unknown_any_function)
15386 if (DRE && Proto && Proto->getParamTypes().empty() && Proto->isVariadic()) {
15389 FD->getDeclContext(),
15390 Loc, Loc, FD->getNameInfo().getName(),
15391 DestType, FD->getTypeSourceInfo(),
15393 FD->hasPrototype(),
15396 if (FD->getQualifier())
15400 for (
const auto &AI : FT->param_types()) {
15402 S.BuildParmVarDeclForTypedef(FD, Loc, AI);
15404 Params.push_back(Param);
15406 NewFD->setParams(Params);
15407 DRE->setDecl(NewFD);
15408 VD = DRE->getDecl();
15413 if (MD->isInstance()) {
15415 Type = S.Context.BoundMemberTy;
15419 if (!S.getLangOpts().CPlusPlus)
15423 }
else if (isa<VarDecl>(VD)) {
15427 S.Diag(E->
getExprLoc(), diag::err_unknown_any_var_function_type)
15434 S.Diag(E->
getExprLoc(), diag::err_unsupported_unknown_any_decl)
15455 diag::err_typecheck_cast_to_incomplete))
15459 ExprResult result = RebuildUnknownAnyExpr(*
this, CastType).Visit(CastExpr);
15462 CastExpr = result.
get();
15464 CastKind = CK_NoOp;
15470 return RebuildUnknownAnyExpr(*
this, ToType).Visit(E);
15498 unsigned diagID = diag::err_uncasted_use_of_unknown_any;
15501 if (
CallExpr *call = dyn_cast<CallExpr>(E)) {
15502 E = call->getCallee();
15503 diagID = diag::err_uncasted_call_of_unknown_any;
15511 if (
DeclRefExpr *ref = dyn_cast<DeclRefExpr>(E)) {
15512 loc = ref->getLocation();
15513 d = ref->getDecl();
15514 }
else if (
MemberExpr *mem = dyn_cast<MemberExpr>(E)) {
15515 loc = mem->getMemberLoc();
15516 d = mem->getMemberDecl();
15518 diagID = diag::err_uncasted_call_of_unknown_any;
15519 loc = msg->getSelectorStartLoc();
15520 d = msg->getMethodDecl();
15522 S.
Diag(loc, diag::err_uncasted_send_to_unknown_any_method)
15523 <<
static_cast<unsigned>(msg->isClassMessage()) << msg->getSelector()
15552 if (!placeholderType)
return E;
15554 switch (placeholderType->
getKind()) {
15557 case BuiltinType::Overload: {
15577 case BuiltinType::BoundMember: {
15582 if (isa<CXXPseudoDestructorExpr>(BME)) {
15583 PD =
PDiag(diag::err_dtor_expr_without_call) << 1;
15584 }
else if (
const auto *ME = dyn_cast<MemberExpr>(BME)) {
15585 if (ME->getMemberNameInfo().getName().getNameKind() ==
15587 PD =
PDiag(diag::err_dtor_expr_without_call) << 0;
15595 case BuiltinType::ARCUnbridgedCast: {
15602 case BuiltinType::UnknownAny:
15606 case BuiltinType::PseudoObject:
15609 case BuiltinType::BuiltinFn: {
15613 auto *FD = cast<FunctionDecl>(DRE->getDecl());
15614 if (FD->getBuiltinID() == Builtin::BI__noop) {
15616 CK_BuiltinFnToFnPtr).
get();
15627 case BuiltinType::OMPArraySection:
15632 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
15633 case BuiltinType::Id:
15634 #include "clang/Basic/OpenCLImageTypes.def"
15635 #define BUILTIN_TYPE(Id, SingletonId) case BuiltinType::Id:
15636 #define PLACEHOLDER_TYPE(Id, SingletonId)
15637 #include "clang/AST/BuiltinTypes.def"
15641 llvm_unreachable(
"invalid placeholder type!");
15655 assert((Kind == tok::kw___objc_yes || Kind == tok::kw___objc_no) &&
15656 "Unknown Objective-C Boolean value!");
15679 auto Spec = std::find_if(AvailSpecs.begin(), AvailSpecs.end(),
15681 return Spec.getPlatform() == Platform;
15685 if (Spec != AvailSpecs.end())
15686 Version = Spec->getVersion();
Abstract class used to diagnose incomplete types.
static void diagnoseArithmeticOnFunctionPointer(Sema &S, SourceLocation Loc, Expr *Pointer)
Diagnose invalid arithmetic on a function pointer.
SourceLocation getLocStart() const LLVM_READONLY
unsigned getNumElements() const
unsigned getFlags() const
getFlags - Return the flags for this scope.
LValueClassification ClassifyLValue(ASTContext &Ctx) const
Reasons why an expression might not be an l-value.
A call to an overloaded operator written using operator syntax.
unsigned getAddressSpace() const
Return the address space of this type.
ObjCMethodDecl * LookupMethodInQualifiedType(Selector Sel, const ObjCObjectPointerType *OPT, bool IsInstance)
LookupMethodInQualifiedType - Lookups up a method in protocol qualifier list of a qualified objective...
const ComplexType * getAsComplexIntegerType() const
SourceLocation getRParenLoc() const
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
bool compatiblyIncludesObjCLifetime(Qualifiers other) const
Determines if these qualifiers compatibly include another set of qualifiers from the narrow perspecti...
int getFloatingTypeOrder(QualType LHS, QualType RHS) const
Compare the rank of the two specified floating point types, ignoring the domain of the type (i...
bool hasDefinition() const
Determine whether this class has been defined.
bool allowsSizeofAlignof() const
Does this runtime allow sizeof or alignof on object types?
static void DiagnoseBitwisePrecedence(Sema &Self, BinaryOperatorKind Opc, SourceLocation OpLoc, Expr *LHSExpr, Expr *RHSExpr)
DiagnoseBitwisePrecedence - Emit a warning when bitwise and comparison operators are mixed in a way t...
Defines the clang::ASTContext interface.
void MarkDeclarationsReferencedInExpr(Expr *E, bool SkipLocalVariables=false)
Mark any declarations that appear within this expression or any potentially-evaluated subexpressions ...
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
SourceLocation getEnd() const
QualType getCurrentThisType()
Try to retrieve the type of the 'this' pointer.
const Expr * getBase() const
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
StmtClass getStmtClass() const
static std::string ComputeName(IdentType IT, const Decl *CurrentDecl)
ConditionResult ActOnCondition(Scope *S, SourceLocation Loc, Expr *SubExpr, ConditionKind CK)
CastKind getCastKind() const
IdKind getKind() const
Determine what kind of name we have.
ExprObjectKind getObjectKind() const
getObjectKind - The object kind that this expression produces.
bool RequireNonAbstractType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
void setImplicit(bool I=true)
void MarkVarDeclODRUsed(VarDecl *Var, SourceLocation Loc, Sema &SemaRef, const unsigned *const FunctionScopeIndexToStopAt)
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
void CheckShadow(NamedDecl *D, NamedDecl *ShadowedDecl, const LookupResult &R)
Diagnose variable or built-in function shadowing.
ParsedType CreateParsedType(QualType T, TypeSourceInfo *TInfo)
Package the given type and TSI into a ParsedType.
static bool isVariableAlreadyCapturedInScopeInfo(CapturingScopeInfo *CSI, VarDecl *Var, bool &SubCapturesAreNested, QualType &CaptureType, QualType &DeclRefType)
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
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
void markUsed(bool IsODRUse)
StringRef getName() const
getName - Get the name of identifier for this declaration as a StringRef.
ExprResult PerformContextuallyConvertToBool(Expr *From)
PerformContextuallyConvertToBool - Perform a contextual conversion of the expression From to bool (C+...
bool isSignedOverflowDefined() const
Smart pointer class that efficiently represents Objective-C method names.
bool isNonOverloadPlaceholderType() const
Test for a placeholder type other than Overload; see BuiltinType::isNonOverloadPlaceholderType.
A class which contains all the information about a particular captured value.
PointerType - C99 6.7.5.1 - Pointer Declarators.
EvaluatedExprVisitor - This class visits 'Expr *'s.
PointerToInt - The assignment converts a pointer to an int, which we accept as an extension...
bool isAtLeastAsQualifiedAs(QualType Other) const
Determine whether this type is at least as qualified as the other given type, requiring exact equalit...
TemplateSpecializationKind getTemplateSpecializationKind() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
bool CheckLoopHintExpr(Expr *E, SourceLocation Loc)
A (possibly-)qualified type.
bool isConstantArrayType() const
ArrayRef< Capture > captures() const
static QualType checkConditionalPointerCompatibility(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc)
Checks compatibility between two pointers and return the resulting type.
Simple class containing the result of Sema::CorrectTypo.
QualType CheckAssignmentOperands(Expr *LHSExpr, ExprResult &RHS, SourceLocation Loc, QualType CompoundType)
bool isPODType(const ASTContext &Context) const
Determine whether this is a Plain Old Data (POD) type (C++ 3.9p10).
bool containsUnexpandedParameterPack() const
Whether this expression contains an unexpanded parameter pack (for C++11 variadic templates)...
QualType areCommonBaseCompatible(const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT)
bool isThisCapture() const
QualType getCallResultType(const ASTContext &Context) const
Determine the type of an expression that calls a function of this type.
static bool checkBlockType(Sema &S, const Expr *E)
Return true if the Expr is block type.
Represents a version number in the form major[.minor[.subminor[.build]]].
bool isSpecificBuiltinType(unsigned K) const
Test for a particular builtin type.
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
bool hasFloatingRepresentation() const
Determine whether this type has a floating-point representation of some sort, e.g., it is a floating-point type or a vector thereof.
ObjCInterfaceDecl * getClassInterface()
bool isBitField() const
Determines whether this field is a bitfield.
DestructionKind isDestructedType() const
Returns a nonzero value if objects of this type require non-trivial work to clean up after...
A stack-allocated class that identifies which local variable declaration instantiations are present i...
static void diagnoseArithmeticOnTwoFunctionPointers(Sema &S, SourceLocation Loc, Expr *LHS, Expr *RHS)
Diagnose invalid arithmetic on two function pointers.
ExprResult ActOnConditionalOp(SourceLocation QuestionLoc, SourceLocation ColonLoc, Expr *CondExpr, Expr *LHSExpr, Expr *RHSExpr)
ActOnConditionalOp - Parse a ?: operation.
EnableIfAttr * CheckEnableIf(FunctionDecl *Function, ArrayRef< Expr * > Args, bool MissingImplicitThis=false)
Check the enable_if expressions on the given function.
bool isMemberPointerType() const
SourceLocation getLocation() const
DeclContext * getFunctionLevelDeclContext()
ExprResult ActOnIntegerConstant(SourceLocation Loc, uint64_t Val)
TheContext getContext() const
static const CastKind CK_Invalid
AvailabilityResult getAvailability(std::string *Message=nullptr, VersionTuple EnclosingVersion=VersionTuple()) const
Determine the availability of the given declaration.
const FunctionProtoType * ResolveExceptionSpec(SourceLocation Loc, const FunctionProtoType *FPT)
static QualType handleIntToFloatConversion(Sema &S, ExprResult &FloatExpr, ExprResult &IntExpr, QualType FloatTy, QualType IntTy, bool ConvertFloat, bool ConvertInt)
Hande arithmetic conversion from integer to float.
static CXXDependentScopeMemberExpr * Create(const ASTContext &C, Expr *Base, QualType BaseType, bool IsArrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, NamedDecl *FirstQualifierFoundInScope, DeclarationNameInfo MemberNameInfo, const TemplateArgumentListInfo *TemplateArgs)
QualType getComplexType(QualType T) const
Return the uniqued reference to the type for a complex number with the specified element type...
Expr * getInitExpr() const
static bool breakDownVectorType(QualType type, uint64_t &len, QualType &eltType)
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc...
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names this declaration, if there is one.
bool CheckParmsForFunctionDef(ArrayRef< ParmVarDecl * > Parameters, bool CheckParameterNames)
Helpers for dealing with blocks and functions.
ExprResult ActOnParenListExpr(SourceLocation L, SourceLocation R, MultiExprArg Val)
static LLVM_READONLY bool isWhitespace(unsigned char c)
Return true if this character is horizontal or vertical ASCII whitespace: ' ', '\t', '\f', '\v', '\n', '\r'.
static bool checkConditionalNullPointer(Sema &S, ExprResult &NullExpr, QualType PointerTy)
Return false if the NullExpr can be promoted to PointerTy, true otherwise.
QualType getNonLValueExprType(const ASTContext &Context) const
Determine the type of a (typically non-lvalue) expression with the specified result type...
QualType getQualifiedType(SplitQualType split) const
Un-split a SplitQualType.
const LangOptions & getLangOpts() const
static ExprResult diagnoseUnknownAnyExpr(Sema &S, Expr *E)
void setLookupName(DeclarationName Name)
Sets the name to look up.
static void addAsFieldToClosureType(Sema &S, LambdaScopeInfo *LSI, QualType FieldType, QualType DeclRefType, SourceLocation Loc, bool RefersToCapturedVariable)
Create a field within the lambda class for the variable being captured.
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false)
Perform unqualified name lookup starting from a given scope.
SourceLocation TemplateNameLoc
TemplateNameLoc - The location of the template name within the source.
static ConditionResult ConditionError()
static UnresolvedLookupExpr * Create(const ASTContext &C, CXXRecordDecl *NamingClass, NestedNameSpecifierLoc QualifierLoc, const DeclarationNameInfo &NameInfo, bool ADL, bool Overloaded, UnresolvedSetIterator Begin, UnresolvedSetIterator End)
CanQual< T > getUnqualifiedType() const
Retrieve the unqualified form of this type.
DeclClass * getAsSingle() const
bool isUserProvided() const
True if this method is user-declared and was not deleted or defaulted on its first declaration...
static void ConvertUTF8ToWideString(unsigned CharByteWidth, StringRef Source, SmallString< 32 > &Target)
Stmt - This represents one statement.
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.
NullabilityKind
Describes the nullability of a particular type.
bool isAnyCharacterType() const
Determine whether this type is any of the built-in character types.
ExprResult SubstInitializer(Expr *E, const MultiLevelTemplateArgumentList &TemplateArgs, bool CXXDirectInit)
FunctionType - C99 6.7.5.3 - Function Declarators.
FullExprArg MakeFullExpr(Expr *Arg)
ARCConversionResult CheckObjCConversion(SourceRange castRange, QualType castType, Expr *&op, CheckedConversionKind CCK, bool Diagnose=true, bool DiagnoseCFAudited=false, BinaryOperatorKind Opc=BO_PtrMemD)
Checks for invalid conversions and casts between retainable pointers and other pointer kinds for ARC ...
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
unsigned getIntWidth(QualType T) const
QualType ReturnType
ReturnType - The target type of return statements in this context, or null if unknown.
ObjCMethodDecl * LookupMethodInObjectType(Selector Sel, QualType Ty, bool IsInstance)
LookupMethodInType - Look up a method in an ObjCObjectType.
static bool IsReadonlyMessage(Expr *E, Sema &S)
ExprResult ActOnArraySubscriptExpr(Scope *S, Expr *Base, SourceLocation LLoc, Expr *Idx, SourceLocation RLoc)
QualType getIntTypeForBitwidth(unsigned DestWidth, unsigned Signed) const
getIntTypeForBitwidth - sets integer QualTy according to specified details: bitwidth, signed/unsigned.
TypedefDecl - Represents the declaration of a typedef-name via the 'typedef' type specifier...
Defines the SourceManager interface.
bool tryToFixConversion(const Expr *FromExpr, const QualType FromQTy, const QualType ToQTy, Sema &S)
If possible, generates and stores a fix for the given conversion.
void addConst()
Add the const type qualifier to this QualType.
ActionResult< Expr * > ExprResult
ExprResult BuildCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param)
BuildCXXDefaultArgExpr - Creates a CXXDefaultArgExpr, instantiating the default expr if needed...
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
The template argument is an expression, and we've not resolved it to one of the other forms yet...
static void diagnoseObjCLiteralComparison(Sema &S, SourceLocation Loc, ExprResult &LHS, ExprResult &RHS, BinaryOperator::Opcode Opc)
QualType InvalidLogicalVectorOperands(SourceLocation Loc, ExprResult &LHS, ExprResult &RHS)
ExprResult BuildPredefinedExpr(SourceLocation Loc, PredefinedExpr::IdentType IT)
static void CheckIdentityFieldAssignment(Expr *LHSExpr, Expr *RHSExpr, SourceLocation Loc, Sema &Sema)
bool hasPlaceholderType() const
Returns whether this expression has a placeholder type.
void computeNRVO(Stmt *Body, sema::FunctionScopeInfo *Scope)
Given the set of return statements within a function body, compute the variables that are subject to ...
SourceLocation getTemplateKeywordLoc() const
Gets the location of the template keyword, if present.
static InitializedEntity InitializeParameter(ASTContext &Context, const ParmVarDecl *Parm)
Create the initialization entity for a parameter.
bool isRecordType() const
bool isMultiplicativeOp() const
MemberSpecializationInfo * getMemberSpecializationInfo() const
If this function is an instantiation of a member function of a class template specialization, retrieves the member specialization information.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
QualType CheckRemainderOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign=false)
bool DiagnoseConditionalForNull(Expr *LHSExpr, Expr *RHSExpr, SourceLocation QuestionLoc)
Emit a specialized diagnostic when one expression is a null pointer constant and the other is not a p...
void ActOnBlockArguments(SourceLocation CaretLoc, Declarator &ParamInfo, Scope *CurScope)
ActOnBlockArguments - This callback allows processing of block arguments.
Decl - This represents one declaration (or definition), e.g.
bool GatherArgumentsForCall(SourceLocation CallLoc, FunctionDecl *FDecl, const FunctionProtoType *Proto, unsigned FirstParam, ArrayRef< Expr * > Args, SmallVectorImpl< Expr * > &AllArgs, VariadicCallType CallType=VariadicDoesNotApply, bool AllowExplicit=false, bool IsListInitialization=false)
GatherArgumentsForCall - Collector argument expressions for various form of call prototypes.
ExprResult BuildCallToMemberFunction(Scope *S, Expr *MemExpr, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc)
BuildCallToMemberFunction - Build a call to a member function.
SourceLocation getLocStart() const LLVM_READONLY
bool isPredefinedLibFunction(unsigned ID) const
Determines whether this builtin is a predefined libc/libm function, such as "malloc", where we know the signature a priori.
std::deque< PendingImplicitInstantiation > PendingInstantiations
The queue of implicit template instantiations that are required but have not yet been performed...
AssignConvertType
AssignConvertType - All of the 'assignment' semantic checks return this enum to indicate whether the ...
A reference to a name which we were able to look up during parsing but could not resolve to a specifi...
ExprResult PerformContextualImplicitConversion(SourceLocation Loc, Expr *FromE, ContextualImplicitConverter &Converter)
Perform a contextual implicit conversion.
bool isOpenMPTargetCapturedDecl(ValueDecl *D, unsigned Level)
Check if the specified variable is captured by 'target' directive.
static NonConstCaptureKind isReferenceToNonConstCapture(Sema &S, Expr *E)
unsigned getBuiltinID() const
Return a value indicating whether this is a builtin function.
Defines the C++ template declaration subclasses.
This is a while, do, switch, for, etc that can have break statements embedded into it...
bool isVoidPointerType() const
Scope * TUScope
Translation Unit Scope - useful to Objective-C actions that need to lookup file scope declarations in...
static bool checkPointerIntegerMismatch(Sema &S, ExprResult &Int, Expr *PointerExpr, SourceLocation Loc, bool IsIntFirstExpr)
Return false if the first expression is not an integer and the second expression is not a pointer...
bool isEnumeralType() const
static bool CheckObjCTraitOperandConstraints(Sema &S, QualType T, SourceLocation Loc, SourceRange ArgRange, UnaryExprOrTypeTrait TraitKind)
ExprResult DefaultArgumentPromotion(Expr *E)
DefaultArgumentPromotion (C99 6.5.2.2p6).
SmallVector< CodeSynthesisContext, 16 > CodeSynthesisContexts
List of active code synthesis contexts.
ParenExpr - This represents a parethesized expression, e.g.
bool CheckVecStepExpr(Expr *E)
std::string getAsString() const
ExprResult forceUnknownAnyToType(Expr *E, QualType ToType)
Force an expression with unknown-type to an expression of the given type.
ExprResult CreateBuiltinArraySubscriptExpr(Expr *Base, SourceLocation LLoc, Expr *Idx, SourceLocation RLoc)
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type...
CanQualType ARCUnbridgedCastTy
ExprResult ActOnVAArg(SourceLocation BuiltinLoc, Expr *E, ParsedType Ty, SourceLocation RPLoc)
IdentifierInfo * getAsIdentifierInfo() const
getAsIdentifierInfo - Retrieve the IdentifierInfo * stored in this declaration name, or NULL if this declaration name isn't a simple identifier.
The base class of the type hierarchy.
std::deque< PendingImplicitInstantiation > PendingLocalImplicitInstantiations
The queue of implicit template instantiations that are required and must be performed within the curr...
bool isObjCQualifiedClassType() const
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
QualType CheckShiftOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc, bool IsCompAssign=false)
QualType CheckSubtractionOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, QualType *CompLHSTy=nullptr)
std::unique_ptr< llvm::MemoryBuffer > Buffer
Represents an array type, per C99 6.7.5.2 - Array Declarators.
Declaration of a variable template.
const Expr * getInit() const
QualType getObjCClassRedefinitionType() const
Retrieve the type that Class has been defined to, which may be different from the built-in Class if C...
The template argument is a declaration that was provided for a pointer, reference, or pointer to member non-type template parameter.
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
Represents a call to a C++ constructor.
static TypoCorrection TryTypoCorrectionForCall(Sema &S, Expr *Fn, FunctionDecl *FDecl, ArrayRef< Expr * > Args)
static ExprValueKind getValueKindForType(QualType T)
getValueKindForType - Given a formal return or parameter type, give its value kind.
static bool convertPointersToCompositeType(Sema &S, SourceLocation Loc, ExprResult &LHS, ExprResult &RHS)
Returns false if the pointers are converted to a composite type, true otherwise.
Incompatible - We reject this conversion outright, it is invalid to represent it in the AST...
bool isBooleanType() const
TemplateNameKind Kind
The kind of template that Template refers to.
bool compatiblyIncludes(Qualifiers other) const
Determines if these qualifiers compatibly include another set.
A container of type source information.
static QualType handleComplexFloatConversion(Sema &S, ExprResult &LHS, ExprResult &RHS, QualType LHSType, QualType RHSType, bool IsCompAssign)
Handle arithmetic conversion with complex types.
SourceLocation getOperatorLoc() const
SourceLocation getLocStart() const LLVM_READONLY
MS property subscript expression.
Expr * getAsExpr() const
Retrieve the template argument as an expression.
bool isBlockPointerType() const
static StringLiteral * Create(const ASTContext &C, StringRef Str, StringKind Kind, bool Pascal, QualType Ty, const SourceLocation *Loc, unsigned NumStrs)
This is the "fully general" constructor that allows representation of strings formed from multiple co...
static bool IsWithinTemplateSpecialization(Decl *D)
QualType CheckVectorLogicalOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc)
static bool CheckForModifiableLvalue(Expr *E, SourceLocation Loc, Sema &S)
CheckForModifiableLvalue - Verify that E is a modifiable lvalue.
Wrapper for source info for pointers decayed from arrays and functions.
bool isCForbiddenLValueType() const
Determine whether expressions of the given type are forbidden from being lvalues in C...
T getAsAdjusted() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLock is not of the desire...
Abstract base class used for diagnosing integer constant expression violations.
Represents a path from a specific derived class (which is not represented as part of the path) to a p...
static bool checkVectorResult(Sema &S, QualType CondTy, QualType VecResTy, SourceLocation QuestionLoc)
Return false if the vector condition type and the vector result type are compatible.
Represents a C++ constructor within a class.
bool HasSideEffects(const ASTContext &Ctx, bool IncludePossibleEffects=true) const
HasSideEffects - This routine returns true for all those expressions which have any effect other than...
bool CheckCXXDefaultArgExpr(SourceLocation CallLoc, FunctionDecl *FD, ParmVarDecl *Param)
Instantiate or parse a C++ default argument expression as necessary.
void MarkFunctionReferenced(SourceLocation Loc, FunctionDecl *Func, bool MightBeOdrUse=true)
Mark a function referenced, and check whether it is odr-used (C++ [basic.def.odr]p2, C99 6.9p3)
bool hasUnsignedIntegerRepresentation() const
Determine whether this type has an unsigned integer representation of some sort, e.g., it is an unsigned integer type or a vector.
void InstantiateVariableDefinition(SourceLocation PointOfInstantiation, VarDecl *Var, bool Recursive=false, bool DefinitionRequired=false, bool AtEndOfTU=false)
const llvm::APInt & getSize() const
ExprResult ActOnGNUNullExpr(SourceLocation TokenLoc)
static InitializedEntity InitializeTemporary(QualType Type)
Create the initialization entity for a temporary.
void DiagnoseInvalidJumps(Stmt *Body)
ExprResult BuildBuiltinOffsetOf(SourceLocation BuiltinLoc, TypeSourceInfo *TInfo, ArrayRef< OffsetOfComponent > Components, SourceLocation RParenLoc)
__builtin_offsetof(type, a.b[123][456].c)
Retains information about a function, method, or block that is currently being parsed.
This file provides some common utility functions for processing Lambda related AST Constructs...
bool CheckVectorCast(SourceRange R, QualType VectorTy, QualType Ty, CastKind &Kind)
static bool hasIsEqualMethod(Sema &S, const Expr *LHS, const Expr *RHS)
void setRAngleLoc(SourceLocation Loc)
bool UseArgumentDependentLookup(const CXXScopeSpec &SS, const LookupResult &R, bool HasTrailingLParen)
QualType getBlockPointerType(QualType T) const
Return the uniqued reference to the type for a block of the specified type.
RAII object that enters a new expression evaluation context.
bool isUsableInConstantExpressions(ASTContext &C) const
Determine whether this variable's value can be used in a constant expression, according to the releva...
VarDecl - An instance of this class is created to represent a variable declaration or definition...
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
static NestedNameSpecifier * Create(const ASTContext &Context, NestedNameSpecifier *Prefix, IdentifierInfo *II)
Builds a specifier combining a prefix and an identifier.
CleanupInfo Cleanup
Used to control the generation of ExprWithCleanups.
Information about one declarator, including the parsed type information and the identifier.
ObjCIsaExpr - Represent X->isa and X.isa when X is an ObjC 'id' type.
void removeObjCLifetime()
DiagnosticsEngine & Diags
CompoundLiteralExpr - [C99 6.5.2.5].
static void diagnoseFunctionPointerToVoidComparison(Sema &S, SourceLocation Loc, ExprResult &LHS, ExprResult &RHS, bool IsError)
void setCXXLiteralOperatorNameLoc(SourceLocation Loc)
setCXXLiteralOperatorNameLoc - Sets the location of the literal operator name (not the operator keywo...
const Expr * getCallee() const
ObjCLifetime getObjCLifetime() const
bool hasCaptures() const
hasCaptures - True if this block (or its nested blocks) captures anything of local storage from its e...
DeclContext * computeDeclContext(QualType T)
Compute the DeclContext that is associated with the given type.
QualType isPromotableBitField(Expr *E) const
Whether this is a promotable bitfield reference according to C99 6.3.1.1p2, bullet 2 (and GCC extensi...
Extra information about a function prototype.
QualType getUsageType(QualType objectType) const
Retrieve the type of this instance variable when viewed as a member of a specific object type...
std::string getDeletedOrUnavailableSuffix(const FunctionDecl *FD)
Retrieve the message suffix that should be added to a diagnostic complaining about the given function...
bool isUnresolvableResult() const
static FunctionDecl * rewriteBuiltinFunctionDecl(Sema *Sema, ASTContext &Context, const FunctionDecl *FDecl, MultiExprArg ArgExprs)
If a builtin function has a pointer argument with no explicit address space, then it should be able t...
static bool canConvertIntToOtherIntTy(Sema &S, ExprResult *Int, QualType OtherIntTy)
Test if a (constant) integer Int can be casted to another integer type IntTy without losing precision...
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...
bool allowsNonTrivialObjCLifetimeQualifiers() const
True if any ObjC types may have non-trivial lifetime qualifiers.
ObjCMethodDecl - Represents an instance or class method declaration.
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
llvm::MapVector< NamedDecl *, SourceLocation > UndefinedButUsed
UndefinedInternals - all the used, undefined objects which require a definition in this translation u...
Expr * IgnoreImplicit() LLVM_READONLY
IgnoreImplicit - Skip past any implicit AST nodes which might surround this expression.
static void checkEnumComparison(Sema &S, SourceLocation Loc, Expr *LHS, Expr *RHS)
If two different enums are compared, raise a warning.
static bool handleIntegerToComplexFloatConversion(Sema &S, ExprResult &IntExpr, ExprResult &ComplexExpr, QualType IntTy, QualType ComplexTy, bool SkipCast)
Converts an integer to complex float type.
void ActOnStartStmtExpr()
static InitializedEntity InitializeResult(SourceLocation ReturnLoc, QualType Type, bool NRVO)
Create the initialization entity for the result of a function.
SourceLocation getOperatorLoc() const
Returns the location of the operator symbol in the expression.
static ObjCPropertyDecl * findPropertyDecl(const DeclContext *DC, const IdentifierInfo *propertyID, ObjCPropertyQueryKind queryKind)
Lookup a property by name in the specified DeclContext.
static InitializationKind CreateDirectList(SourceLocation InitLoc)
const BuiltinType * getAsPlaceholderType() const
void DefineImplicitLambdaToFunctionPointerConversion(SourceLocation CurrentLoc, CXXConversionDecl *Conv)
Define the "body" of the conversion from a lambda object to a function pointer.
ExprResult BuildUnaryOp(Scope *S, SourceLocation OpLoc, UnaryOperatorKind Opc, Expr *Input)
bool tryCaptureVariable(VarDecl *Var, SourceLocation Loc, TryCaptureKind Kind, SourceLocation EllipsisLoc, bool BuildAndDiagnose, QualType &CaptureType, QualType &DeclRefType, const unsigned *const FunctionScopeIndexToStopAt)
Try to capture the given variable.
unsigned getValue() const
Represents an expression – generally a full-expression – that introduces cleanups to be run at the en...
static void DiagnoseConstAssignment(Sema &S, const Expr *E, SourceLocation Loc)
Emit the "read-only variable not assignable" error and print notes to give more information about why...
std::vector< FixItHint > Hints
The list of Hints generated so far.
ParmVarDecl - Represents a parameter to a function.
NullPointerConstantKind isNullPointerConstant(ASTContext &Ctx, NullPointerConstantValueDependence NPC) const
isNullPointerConstant - C99 6.3.2.3p3 - Test if this reduces down to a Null pointer constant...
OpenCLOptions & getOpenCLOptions()
Defines the clang::Expr interface and subclasses for C++ expressions.
SourceLocation getLocation() const
void setHasBranchProtectedScope()
bool isEmpty() const
No scope specifier.
NestedNameSpecifierLoc getQualifierLoc() const
Retrieve the nested-name-specifier (with source-location information) that qualifies the name of this...
QualType getFunctionNoProtoType(QualType ResultTy, const FunctionType::ExtInfo &Info) const
Return a K&R style C function type like 'int()'.
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
static void diagnosePointerIncompatibility(Sema &S, SourceLocation Loc, Expr *LHSExpr, Expr *RHSExpr)
Emit error when two pointers are incompatible.
The collection of all-type qualifiers we support.
QualType getCaptureType() const
Retrieve the capture type for this capture, which is effectively the type of the non-static data memb...
tok::TokenKind ContextKind
QualType withConst() const
Retrieves a version of this type with const applied.
EvaluatedStmt * ensureEvaluatedStmt() const
Convert the initializer for this declaration to the elaborated EvaluatedStmt form, which contains extra information on the evaluated value of the initializer.
ExprResult ActOnCallExpr(Scope *S, Expr *Fn, SourceLocation LParenLoc, MultiExprArg ArgExprs, SourceLocation RParenLoc, Expr *ExecConfig=nullptr, bool IsExecConfig=false)
ActOnCallExpr - Handle a call to Fn with the specified array of arguments.
void DefineImplicitMoveConstructor(SourceLocation CurrentLocation, CXXConstructorDecl *Constructor)
DefineImplicitMoveConstructor - Checks for feasibility of defining this constructor as the move const...
QualType getArrayDecayedType(QualType T) const
Return the properly qualified result of decaying the specified array type to a pointer.
ExprResult PerformImplicitConversion(Expr *From, QualType ToType, AssignmentAction Action, bool AllowExplicit=false)
PerformImplicitConversion - Perform an implicit conversion of the expression From to the type ToType...
void MarkDeclarationsReferencedInType(SourceLocation Loc, QualType T)
Mark all of the declarations referenced within a particular AST node as referenced.
ExprResult CreateOverloadedBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, const UnresolvedSetImpl &Fns, Expr *LHS, Expr *RHS)
Create a binary operation that may resolve to an overloaded operator.
Base wrapper for a particular "section" of type source info.
LabelStmt - Represents a label, which has a substatement.
Expr * IgnoreImpCasts() LLVM_READONLY
IgnoreImpCasts - Skip past any implicit casts which might surround this expression.
static Sema::AssignConvertType checkObjCPointerTypesForAssignment(Sema &S, QualType LHSType, QualType RHSType)
checkObjCPointerTypesForAssignment - Compares two objective-c pointer types for assignment compatibil...
unsigned getNumParams() const
Expr * FixOverloadedFunctionReference(Expr *E, DeclAccessPair FoundDecl, FunctionDecl *Fn)
FixOverloadedFunctionReference - E is an expression that refers to a C++ overloaded function (possibl...
RecordDecl - Represents a struct/union/class.
static QualType OpenCLConvertScalarsToVectors(Sema &S, ExprResult &LHS, ExprResult &RHS, QualType CondTy, SourceLocation QuestionLoc)
Convert scalar operands to a vector that matches the condition in length.
QualType FindCompositeObjCPointerType(ExprResult &LHS, ExprResult &RHS, SourceLocation QuestionLoc)
FindCompositeObjCPointerType - Helper method to find composite type of two objective-c pointer types ...
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Computes the source location just past the end of the token at this source location.
bool hasBody(const FunctionDecl *&Definition) const
Returns true if the function has a body (definition).
bool isComparisonOp() const
bool hasUninstantiatedDefaultArg() const
bool isExternC() const
Determines whether this function is a function with external, C linkage.
TemplateIdAnnotation * TemplateId
When Kind == IK_TemplateId or IK_ConstructorTemplateId, the template-id annotation that contains the ...
ExprResult UsualUnaryConversions(Expr *E)
UsualUnaryConversions - Performs various conversions that are common to most operators (C99 6...
ExprResult ActOnPostfixUnaryOp(Scope *S, SourceLocation OpLoc, tok::TokenKind Kind, Expr *Input)
DeclarationName getName() const
getName - Returns the embedded declaration name.
FunctionType::ExtInfo ExtInfo
One of these records is kept for each identifier that is lexed.
std::unique_ptr< NSAPI > NSAPIObj
Caches identifiers/selectors for NSFoundation APIs.
static QualType handleComplexIntConversion(Sema &S, ExprResult &LHS, ExprResult &RHS, QualType LHSType, QualType RHSType, bool IsCompAssign)
Handle conversions with GCC complex int extension.
bool hasAnyUnrecoverableErrorsInThisFunction() const
Determine whether any errors occurred within this function/method/ block.
bool isScalarType() const
bool hasPtrArgsOrResult(unsigned ID) const
Determines whether this builtin has a result or any arguments which are pointer types.
IntToPointer - The assignment converts an int to a pointer, which we accept as an extension...
void DiagnoseUnusedExprResult(const Stmt *S)
DiagnoseUnusedExprResult - If the statement passed in is an expression whose result is unused...
IncompatibleObjCWeakRef - Assigning a weak-unavailable object to an object with __weak qualifier...
Represents a class type in Objective C.
IdentifierInfo * getCorrectionAsIdentifierInfo() const
A vector component is an element or range of elements on a vector.
Expr * getSizeExpr() const
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
TypeLoc getPointeeLoc() const
static void DiagnoseConditionalPrecedence(Sema &Self, SourceLocation OpLoc, Expr *Condition, Expr *LHSExpr, Expr *RHSExpr)
DiagnoseConditionalPrecedence - Emit a warning when a conditional operator and binary operator are mi...
static bool captureInCapturedRegion(CapturedRegionScopeInfo *RSI, VarDecl *Var, SourceLocation Loc, const bool BuildAndDiagnose, QualType &CaptureType, QualType &DeclRefType, const bool RefersToCapturedVariable, Sema &S)
Capture the given variable in the captured region.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
A C++ nested-name-specifier augmented with source location information.
static bool checkArithmeticOpPointerOperand(Sema &S, SourceLocation Loc, Expr *Operand)
Check the validity of an arithmetic pointer operand.
ArrayRef< QualType > getParamTypes() const
SourceLocation getPointOfInstantiation() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
ObjCMethodFamily
A family of Objective-C methods.
static bool anyDependentTemplateArguments(ArrayRef< TemplateArgumentLoc > Args, bool &InstantiationDependent)
Determine whether any of the given template arguments are dependent.
QualType getAddrSpaceQualType(QualType T, unsigned AddressSpace) const
Return the uniqued reference to the type for an address space qualified type with the specified type ...
static Sema::AssignConvertType checkPointerTypesForAssignment(Sema &S, QualType LHSType, QualType RHSType)
bool IsDerivedFrom(SourceLocation Loc, QualType Derived, QualType Base)
Determine whether the type Derived is a C++ class that is derived from the type Base.
bool isReferenceType() const
sema::BlockScopeInfo * getCurBlock()
Retrieve the current block, if any.
TypeSourceInfo * getTypeSourceInfo(ASTContext &Context, QualType T)
Creates a TypeSourceInfo for the given type.
QualType getReturnType() const
QualType getExtVectorType(QualType VectorType, unsigned NumElts) const
Return the unique reference to an extended vector type of the specified element type and size...
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
void checkSpecializationVisibility(SourceLocation Loc, NamedDecl *Spec)
We've found a use of a templated declaration that would trigger an implicit instantiation.
The current expression is potentially evaluated at run time, which means that code may be generated t...
bool isAnyPointerType() const
void diagnoseARCUnbridgedCast(Expr *e)
Given that we saw an expression with the ARCUnbridgedCastTy placeholder type, complain bitterly...
void setBOOLDecl(TypedefDecl *TD)
Save declaration of 'BOOL' typedef.
void setNumArgs(const ASTContext &C, unsigned NumArgs)
setNumArgs - This changes the number of arguments present in this call.
bool isOverloaded() const
UnaryExprOrTypeTrait
Names for the "expression or type" traits.
bool CheckObjCBridgeRelatedConversions(SourceLocation Loc, QualType DestType, QualType SrcType, Expr *&SrcExpr, bool Diagnose=true)
GNUNullExpr - Implements the GNU __null extension, which is a name for a null pointer constant that h...
SourceLocation getLocEnd() const LLVM_READONLY
unsigned getCVRQualifiers() const
void setArg(unsigned Arg, Expr *ArgExpr)
setArg - Set the specified argument.
void DiagnoseEqualityWithExtraParens(ParenExpr *ParenE)
Redundant parentheses over an equality comparison can indicate that the user intended an assignment u...
SourceRange getLocalSourceRange() const
Get the local source range.
static void DiagnoseDirectIsaAccess(Sema &S, const ObjCIvarRefExpr *OIRE, SourceLocation AssignLoc, const Expr *RHS)
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
Token - This structure provides full information about a lexed token.
static DeclRefExpr * Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *D, bool RefersToEnclosingVariableOrCapture, SourceLocation NameLoc, QualType T, ExprValueKind VK, NamedDecl *FoundD=nullptr, const TemplateArgumentListInfo *TemplateArgs=nullptr)
CompatiblePointerDiscardsQualifiers - The assignment discards c/v/r qualifiers, which we accept as an...
const RecordType * getAsUnionType() const
NOTE: getAs*ArrayType are methods on ASTContext.
static void diagnoseArithmeticOnTwoVoidPointers(Sema &S, SourceLocation Loc, Expr *LHSExpr, Expr *RHSExpr)
Diagnose invalid arithmetic on two void pointers.
void setKind(tok::TokenKind K)
VarDecl * getVariable() const
SourceLocation getLocStart() const LLVM_READONLY
ExprResult ActOnObjCBoolLiteral(SourceLocation OpLoc, tok::TokenKind Kind)
ActOnObjCBoolLiteral - Parse {__objc_yes,__objc_no} literals.
CUDAFunctionTarget IdentifyCUDATarget(const FunctionDecl *D, bool IgnoreImplicitHDAttr=false)
Determines whether the given function is a CUDA device/host/kernel/etc.
ExprResult CreateOverloadedUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc, const UnresolvedSetImpl &Fns, Expr *input)
Create a unary operation that may resolve to an overloaded operator.
QualType CheckConditionalOperands(ExprResult &Cond, ExprResult &LHS, ExprResult &RHS, ExprValueKind &VK, ExprObjectKind &OK, SourceLocation QuestionLoc)
Note that LHS is not null here, even if this is the gnu "x ?: y" extension.
bool isForRedeclaration() const
True if this lookup is just looking for an existing declaration.
bool isParamConsumed(unsigned I) const
ExprResult DefaultFunctionArrayConversion(Expr *E, bool Diagnose=true)
DefaultFunctionArrayConversion (C99 6.3.2.1p3, C99 6.3.2.1p4).
QualType getTypeDeclType(const TypeDecl *Decl, const TypeDecl *PrevDecl=nullptr) const
Return the unique reference to the type for the specified type declaration.
void PopExpressionEvaluationContext()
void FinalizeVarWithDestructor(VarDecl *VD, const RecordType *DeclInitType)
FinalizeVarWithDestructor - Prepare for calling destructor on the constructed variable.
void CheckObjCBridgeRelatedCast(QualType castType, Expr *castExpr)
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
void CheckExtraCXXDefaultArguments(Declarator &D)
CheckExtraCXXDefaultArguments - Check for any extra default arguments in the declarator, which is not a function declaration or definition and therefore is not permitted to have default arguments.
SourceRange getExprRange(Expr *E) const
No entity found met the criteria within the current instantiation,, but there were dependent base cla...
void NoteDeletedFunction(FunctionDecl *FD)
Emit a note explaining that this function is deleted.
static OffsetOfExpr * Create(const ASTContext &C, QualType type, SourceLocation OperatorLoc, TypeSourceInfo *tsi, ArrayRef< OffsetOfNode > comps, ArrayRef< Expr * > exprs, SourceLocation RParenLoc)
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
static InitializedEntity InitializeBlock(SourceLocation BlockVarLoc, QualType Type, bool NRVO)
Values of this type can be null.
The controlling scope in a if/switch/while/for statement.
Provides information about a function template specialization, which is a FunctionDecl that has been ...
static bool checkCondition(Sema &S, Expr *Cond, SourceLocation QuestionLoc)
Return false if the condition expression is valid, true otherwise.
SourceLocation getBeginLoc() const
Get the begin source location.
Describes an C or C++ initializer list.
bool isIntegralOrUnscopedEnumerationType() const
Determine whether this type is an integral or unscoped enumeration type.
void CheckStaticArrayArgument(SourceLocation CallLoc, ParmVarDecl *Param, const Expr *ArgExpr)
CheckStaticArrayArgument - If the given argument corresponds to a static array parameter, check that it is non-null, and that if it is formed by array-to-pointer decay, the underlying array is sufficiently large.
static bool IsTypeModifiable(QualType Ty, bool IsDereference)
uint32_t getCodeUnit(size_t i) const
ExprResult ActOnBlockStmtExpr(SourceLocation CaretLoc, Stmt *Body, Scope *CurScope)
ActOnBlockStmtExpr - This is called when the body of a block statement literal was successfully compl...
ExprResult ActOnGenericSelectionExpr(SourceLocation KeyLoc, SourceLocation DefaultLoc, SourceLocation RParenLoc, Expr *ControllingExpr, ArrayRef< ParsedType > ArgTypes, ArrayRef< Expr * > ArgExprs)
static bool CheckVecStepTraitOperandType(Sema &S, QualType T, SourceLocation Loc, SourceRange ArgRange)
Represents a C++ unqualified-id that has been parsed.
bool CanUseDecl(NamedDecl *D, bool TreatUnavailableAsInvalid)
Determine whether the use of this declaration is valid, without emitting diagnostics.
bool isCompleteType(SourceLocation Loc, QualType T)
bool findMacroSpelling(SourceLocation &loc, StringRef name)
Looks through the macro-expansion chain for the given location, looking for a macro expansion with th...
param_type_range param_types() const
SmallVectorImpl< PartialDiagnosticAt > * Diag
Diag - If this is non-null, it will be filled in with a stack of notes indicating why evaluation fail...
void setNameLoc(SourceLocation Loc)
Represents the results of name lookup.
static QualType OpenCLArithmeticConversions(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation QuestionLoc)
Simple conversion between integer and floating point types.
bool IsOpenMPCapturedByRef(ValueDecl *D, unsigned Level)
Return true if the provided declaration VD should be captured by reference.
ExprResult CallExprUnaryConversions(Expr *E)
CallExprUnaryConversions - a special case of an unary conversion performed on a function designator o...
static bool canConvertIntTyToFloatTy(Sema &S, ExprResult *Int, QualType FloatTy)
Test if a (constant) integer Int can be casted to floating point type FloatTy without losing precisio...
const TargetInfo & getTargetInfo() const
SourceLocation getLocWithOffset(int Offset) const
Return a source location with the specified offset from this SourceLocation.
static DeclAccessPair make(NamedDecl *D, AccessSpecifier AS)
QualType getOriginalType() const
ExprResult MaybeConvertParenListExprToParenExpr(Scope *S, Expr *ME)
This is not an AltiVec-style cast or or C++ direct-initialization, so turn the ParenListExpr into a s...
static bool isVariableCapturable(CapturingScopeInfo *CSI, VarDecl *Var, SourceLocation Loc, const bool Diagnose, Sema &S)
bool isSpecificPlaceholderType(unsigned K) const
Test for a specific placeholder type.
const LangOptions & getLangOpts() const
void ActOnBlockStart(SourceLocation CaretLoc, Scope *CurScope)
ActOnBlockStart - This callback is invoked when a block literal is started.
ObjCMethodDecl * getCurMethodDecl()
getCurMethodDecl - If inside of a method body, this returns a pointer to the method decl for the meth...
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
bool HasFormOfMemberPointer
unsigned getLength() const
CharUnits - This is an opaque type for sizes expressed in character units.
APValue Val
Val - This is the value the expression can be folded to.
A convenient class for passing around template argument information.
Qualifiers withoutObjCGCAttr() const
bool ValidateCandidate(const TypoCorrection &candidate) override
Simple predicate used by the default RankCandidate to determine whether to return an edit distance of...
bool EvaluateAsFloat(llvm::APFloat &Result, const ASTContext &Ctx, SideEffectsKind AllowSideEffects=SE_NoSideEffects) const
EvaluateAsFloat - Return true if this is a constant which we can fold and convert to a floating point...
ObjCMethodFamily getMethodFamily() const
Determines the family of this method.
bool exprNeedsCleanups() const
Keeps track of the mangled names of lambda expressions and block literals within a particular context...
QualType getReturnType() const
AssignConvertType CheckAssignmentConstraints(SourceLocation Loc, QualType LHSType, QualType RHSType)
CheckAssignmentConstraints - Perform type checking for assignment, argument passing, variable initialization, and function return values.
This is a while, do, for, which can have continue statements embedded into it.
unsigned getMinRequiredArguments() const
getMinRequiredArguments - Returns the minimum number of arguments needed to call this function...
const CXXRecordDecl * getParent() const
Returns the parent of this method declaration, which is the class in which this method is defined...
void DefineInheritingConstructor(SourceLocation UseLoc, CXXConstructorDecl *Constructor)
Define the specified inheriting constructor.
Whether values of this type can be null is (explicitly) unspecified.
An x-value expression is a reference to an object with independent storage but which can be "moved"...
field_range fields() const
static void checkDirectCallValidity(Sema &S, const Expr *Fn, FunctionDecl *Callee, MultiExprArg ArgExprs)
bool isObjCLifetimeType() const
Returns true if objects of this type have lifetime semantics under ARC.
bool IsFunctionConversion(QualType FromType, QualType ToType, QualType &ResultTy)
Determine whether the conversion from FromType to ToType is a valid conversion that strips "noexcept"...
void MarkDeclRefReferenced(DeclRefExpr *E, const Expr *Base=nullptr)
Perform reference-marking and odr-use handling for a DeclRefExpr.
static void DiagnoseSelfAssignment(Sema &S, Expr *LHSExpr, Expr *RHSExpr, SourceLocation OpLoc)
DiagnoseSelfAssignment - Emits a warning if a value is assigned to itself.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
bool containsDecl(Decl *D) const
Checks whether a declaration is in this context.
static Expr * recoverFromMSUnqualifiedLookup(Sema &S, ASTContext &Context, DeclarationNameInfo &NameInfo, SourceLocation TemplateKWLoc, const TemplateArgumentListInfo *TemplateArgs)
In Microsoft mode, if we are inside a template class whose parent class has dependent base classes...
QualType FunctionType
BlockType - The function type of the block, if one was given.
TypeDecl - Represents a declaration of a type.
A builtin binary operation expression such as "x + y" or "x <= y".
An implicit 'self' parameter.
CanQualType PseudoObjectTy
static QualType checkConditionalBlockPointerCompatibility(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc)
Return the resulting type when the operands are both block pointers.
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
RecordDecl * getDecl() const
ExprResult ActOnObjCAvailabilityCheckExpr(llvm::ArrayRef< AvailabilitySpec > AvailSpecs, SourceLocation AtLoc, SourceLocation RParen)
LiteralOperatorLookupResult LookupLiteralOperator(Scope *S, LookupResult &R, ArrayRef< QualType > ArgTys, bool AllowRaw, bool AllowTemplate, bool AllowStringTemplate)
LookupLiteralOperator - Determine which literal operator should be used for a user-defined literal...
ParsedTemplateArgument * getTemplateArgs()
Retrieves a pointer to the template arguments.
bool isUnsignedIntegerType() const
Return true if this is an integer type that is unsigned, according to C99 6.2.5p6 [which returns true...
bool isOverloadedOperator() const
isOverloadedOperator - Whether this function declaration represents an C++ overloaded operator...
FunctionDecl * ResolveAddressOfOverloadedFunction(Expr *AddressOfExpr, QualType TargetType, bool Complain, DeclAccessPair &Found, bool *pHadMultipleCandidates=nullptr)
ResolveAddressOfOverloadedFunction - Try to resolve the address of an overloaded function (C++ [over...
ExprResult BuildOverloadedCallExpr(Scope *S, Expr *Fn, UnresolvedLookupExpr *ULE, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc, Expr *ExecConfig, bool AllowTypoCorrection=true, bool CalleesAddressIsTaken=false)
BuildOverloadedCallExpr - Given the call expression that calls Fn (which eventually refers to the dec...
Expr * IgnoreParenCasts() LLVM_READONLY
IgnoreParenCasts - Ignore parentheses and casts.
Values of this type can never be null.
QualType getCapturedDeclRefType(VarDecl *Var, SourceLocation Loc)
Given a variable, determine the type that a reference to that variable will have in the given scope...
bool isVariadic() const
Whether this function is variadic.
DeclContext * getLambdaAwareParentOfDeclContext(DeclContext *DC)
QualType getTypeAsWritten() const
getTypeAsWritten - Returns the type that this expression is casting to, as written in the source code...
Scope - A scope is a transient data structure that is used while parsing the program.
ExprResult Perform(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Args, QualType *ResultType=nullptr)
Perform the actual initialization of the given entity based on the computed initialization sequence...
static bool CheckExtensionTraitOperandType(Sema &S, QualType T, SourceLocation Loc, SourceRange ArgRange, UnaryExprOrTypeTrait TraitKind)
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
TypoExpr - Internal placeholder for expressions where typo correction still needs to be performed and...
Represents a C++ nested-name-specifier or a global scope specifier.
static void captureVariablyModifiedType(ASTContext &Context, QualType T, CapturingScopeInfo *CSI)
void CheckTollFreeBridgeCast(QualType castType, Expr *castExpr)
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
TypeClass getTypeClass() const
static QualType CheckIndirectionOperand(Sema &S, Expr *Op, ExprValueKind &VK, SourceLocation OpLoc)
CheckIndirectionOperand - Type check unary indirection (prefix '*').
Helper class for OffsetOfExpr.
ExprResult CheckSwitchCondition(SourceLocation SwitchLoc, Expr *Cond)
The current expression occurs within a discarded statement.
Represents an Objective-C protocol declaration.
QualType getDestroyedType() const
Retrieve the type being destroyed.
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types...
Represents binding an expression to a temporary.
tok::TokenKind getKind() const
CXXTemporary * getTemporary()
std::string getAsString() const
getNameAsString - Retrieve the human-readable string for this name.
static bool checkAddressOfFunctionIsAvailable(Sema &S, const FunctionDecl *FD, bool Complain, bool InOverloadResolution, SourceLocation Loc)
Returns true if we can take the address of the function.
A C++ lambda expression, which produces a function object (of unspecified type) that can be invoked l...
static IntegerLiteral * Create(const ASTContext &C, const llvm::APInt &V, QualType type, SourceLocation l)
Returns a new integer literal with value 'V' and type 'type'.
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
ExprResult DefaultFunctionArrayLvalueConversion(Expr *E, bool Diagnose=true)
ExprResult ActOnNumericConstant(const Token &Tok, Scope *UDLScope=nullptr)
AssignConvertType CheckSingleAssignmentConstraints(QualType LHSType, ExprResult &RHS, bool Diagnose=true, bool DiagnoseCFAudited=false, bool ConvertRHS=true)
Check assignment constraints for an assignment of RHS to LHSType.
An ordinary object is located at an address in memory.
bool isLambdaCallOperator(const CXXMethodDecl *MD)
sema::AnalysisBasedWarnings AnalysisWarnings
Worker object for performing CFG-based warnings.
static void DiagnoseLogicalAndInLogicalOrRHS(Sema &S, SourceLocation OpLoc, Expr *LHSExpr, Expr *RHSExpr)
Look for '&&' in the right hand of a '||' expr.
A class that does preordor or postorder depth-first traversal on the entire Clang AST and visits each...
Represents an ObjC class declaration.
SmallVector< LambdaExpr *, 2 > Lambdas
The lambdas that are present within this context, if it is indeed an unevaluated context.
bool isExtVectorType() const
void addDecl(NamedDecl *D)
Add a declaration to these results with its natural access.
static SourceLocation AdvanceToTokenCharacter(SourceLocation TokStart, unsigned Character, const SourceManager &SM, const LangOptions &LangOpts)
AdvanceToTokenCharacter - If the current SourceLocation specifies a location at the start of a token...
CastKind PrepareScalarCast(ExprResult &src, QualType destType)
Prepares for a scalar cast, performing all the necessary stages except the final cast and returning t...
Member name lookup, which finds the names of class/struct/union members.
detail::InMemoryDirectory::const_iterator I
IncompatiblePointerSign - The assignment is between two pointers types which point to integers which ...
bool isEqualityOp() const
ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R, bool NeedsADL, bool AcceptInvalidDecl=false)
SourceLocation getLParenLoc() const
The current context is "potentially evaluated" in C++11 terms, but the expression is evaluated at com...
ExprResult checkUnknownAnyArg(SourceLocation callLoc, Expr *result, QualType ¶mType)
Type-check an expression that's being passed to an __unknown_anytype parameter.
bool isLambdaToBlockPointerConversion() const
Determine whether this conversion function is a conversion from a lambda closure type to a block poin...
void MarkVariableReferenced(SourceLocation Loc, VarDecl *Var)
Mark a variable referenced, and check whether it is odr-used (C++ [basic.def.odr]p2, C99 6.9p3).
CanQualType UnsignedCharTy
A default argument (C++ [dcl.fct.default]).
void setStmt(LabelStmt *T)
static FunctionDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation NLoc, DeclarationName N, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool isInlineSpecified=false, bool hasWrittenPrototype=true, bool isConstexprSpecified=false)
const LangOptions & LangOpts
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
bool IsStringLiteralToNonConstPointerConversion(Expr *From, QualType ToType)
Helper function to determine whether this is the (deprecated) C++ conversion from a string literal to...
static void CheckForNullPointerDereference(Sema &S, Expr *E)
bool checkOpenCLDisabledDecl(const NamedDecl &D, const Expr &E)
Check if declaration D used by expression E is disabled due to required OpenCL extensions being disab...
NestedNameSpecifier * getQualifier() const
If the name was qualified, retrieves the nested-name-specifier that precedes the name.
TypeSpecTypeLoc pushTypeSpec(QualType T)
Pushes space for a typespec TypeLoc.
bool isUnevaluatedContext() const
Determines whether we are currently in a context that is not evaluated as per C++ [expr] p5...
SourceRange getRange() const
bool isDefined(const FunctionDecl *&Definition) const
isDefined - Returns true if the function is defined at all, including a deleted definition.
void ActOnStmtExprError()
TyLocType push(QualType T)
Pushes space for a new TypeLoc of the given type.
unsigned NumCleanupObjects
The number of active cleanup objects when we entered this expression evaluation context.
void InstantiateFunctionDefinition(SourceLocation PointOfInstantiation, FunctionDecl *Function, bool Recursive=false, bool DefinitionRequired=false, bool AtEndOfTU=false)
Instantiate the definition of the given function from its template.
bool hasPrototype() const
Whether this function has a prototype, either because one was explicitly written or because it was "i...
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
const ArrayType * getAsArrayTypeUnsafe() const
A variant of getAs<> for array types which silently discards qualifiers from the outermost type...
ImplicitCaptureStyle ImpCaptureStyle
SourceLocation LAngleLoc
The location of the '<' before the template argument list.
EnumDecl * getDecl() const
void addPotentialCapture(Expr *VarExpr)
Add a variable that might potentially be captured by the lambda and therefore the enclosing lambdas...
bool isBlockCapture() const
CXXSpecialMember
Kinds of C++ special members.
OverloadFixItKind Kind
The type of fix applied.
OpenMP 4.0 [2.4, Array Sections].
FunctionDecl * getOperatorDelete() const
ExprResult checkPseudoObjectIncDec(Scope *S, SourceLocation OpLoc, UnaryOperatorKind Opcode, Expr *Op)
Check an increment or decrement of a pseudo-object expression.
FunctionTemplateSpecializationInfo * getTemplateSpecializationInfo() const
If this function is actually a function template specialization, retrieve information about this func...
ConditionalOperator - The ?: ternary operator.
ExtInfo getExtInfo() const
Sema - This implements semantic analysis and AST building for C.
static void DiagnoseBinOpPrecedence(Sema &Self, BinaryOperatorKind Opc, SourceLocation OpLoc, Expr *LHSExpr, Expr *RHSExpr)
DiagnoseBinOpPrecedence - Emit warnings for expressions with tricky precedence.
bool isAssignmentOp() const
void EmitRelatedResultTypeNoteForReturn(QualType destType)
Given that we had incompatible pointer types in a return statement, check whether we're in a method w...
void setNamingClass(CXXRecordDecl *Record)
Sets the 'naming class' for this lookup.
static bool ExprLooksBoolean(Expr *E)
ExprLooksBoolean - Returns true if E looks boolean, i.e.
bool Mutable
Whether this is a mutable lambda.
CompoundStmt - This represents a group of statements like { stmt stmt }.
const DeclarationNameInfo & getLookupNameInfo() const
Gets the name info to look up.
void checkVariadicArgument(const Expr *E, VariadicCallType CT)
Check to see if the given expression is a valid argument to a variadic function, issuing a diagnostic...
QualType getParamType(unsigned i) const
Represents a prototype with parameter type info, e.g.
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
static QualType computeConditionalNullability(QualType ResTy, bool IsBin, QualType LHSTy, QualType RHSTy, ASTContext &Ctx)
Compute the nullability of a conditional expression.
void MarkAnyDeclReferenced(SourceLocation Loc, Decl *D, bool MightBeOdrUse)
Perform marking for a reference to an arbitrary declaration.
SourceLocation getLocStart() const LLVM_READONLY
static NamedDecl * getDeclFromExpr(Expr *E)
ExprResult CreateBuiltinBinOp(SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr)
CreateBuiltinBinOp - Creates a new built-in binary operation with operator Opc at location TokLoc...
void CheckShadowingDeclModification(Expr *E, SourceLocation Loc)
Warn if 'E', which is an expression that is about to be modified, refers to a shadowing declaration...
Retains information about a captured region.
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
static void DiagnoseBitwiseOpInBitwiseOp(Sema &S, BinaryOperatorKind Opc, SourceLocation OpLoc, Expr *SubExpr)
Look for bitwise op in the left or right hand of a bitwise op with lower precedence and emit a diagno...
void DefineImplicitCopyAssignment(SourceLocation CurrentLocation, CXXMethodDecl *MethodDecl)
Defines an implicitly-declared copy assignment operator.
bool EvaluateAsRValue(EvalResult &Result, const ASTContext &Ctx) const
EvaluateAsRValue - Return true if this is a constant which we can fold to an rvalue using any crazy t...
CastKind
CastKind - The kind of operation required for a conversion.
static bool isQualifiedMemberAccess(Expr *E)
Determine whether the given expression is a qualified member access expression, of a form that could ...
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat)
SourceLocation getLocEnd() const LLVM_READONLY
static QualType checkConditionalVoidType(Sema &S, ExprResult &LHS, ExprResult &RHS)
Handle when one or both operands are void type.
DeclarationNameTable DeclarationNames
Specifies that the expression should never be value-dependent.
QualType CheckAdditionOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc, QualType *CompLHSTy=nullptr)
QualType getLogicalOperationType() const
The result type of logical operations, '<', '>', '!=', etc.
FunctionVoidPointer - The assignment is between a function pointer and void*, which the standard does...
bool CheckPointerConversion(Expr *From, QualType ToType, CastKind &Kind, CXXCastPath &BasePath, bool IgnoreBaseAccess, bool Diagnose=true)
CheckPointerConversion - Check the pointer conversion from the expression From to the type ToType...
UnaryExprOrTypeTraitExpr - expression with either a type or (unevaluated) expression operand...
static StringRef getOpcodeStr(Opcode Op)
getOpcodeStr - Turn an Opcode enum value into the punctuation char it corresponds to...
static void diagnoseStringPlusChar(Sema &Self, SourceLocation OpLoc, Expr *LHSExpr, Expr *RHSExpr)
Emit a warning when adding a char literal to a string.
Represents a call to the builtin function __builtin_va_arg.
static CXXDefaultArgExpr * Create(const ASTContext &C, SourceLocation Loc, ParmVarDecl *Param)
FunctionDecl * getOperatorDelete() const
sema::FunctionScopeInfo * getEnclosingFunction() const
static QualType handleIntegerConversion(Sema &S, ExprResult &LHS, ExprResult &RHS, QualType LHSType, QualType RHSType, bool IsCompAssign)
Handle integer arithmetic conversions.
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
bool isUnarySelector() const
SourceLocation getOpLoc() const
bool isFunctionPointerType() const
bool isCXXClassMember() const
Determine whether this declaration is a C++ class member.
ImplicitConversionSequence TryImplicitConversion(Expr *From, QualType ToType, bool SuppressUserConversions, bool AllowExplicit, bool InOverloadResolution, bool CStyle, bool AllowObjCWritebackConversion)
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
static void diagnoseArithmeticOnVoidPointer(Sema &S, SourceLocation Loc, Expr *Pointer)
Diagnose invalid arithmetic on a void pointer.
QualType CheckLogicalOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
bool isRealFloatingType() const
Floating point categories.
static StringRef getSourceText(CharSourceRange Range, const SourceManager &SM, const LangOptions &LangOpts, bool *Invalid=nullptr)
Returns a string for the source that the range encompasses.
ExprResult ActOnCompoundLiteral(SourceLocation LParenLoc, ParsedType Ty, SourceLocation RParenLoc, Expr *InitExpr)
An Objective-C property is a logical field of an Objective-C object which is read and written via Obj...
const ObjCMethodDecl * getMethodDecl() const
void DiagnoseAssignmentAsCondition(Expr *E)
DiagnoseAssignmentAsCondition - Given that an expression is being used as a boolean condition...
ExprResult ActOnBinOp(Scope *S, SourceLocation TokLoc, tok::TokenKind Kind, Expr *LHSExpr, Expr *RHSExpr)
LabelDecl * getDecl() const
unsigned getNumExprs() const
void mergeFrom(CleanupInfo Rhs)
Retains information about a block that is currently being parsed.
DeclContext * getLexicalParent()
getLexicalParent - Returns the containing lexical DeclContext.
bool isDeleted() const
Whether this function has been deleted.
CXXMethodDecl * CallOperator
The lambda's compiler-generated operator().
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
const Type * getTypeForDecl() const
BlockDecl - This represents a block literal declaration, which is like an unnamed FunctionDecl...
bool isKnownToHaveBooleanValue() const
isKnownToHaveBooleanValue - Return true if this is an integer expression that is known to return 0 or...
MultiLevelTemplateArgumentList getTemplateInstantiationArgs(NamedDecl *D, const TemplateArgumentList *Innermost=nullptr, bool RelativeToPrimary=false, const FunctionDecl *Pattern=nullptr)
Retrieve the template argument list(s) that should be used to instantiate the definition of the given...
The current expression is potentially evaluated, but any declarations referenced inside that expressi...
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
ExprResult BuildResolvedCallExpr(Expr *Fn, NamedDecl *NDecl, SourceLocation LParenLoc, ArrayRef< Expr * > Arg, SourceLocation RParenLoc, Expr *Config=nullptr, bool IsExecConfig=false)
BuildResolvedCallExpr - Build a call to a resolved expression, i.e.
Expr - This represents one expression.
bool DiagnoseEmptyLookup(Scope *S, CXXScopeSpec &SS, LookupResult &R, std::unique_ptr< CorrectionCandidateCallback > CCC, TemplateArgumentListInfo *ExplicitTemplateArgs=nullptr, ArrayRef< Expr * > Args=None, TypoExpr **Out=nullptr)
Diagnose an empty lookup.
bool isOrdinaryOrBitFieldObject() const
DeclarationName getLookupName() const
Gets the name to look up.
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)
DefineImplicitCopyConstructor - Checks for feasibility of defining this constructor as the copy const...
const Expr * getExpr(unsigned Init) const
Represents a character-granular source range.
static bool isEvaluatableContext(Sema &SemaRef)
Are we within a context in which some evaluation could be performed (be it constant evaluation or run...
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
bool performsVirtualDispatch(const LangOptions &LO) const
Returns true if virtual dispatch is performed.
static void DiagnoseLogicalAndInLogicalOrLHS(Sema &S, SourceLocation OpLoc, Expr *LHSExpr, Expr *RHSExpr)
Look for '&&' in the left hand of a '||' expr.
CXXRecordDecl * getNamingClass() const
Returns the 'naming class' for this lookup, i.e.
Expr * stripARCUnbridgedCast(Expr *e)
stripARCUnbridgedCast - Given an expression of ARCUnbridgedCast type, remove the placeholder cast...
static DeclContext * getParentOfCapturingContextOrNull(DeclContext *DC, VarDecl *Var, SourceLocation Loc, const bool Diagnose, Sema &S)
bool isAnyComplexType() const
static Kind getNullabilityAttrKind(NullabilityKind kind)
Retrieve the attribute kind corresponding to the given nullability kind.
bool isObjCClassType() const
static bool EvaluatesAsTrue(Sema &S, Expr *E)
Returns true if the given expression can be evaluated as a constant 'true'.
static FindResult find(Expr *E)
Finds the overloaded expression in the given expression E of OverloadTy.
NestedNameSpecifier * getCorrectionSpecifier() const
Gets the NestedNameSpecifier needed to use the typo correction.
bool isOpenMPPrivateDecl(ValueDecl *D, unsigned Level)
Check if the specified variable is used in 'private' clause.
bool isConstantEvaluated() const
SourceLocation getNameLoc() const
Gets the location of the identifier.
This file defines the classes used to store parsed information about declaration-specifiers and decla...
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context encloses the declaration context DC.
static bool maybeDiagnoseAssignmentToFunction(Sema &S, QualType DstType, const Expr *SrcExpr)
static bool captureInLambda(LambdaScopeInfo *LSI, VarDecl *Var, SourceLocation Loc, const bool BuildAndDiagnose, QualType &CaptureType, QualType &DeclRefType, const bool RefersToCapturedVariable, const Sema::TryCaptureKind Kind, SourceLocation EllipsisLoc, const bool IsTopScope, Sema &S)
Capture the given variable in the lambda.
QualType FindCompositePointerType(SourceLocation Loc, Expr *&E1, Expr *&E2, bool ConvertArgs=true)
Find a merged pointer type and convert the two expressions to it.
bool isAtomicType() const
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
static Expr * maybeRebuildARCConsumingStmt(Stmt *Statement)
Given the last statement in a statement-expression, check whether the result is a producing expressio...
Represents a C++ destructor within a class.
bool isNonWeakInMRRWithObjCWeak(const ASTContext &Context) const
void setAddressSpace(unsigned space)
CanQualType OMPArraySectionTy
SourceRange getSourceRange() const
void setInvalidDecl(bool Invalid=true)
setInvalidDecl - Indicates the Decl had a semantic error.
TranslationUnitDecl * getTranslationUnitDecl() const
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup.
void DiagnoseUnguardedAvailabilityViolations(Decl *FD)
Issue any -Wunguarded-availability warnings in FD.
bool isVariableArrayType() const
Defines the clang::Preprocessor interface.
SmallVectorImpl< OverloadCandidate >::iterator iterator
bool IsVariableAConstantExpression(VarDecl *Var, ASTContext &Context)
ExprResult VerifyIntegerConstantExpression(Expr *E, llvm::APSInt *Result, VerifyICEDiagnoser &Diagnoser, bool AllowFold=true)
VerifyIntegerConstantExpression - Verifies that an expression is an ICE, and reports the appropriate ...
ArgKind getKind() const
Return the kind of stored template argument.
const ParmVarDecl * getParamDecl(unsigned i) const
CharLiteralParser - Perform interpretation and semantic analysis of a character literal.
ExtProtoInfo getExtProtoInfo() const
bool isImplicitlyInstantiable() const
Determines whether this function is a function template specialization or a member of a class templat...
IncompatibleVectors - The assignment is between two vector types that have the same size...
Defines the classes clang::DelayedDiagnostic and clang::AccessedEntity.
static void emitEmptyLookupTypoDiagnostic(const TypoCorrection &TC, Sema &SemaRef, const CXXScopeSpec &SS, DeclarationName Typo, SourceLocation TypoLoc, ArrayRef< Expr * > Args, unsigned DiagnosticID, unsigned DiagnosticSuggestID)
static void DiagnoseShiftCompare(Sema &S, SourceLocation OpLoc, Expr *LHSExpr, Expr *RHSExpr)
DeclContext * getDeclContext()
Overload resolution succeeded.
void PopFunctionScopeInfo(const sema::AnalysisBasedWarnings::Policy *WP=nullptr, const Decl *D=nullptr, const BlockExpr *blkExpr=nullptr)
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given unary opcode. ...
bool isFloatingType() const
static ExprResult BuildOverloadedBinOp(Sema &S, Scope *Sc, SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHS, Expr *RHS)
Build an overloaded binary operator expression in the given scope.
bool DiagnoseAssignmentResult(AssignConvertType ConvTy, SourceLocation Loc, QualType DstType, QualType SrcType, Expr *SrcExpr, AssignmentAction Action, bool *Complained=nullptr)
DiagnoseAssignmentResult - Emit a diagnostic, if required, for the assignment conversion type specifi...
static ValueDecl * getCompareDecl(Expr *E)
An abstract interface that should be implemented by listeners that want to be notified when an AST en...
AsTypeExpr - Clang builtin function __builtin_astype [OpenCL 6.2.4.2] This AST node provides support ...
static void diagnoseUncapturableValueReference(Sema &S, SourceLocation loc, ValueDecl *var, DeclContext *DC)
ImplicitParamDecl * getSelfDecl() const
IncompatiblePointerDiscardsQualifiers - The assignment discards qualifiers that we don't permit to be...
ExprResult CheckPlaceholderExpr(Expr *E)
Check for operands with placeholder types and complain if found.
static FloatingLiteral * Create(const ASTContext &C, const llvm::APFloat &V, bool isexact, QualType Type, SourceLocation L)
Represents a C++ template name within the type system.
static DependentScopeDeclRefExpr * Create(const ASTContext &C, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, const DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *TemplateArgs)
static bool isMSPropertySubscriptExpr(Sema &S, Expr *Base)
isModifiableLvalueResult isModifiableLvalue(ASTContext &Ctx, SourceLocation *Loc=nullptr) const
isModifiableLvalue - C99 6.3.2.1: an lvalue that does not have array type, does not have an incomplet...
bool RequireCompleteType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
Ensure that the type T is a complete type.
Defines the clang::TypeLoc interface and its subclasses.
bool isObjCIdType() const
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7)...
bool hasCustomTypechecking(unsigned ID) const
Determines whether this builtin has custom typechecking.
unsigned getIntMaxTWidth() const
Return the size of intmax_t and uintmax_t for this target, in bits.
bool isInlined() const
Determine whether this function should be inlined, because it is either marked "inline" or "constexpr...
void DiscardCleanupsInEvaluationContext()
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file. ...
FunctionDecl * ResolveSingleFunctionTemplateSpecialization(OverloadExpr *ovl, bool Complain=false, DeclAccessPair *Found=nullptr)
Given an expression that refers to an overloaded function, try to resolve that overloaded function ex...
Specifies that a value-dependent expression of integral or dependent type should be considered a null...
ASTMutationListener * getASTMutationListener() const
QualType getType() const
Get the type for which this source info wrapper provides information.
CleanupInfo ParentCleanup
Whether the enclosing context needed a cleanup.
Capture & getCapture(VarDecl *Var)
Retrieve the capture of the given variable, if it has been captured already.
Expr * getSubExpr() const
ObjCIvarDecl * lookupInstanceVariable(IdentifierInfo *IVarName, ObjCInterfaceDecl *&ClassDeclared)
void DefineImplicitMoveAssignment(SourceLocation CurrentLocation, CXXMethodDecl *MethodDecl)
Defines an implicitly-declared move assignment operator.
static bool TooManyArguments(size_t NumParams, size_t NumArgs, bool PartialOverloading=false)
To be used for checking whether the arguments being passed to function exceeds the number of paramete...
SmallVector< sema::FunctionScopeInfo *, 4 > FunctionScopes
Stack containing information about each of the nested function, block, and method scopes that are cur...
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
bool isInstanceMethod() const
void setValueKind(ExprValueKind Cat)
setValueKind - Set the value kind produced by this expression.
bool isFunctionOrMethod() const
clang::ObjCRuntime ObjCRuntime
bool ResolveAndFixSingleFunctionTemplateSpecialization(ExprResult &SrcExpr, bool DoFunctionPointerConverion=false, bool Complain=false, SourceRange OpRangeForComplaining=SourceRange(), QualType DestTypeForComplaining=QualType(), unsigned DiagIDForComplaining=0)
bool isVLATypeCaptured(const VariableArrayType *VAT) const
Determine whether the given variable-array type has been captured.
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool EvaluateAsInt(llvm::APSInt &Result, const ASTContext &Ctx, SideEffectsKind AllowSideEffects=SE_NoSideEffects) const
EvaluateAsInt - Return true if this is a constant which we can fold and convert to an integer...
QualType getCXXNameType() const
getCXXNameType - If this name is one of the C++ names (of a constructor, destructor, or conversion function), return the type associated with that name.
QualType getObjCIdType() const
Represents the Objective-CC id type.
bool resolveAndFixAddressOfOnlyViableOverloadCandidate(ExprResult &SrcExpr, bool DoFunctionPointerConversion=false)
Given an overloaded function, tries to turn it into a non-overloaded function reference using resolve...
A boolean condition, from 'if', 'while', 'for', or 'do'.
An expression that sends a message to the given Objective-C object or class.
Data structure that captures multiple levels of template argument lists for use in template instantia...
bool isExternallyVisible() const
static UnaryOperatorKind ConvertTokenKindToUnaryOpcode(tok::TokenKind Kind)
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
ArrayRef< ParmVarDecl * > parameters() const
Represents a GCC generic vector type.
ExprResult ActOnChooseExpr(SourceLocation BuiltinLoc, Expr *CondExpr, Expr *LHSExpr, Expr *RHSExpr, SourceLocation RPLoc)
DeclarationName getDeclName() const
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
DiagnosticsEngine & getDiagnostics() const
void CleanupVarDeclMarking()
QualType CheckVectorCompareOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool isRelational)
CheckVectorCompareOperands - vector comparisons are a clang extension that operates on extended vecto...
void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext=true)
Add this decl to the scope shadowed decl chains.
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
Linkage getFormalLinkage() const
Get the linkage from a semantic point of view.
QualType getElementType() const
Represents a C++ conversion function within a class.
The result type of a method or function.
bool isComplexIntegerType() const
This template specialization was implicitly instantiated from a template.
NamedDecl * LookupSingleName(Scope *S, DeclarationName Name, SourceLocation Loc, LookupNameKind NameKind, RedeclarationKind Redecl=NotForRedeclaration)
Look up a name, looking for a single declaration.
unsigned short CapRegionKind
The kind of captured region.
bool RequireCompleteExprType(Expr *E, TypeDiagnoser &Diagnoser)
Ensure that the type of the given expression is complete.
ExprResult BuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo, SourceLocation RParenLoc, Expr *LiteralExpr)
void setBlockMangling(unsigned Number, Decl *Ctx)
void removeCVRQualifiers(unsigned mask)
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
static bool checkArgsForPlaceholders(Sema &S, MultiExprArg args)
Check an argument list for placeholders that we won't try to handle later.
void DefineImplicitDefaultConstructor(SourceLocation CurrentLocation, CXXConstructorDecl *Constructor)
DefineImplicitDefaultConstructor - Checks for feasibility of defining this constructor as the default...
TypeSourceInfo * getTypeSourceInfo() const
static bool hasAnyExplicitStorageClass(const FunctionDecl *D)
Determine whether a FunctionDecl was ever declared with an explicit storage class.
QualType getWideCharType() const
Return the type of wide characters.
ImaginaryLiteral - We support imaginary integer and floating point literals, like "1...
const Expr * getAnyInitializer() const
getAnyInitializer - Get the initializer for this variable, no matter which declaration it is attached...
bool isConstexpr() const
Whether this is a (C++11) constexpr function or constexpr constructor.
decl_type * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
TypeSourceInfo * GetTypeForDeclaratorCast(Declarator &D, QualType FromTy)
static InitializationKind CreateCopy(SourceLocation InitLoc, SourceLocation EqualLoc, bool AllowExplicitConvs=false)
Create a copy initialization.
ExprResult ActOnFinishFullExpr(Expr *Expr)
static void DiagnoseCalleeStaticArrayParam(Sema &S, ParmVarDecl *PVD)
static bool isPlaceholderToRemoveAsArg(QualType type)
Is the given type a placeholder that we need to lower out immediately during argument processing...
ivar_iterator ivar_begin() const
bool isInSystemMacro(SourceLocation loc) const
Returns whether Loc is expanded from a macro in a system header.
static CharSourceRange getCharRange(SourceRange R)
ExprResult BuildCStyleCastExpr(SourceLocation LParenLoc, TypeSourceInfo *Ty, SourceLocation RParenLoc, Expr *Op)
ExprResult ActOnParenExpr(SourceLocation L, SourceLocation R, Expr *E)
bool areLaxCompatibleVectorTypes(QualType srcType, QualType destType)
Are the two types lax-compatible vector types? That is, given that one of them is a vector...
static void diagnoseAddressOfInvalidType(Sema &S, SourceLocation Loc, Expr *E, unsigned Type)
Diagnose invalid operand for address of operations.
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
SourceLocation getEndLoc() const
Get the end source location.
bool isClassMethod() const
bool getNoReturnAttr() const
Determine whether this function type includes the GNU noreturn attribute.
ArrayRef< ParmVarDecl * > parameters() const
void DiagnoseUnusedParameters(ArrayRef< ParmVarDecl * > Parameters)
Diagnose any unused parameters in the given sequence of ParmVarDecl pointers.
static void MarkExprReferenced(Sema &SemaRef, SourceLocation Loc, Decl *D, Expr *E, bool MightBeOdrUse)
static bool isBitwiseOp(Opcode Opc)
Stmt * getBody(const FunctionDecl *&Definition) const
getBody - Retrieve the body (definition) of the function.
bool isInMainFile(SourceLocation Loc) const
Returns whether the PresumedLoc for a given SourceLocation is in the main file.
static Opcode getOverloadedOpcode(OverloadedOperatorKind OO)
Retrieve the binary opcode that corresponds to the given overloaded operator.
void PushBlockScope(Scope *BlockScope, BlockDecl *Block)
static QualType checkConditionalObjectPointersCompatibility(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc)
Return the resulting type when the operands are both pointers.
void checkDeclIsAllowedInOpenMPTarget(Expr *E, Decl *D)
Check declaration inside target region.
Wrapper for source info for arrays.
TypeSourceInfo * CreateTypeSourceInfo(QualType T, unsigned Size=0) const
Allocate an uninitialized TypeSourceInfo.
Expr * IgnoreConversionOperator() LLVM_READONLY
IgnoreConversionOperator - Ignore conversion operator.
static bool checkArithmeticIncompletePointerType(Sema &S, SourceLocation Loc, Expr *Operand)
Emit error if Operand is incomplete pointer type.
SourceRange getReturnTypeSourceRange() const
Attempt to compute an informative source range covering the function return type. ...
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
bool EvaluateAsBooleanCondition(bool &Result, const ASTContext &Ctx) const
EvaluateAsBooleanCondition - Return true if this is a constant which we we can fold and convert to a ...
int getIntegerTypeOrder(QualType LHS, QualType RHS) const
Return the highest ranked integer type, see C99 6.3.1.8p1.
ExprResult MaybeBindToTemporary(Expr *E)
MaybeBindToTemporary - If the passed in expression has a record type with a non-trivial destructor...
Assigning into this object requires the old value to be released and the new value to be retained...
DeclarationNameInfo getNameForTemplate(TemplateName Name, SourceLocation NameLoc) const
A reference to an overloaded function set, either an UnresolvedLookupExpr or an UnresolvedMemberExpr...
ImplicitConversionSequence - Represents an implicit conversion sequence, which may be a standard conv...
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
bool CheckCaseExpression(Expr *E)
not a target-specific vector type
ExprResult LookupInObjCMethod(LookupResult &LookUp, Scope *S, IdentifierInfo *II, bool AllowBuiltinCreation=false)
LookupInObjCMethod - The parser has read a name in, and Sema has detected that we're currently inside...
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
A stack object to be created when performing template instantiation.
ExprResult CreateGenericSelectionExpr(SourceLocation KeyLoc, SourceLocation DefaultLoc, SourceLocation RParenLoc, Expr *ControllingExpr, ArrayRef< TypeSourceInfo * > Types, ArrayRef< Expr * > Exprs)
bool HasPotentialAvailabilityViolations
Whether we make reference to a declaration that could be unavailable.
SourceLocation getOuterLocStart() const
getOuterLocStart - Return SourceLocation representing start of source range taking into account any o...
Encodes a location in the source.
ExprResult ActOnConvertVectorExpr(Expr *E, ParsedType ParsedDestTy, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
__builtin_convertvector(...)
bool hasIntegerRepresentation() const
Determine whether this type has an integer representation of some sort, e.g., it is an integer type o...
llvm::SmallPtrSet< Expr *, 2 > MaybeODRUseExprs
Store a list of either DeclRefExprs or MemberExprs that contain a reference to a variable (constant) ...
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
bool CheckForConstantInitializer(Expr *e, QualType t)
type checking declaration initializers (C99 6.7.8)
unsigned getNumParams() const
getNumParams - Return the number of parameters this function must have based on its FunctionType...
llvm::APFloat::opStatus GetFloatValue(llvm::APFloat &Result)
GetFloatValue - Convert this numeric literal to a floating value, using the specified APFloat fltSema...
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
llvm::SmallPtrSet< Expr *, 2 > SavedMaybeODRUseExprs
CastKind PrepareCastToObjCObjectPointer(ExprResult &E)
Prepare a conversion of the given expression to an ObjC object pointer type.
QualType getElementType() const
This represents '#pragma omp declare reduction ...' directive.
QualType withCVRQualifiers(unsigned CVR) const
Expression is not a Null pointer constant.
VarArgKind isValidVarArgType(const QualType &Ty)
Determine the degree of POD-ness for an expression.
Interfaces are the core concept in Objective-C for object oriented design.
static void SuggestParentheses(Sema &Self, SourceLocation Loc, const PartialDiagnostic &Note, SourceRange ParenRange)
SuggestParentheses - Emit a note with a fixit hint that wraps ParenRange in parentheses.
void checkRetainCycles(ObjCMessageExpr *msg)
checkRetainCycles - Check whether an Objective-C message send might create an obvious retain cycle...
CXXRecordDecl * Lambda
The class that describes the lambda.
const TemplateArgumentListInfo & getTemplateArgsInfo() const
void DiagnoseAssignmentEnum(QualType DstType, QualType SrcType, Expr *SrcExpr)
DiagnoseAssignmentEnum - Warn if assignment to enum is a constant integer not in the range of enum va...
static QualType CheckCommaOperands(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc)
bool ConversionToObjCStringLiteralCheck(QualType DstType, Expr *&SrcExpr, bool Diagnose=true)
bool isComplexType() const
isComplexType() does not include complex integers (a GCC extension).
VarDecl * IsOpenMPCapturedDecl(ValueDecl *D)
Check if the specified variable is used in one of the private clauses (private, firstprivate, lastprivate, reduction etc.) in OpenMP constructs.
bool isValid() const
Return true if this is a valid SourceLocation object.
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)"...
static ValueDecl * getPrimaryDecl(Expr *E)
getPrimaryDecl - Helper function for CheckAddressOfOperand().
void setLastStmt(Stmt *S)
static void warnOnSizeofOnArrayDecay(Sema &S, SourceLocation Loc, QualType T, Expr *E)
Check whether E is a pointer from a decayed array type (the decayed pointer type is equal to T) and e...
static bool IgnoreCommaOperand(const Expr *E)
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
StringRef getNameForSlot(unsigned argIndex) const
Retrieve the name at a given position in the selector.
bool isInOpenMPDeclareTargetContext() const
Return true inside OpenMP target region.
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location, which defaults to the empty location.
ASTContext & getASTContext() const
bool refersToEnclosingVariableOrCapture() const
Does this DeclRefExpr refer to an enclosing local or a captured variable?
void setReferenced(bool R=true)
LabelDecl - Represents the declaration of a label.
IncompatiblePointer - The assignment is between two pointers types that are not compatible, but we accept them as an extension.
void DefineImplicitDestructor(SourceLocation CurrentLocation, CXXDestructorDecl *Destructor)
DefineImplicitDestructor - Checks for feasibility of defining this destructor as the default destruct...
VectorKind getVectorKind() const
llvm::APSInt EvaluateKnownConstInt(const ASTContext &Ctx, SmallVectorImpl< PartialDiagnosticAt > *Diag=nullptr) const
EvaluateKnownConstInt - Call EvaluateAsRValue and return the folded integer.
ExprResult ActOnCharacterConstant(const Token &Tok, Scope *UDLScope=nullptr)
QualType withConst() const
ExprObjectKind
A further classification of the kind of object referenced by an l-value or x-value.
SourceLocation getLocStart() const LLVM_READONLY
Represents a static or instance method of a struct/union/class.
bool isObjCBuiltinType() const
void setIdentifierInfo(IdentifierInfo *II)
ExprResult TransformToPotentiallyEvaluated(Expr *E)
StmtVisitor - This class implements a simple visitor for Stmt subclasses.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
ExprResult DefaultLvalueConversion(Expr *E)
static InitializedEntity InitializeCompoundLiteralInit(TypeSourceInfo *TSI)
Create the entity for a compound literal initializer.
ExtInfo withNoReturn(bool noReturn) const
bool CheckObjCARCUnavailableWeakConversion(QualType castType, QualType ExprType)
bool isInvalid() const
An error occurred during parsing of the scope specifier.
QualType getObjCSelRedefinitionType() const
Retrieve the type that 'SEL' has been defined to, which may be different from the built-in 'SEL' if '...
bool isCXX98PODType(const ASTContext &Context) const
Return true if this is a POD type according to the rules of the C++98 standard, regardless of the cur...
bool isIntegralType(const ASTContext &Ctx) const
Determine whether this type is an integral type.
const ConstantArrayType * getAsConstantArrayType(QualType T) const
bool isIntegerConstantExpr(llvm::APSInt &Result, const ASTContext &Ctx, SourceLocation *Loc=nullptr, bool isEvaluated=true) const
isIntegerConstantExpr - Return true if this expression is a valid integer constant expression...
ExprResult ActOnInitList(SourceLocation LBraceLoc, MultiExprArg InitArgList, SourceLocation RBraceLoc)
Specifies that a value-dependent expression should be considered to never be a null pointer constant...
ExprResult CheckCXXBooleanCondition(Expr *CondExpr, bool IsConstexpr=false)
CheckCXXBooleanCondition - Returns true if conversion to bool is invalid.
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
Describes the kind of initialization being performed, along with location information for tokens rela...
AssignConvertType CheckTransparentUnionArgumentConstraints(QualType ArgType, ExprResult &RHS)
is AltiVec 'vector bool ...'
SmallVector< Capture, 4 > Captures
Captures - The captures.
virtual BuiltinVaListKind getBuiltinVaListKind() const =0
Returns the kind of __builtin_va_list type that should be used with this target.
unsigned NumTypos
The number of typos encountered during this expression evaluation context (i.e.
Represents one property declaration in an Objective-C interface.
bool hasBuiltinMSVaList() const
Returns whether or not type __builtin_ms_va_list type is available on this target.
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
std::pair< SourceLocation, PartialDiagnostic > PartialDiagnosticAt
A partial diagnostic along with the source location where this diagnostic occurs. ...
static QualType findBoundMemberType(const Expr *expr)
Given an expression of bound-member type, find the type of the member.
QualType CheckCompareOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc, bool isRelational)
QualType getReturnType() const
SourceLocation getBegin() const
virtual void diagnoseFold(Sema &S, SourceLocation Loc, SourceRange SR)
bool isTypeDependent() const
isTypeDependent - Determines whether this expression is type-dependent (C++ [temp.dep.expr]), which means that its type could change from one template instantiation to the next.
const T * castAs() const
Member-template castAs<specific type>.
MangleNumberingContext * getCurrentMangleNumberContext(const DeclContext *DC, Decl *&ManglingContextDecl)
Compute the mangling number context for a lambda expression or block literal.
SourceLocation getBeginLoc() const
ExprResult ActOnOMPArraySectionExpr(Expr *Base, SourceLocation LBLoc, Expr *LowerBound, SourceLocation ColonLoc, Expr *Length, SourceLocation RBLoc)
void setKind(IdKind kind)
void MarkVTableUsed(SourceLocation Loc, CXXRecordDecl *Class, bool DefinitionRequired=false)
Note that the vtable for the given class was used at the given location.
QualType getAttributedType(AttributedType::Kind attrKind, QualType modifiedType, QualType equivalentType)
This template specialization was formed from a template-id but has not yet been declared, defined, or instantiated.
bool typesAreBlockPointerCompatible(QualType, QualType)
bool isVectorType() const
unsigned getBuiltinID() const
Returns a value indicating whether this function corresponds to a builtin function.
bool isPromotableIntegerType() const
More type predicates useful for type checking/promotion.
sema::FunctionScopeInfo * getCurFunction() const
Assigning into this object requires a lifetime extension.
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
OverloadCandidateSet - A set of overload candidates, used in C++ overload resolution (C++ 13...
const ArgList & getInnermost() const
Retrieve the innermost template argument list.
ExprResult PerformOpenMPImplicitIntegerConversion(SourceLocation OpLoc, Expr *Op)
ExprResult HandleExprEvaluationContextForTypeof(Expr *E)
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
const BlockDecl * getBlockDecl() const
bool refersToBitField() const
Returns true if this expression is a gl-value that potentially refers to a bit-field.
void setLAngleLoc(SourceLocation Loc)
ExprResult BuildCallToObjectOfClassType(Scope *S, Expr *Object, SourceLocation LParenLoc, MultiExprArg Args, SourceLocation RParenLoc)
BuildCallToObjectOfClassType - Build a call to an object of class type (C++ [over.call.object]), which can end up invoking an overloaded function call operator (operator()) or performing a user-defined conversion on the object argument.
QualType getType() const
Return the type wrapped by this type source info.
void addArgument(const TemplateArgumentLoc &Loc)
static QualType checkVectorShift(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign)
Return the resulting type when a vector is shifted by a scalar or vector shift amount.
static unsigned isEnabled(DiagnosticsEngine &D, unsigned diag)
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
ExprResult ActOnStmtExpr(SourceLocation LPLoc, Stmt *SubStmt, SourceLocation RPLoc)
QualType CXXCheckConditionalOperands(ExprResult &cond, ExprResult &lhs, ExprResult &rhs, ExprValueKind &VK, ExprObjectKind &OK, SourceLocation questionLoc)
Check the operands of ?: under C++ semantics.
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
QualType getPointeeType() const
SourceLocation getOperatorLoc() const
getOperatorLoc - Return the location of the operator.
static void DiagnoseBadShiftValues(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc, QualType LHSType)
ExprResult PerformCastFn(Sema &S, Expr *operand, QualType toType)
ExprResult checkUnknownAnyCast(SourceRange TypeRange, QualType CastType, Expr *CastExpr, CastKind &CastKind, ExprValueKind &VK, CXXCastPath &Path)
Check a cast of an unknown-any type.
CompoundAssignOperator - For compound assignments (e.g.
A POD class for pairing a NamedDecl* with an access specifier.
bool isAdditiveOp() const
void maybeExtendBlockObject(ExprResult &E)
Do an explicit extend of the given block pointer if we're in ARC.
Represents a C11 generic selection.
void setTemplateSpecializationKind(TemplateSpecializationKind TSK, SourceLocation PointOfInstantiation=SourceLocation())
For a static data member that was instantiated from a static data member of a class template...
bool isInitCapture() const
Whether this variable is the implicit variable for a lambda init-capture.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
Represents an element in a path from a derived class to a base class.
AddrLabelExpr - The GNU address of label extension, representing &&label.
void diagnoseTypo(const TypoCorrection &Correction, const PartialDiagnostic &TypoDiag, bool ErrorRecovery=true)
void MarkMemberReferenced(MemberExpr *E)
Perform reference-marking and odr-use handling for a MemberExpr.
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T-> getSizeExpr()))
Represents a template argument.
ExprResult PerformCopyInitialization(const InitializedEntity &Entity, SourceLocation EqualLoc, ExprResult Init, bool TopLevelOfInitList=false, bool AllowExplicit=false)
QualType getMemberPointerType(QualType T, const Type *Cls) const
Return the uniqued reference to the type for a member pointer to the specified type in the specified ...
void DecomposeUnqualifiedId(const UnqualifiedId &Id, TemplateArgumentListInfo &Buffer, DeclarationNameInfo &NameInfo, const TemplateArgumentListInfo *&TemplateArgs)
Decomposes the given name into a DeclarationNameInfo, its location, and possibly a list of template a...
static bool isInvalid(LocType Loc, bool *Invalid)
NonConstCaptureKind
Is the given expression (which must be 'const') a reference to a variable which was originally non-co...
static void ConstructTransparentUnion(Sema &S, ASTContext &C, ExprResult &EResult, QualType UnionType, FieldDecl *Field)
Constructs a transparent union from an expression that is used to initialize the transparent union...
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
void setBody(CompoundStmt *B)
void checkUnusedDeclAttributes(Declarator &D)
checkUnusedDeclAttributes - Given a declarator which is not being used to build a declaration...
StringRef getOpcodeStr() const
const Expr * getExpr() const
ParmVarDecl * BuildParmVarDeclForTypedef(DeclContext *DC, SourceLocation Loc, QualType T)
Synthesizes a variable for a parameter arising from a typedef.
ExprResult BuildObjCStringLiteral(SourceLocation AtLoc, StringLiteral *S)
Qualifiers withoutObjCLifetime() const
static bool isScopedEnumerationType(QualType T)
QualType mergeTypes(QualType, QualType, bool OfBlockPointer=false, bool Unqualified=false, bool BlockReturnType=false)
[C99 6.4.2.2] - A predefined identifier such as func.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
TypedefDecl * getBOOLDecl() const
Retrieve declaration of 'BOOL' typedef.
EvalResult is a struct with detailed info about an evaluated expression.
ExprResult ActOnUnaryOp(Scope *S, SourceLocation OpLoc, tok::TokenKind Op, Expr *Input)
Represents a delete expression for memory deallocation and destructor calls, e.g. ...
static void diagnoseStringPlusInt(Sema &Self, SourceLocation OpLoc, Expr *LHSExpr, Expr *RHSExpr)
diagnoseStringPlusInt - Emit a warning when adding an integer to a string literal.
bool isSentinelNullExpr(const Expr *E)
The base class of all kinds of template declarations (e.g., class, function, etc.).
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
bool hasUnparsedDefaultArg() const
hasUnparsedDefaultArg - Determines whether this parameter has a default argument that has not yet bee...
bool isZero() const
isZero - Test whether the quantity equals zero.
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
void deduceClosureReturnType(sema::CapturingScopeInfo &CSI)
Deduce a block or lambda's return type based on the return statements present in the body...
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return 0.
QualType GetSignedVectorType(QualType V)
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
ExprResult checkPseudoObjectAssignment(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opcode, Expr *LHS, Expr *RHS)
ExprResult ImpCastExprToType(Expr *E, QualType Type, CastKind CK, ExprValueKind VK=VK_RValue, const CXXCastPath *BasePath=nullptr, CheckedConversionKind CCK=CCK_ImplicitConversion)
ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.
typedef char* __builtin_va_list;
static bool unsupportedTypeConversion(const Sema &S, QualType LHSType, QualType RHSType)
Diagnose attempts to convert between __float128 and long double if there is no support for such conve...
static bool CheckAlignOfExpr(Sema &S, Expr *E)
The current expression occurs within an unevaluated operand that unconditionally permits abstract ref...
SourceLocation RAngleLoc
The location of the '>' after the template argument list.
bool isInvalidDecl() const
ObjCLiteralKind CheckLiteralKind(Expr *FromE)
static bool IsVariableNonDependentAndAConstantExpression(VarDecl *Var, ASTContext &Context)
IndirectFieldDecl - An instance of this class is created to represent a field injected from an anonym...
void HandleFunctionTypeMismatch(PartialDiagnostic &PDiag, QualType FromType, QualType ToType)
HandleFunctionTypeMismatch - Gives diagnostic information for differeing function types...
TypeLoc IgnoreParens() const
static bool tryVectorConvertAndSplat(Sema &S, ExprResult *scalar, QualType scalarTy, QualType vectorEltTy, QualType vectorTy, unsigned &DiagID)
Try to convert a value of non-vector type to a vector type by converting the type to the element type...
ExprResult ActOnAsTypeExpr(Expr *E, ParsedType ParsedDestTy, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
__builtin_astype(...)
bool DiagRuntimeBehavior(SourceLocation Loc, const Stmt *Statement, const PartialDiagnostic &PD)
Conditionally issue a diagnostic based on the current evaluation context.
BinaryOperator::Opcode getOpcode(const SymExpr *SE)
bool DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false, bool AvoidPartialAvailabilityChecks=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics...
static void checkArithmeticNull(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompare)
CanQualType UnsignedLongLongTy
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
void CheckCompatibleReinterpretCast(QualType SrcType, QualType DestType, bool IsDereference, SourceRange Range)
A constant boolean condition from 'if constexpr'.
A runtime availability query.
const ObjCInterfaceType * getInterfaceType() const
If this pointer points to an Objective C @interface type, gets the type for that interface.
unsigned CXXThisCaptureIndex
CXXThisCaptureIndex - The (index+1) of the capture of 'this'; zero if 'this' is not captured...
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
bool CheckUnaryExprOrTypeTraitOperand(Expr *E, UnaryExprOrTypeTrait ExprKind)
Check the constraints on expression operands to unary type expression and type traits.
DeclarationName - The name of a declaration.
static ExprResult BuildCookedLiteralOperatorCall(Sema &S, Scope *Scope, IdentifierInfo *UDSuffix, SourceLocation UDSuffixLoc, ArrayRef< Expr * > Args, SourceLocation LitEndLoc)
BuildCookedLiteralOperatorCall - A user-defined literal was found.
void setInstantiationIsPending(bool IC)
static ExprResult rebuildUnknownAnyFunction(Sema &S, Expr *fn)
Given a function expression of unknown-any type, try to rebuild it to have a function type...
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
bool tryToRecoverWithCall(ExprResult &E, const PartialDiagnostic &PD, bool ForceComplain=false, bool(*IsPlausibleResult)(QualType)=nullptr)
Try to recover by turning the given expression into a call.
OverloadExpr * Expression
bool isUsed(bool CheckUsedAttr=true) const
Whether any (re-)declaration of the entity was used, meaning that a definition is required...
bool isLValue() const
isLValue - True if this expression is an "l-value" according to the rules of the current language...
void PushDeclContext(Scope *S, DeclContext *DC)
Set the current declaration context until it gets popped.
bool hasDefinition() const
Determine whether this protocol has a definition.
Expression is a Null pointer constant built from a zero integer expression that is not a simple...
U cast(CodeGen::Address addr)
virtual void HandleCXXImplicitFunctionInstantiation(FunctionDecl *D)
Invoked when a function is implicitly instantiated.
ExprResult prepareVectorSplat(QualType VectorTy, Expr *SplattedExpr)
Prepare SplattedExpr for a vector splat operation, adding implicit casts if necessary.
A set of unresolved declarations.
bool isCopyCapture() const
SourceLocation getLocStart() const LLVM_READONLY
size_t param_size() const
bool isDefinedOutsideFunctionOrMethod() const
isDefinedOutsideFunctionOrMethod - This predicate returns true if this scoped decl is defined outside...
virtual void diagnoseNotICE(Sema &S, SourceLocation Loc, SourceRange SR)=0
IncompatibleBlockPointer - The assignment is between two block pointers types that are not compatible...
Expression is a C++11 nullptr.
static void diagnoseLogicalNotOnLHSofCheck(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
Warns on !x < y, !x & y where !(x < y), !(x & y) was probably intended.
detail::InMemoryDirectory::const_iterator E
bool inTemplateInstantiation() const
Determine whether we are currently performing template instantiation.
static void EmitDiagnosticForLogicalAndInLogicalOr(Sema &Self, SourceLocation OpLoc, BinaryOperator *Bop)
It accepts a '&&' expr that is inside a '||' one.
TemplateSpecializationKind
Describes the kind of template specialization that a particular template specialization declaration r...
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
bool isSingleResult() const
Determines if this names a single result which is not an unresolved value using decl.
static InitializationKind CreateCStyleCast(SourceLocation StartLoc, SourceRange TypeRange, bool InitList)
Create a direct initialization for a C-style cast.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
static CastKind ScalarTypeToBooleanCastKind(QualType ScalarTy)
ScalarTypeToBooleanCastKind - Returns the cast kind corresponding to the conversion from scalar type ...
bool hasAnyDependentBases() const
Determine whether this class has any dependent base classes which are not the current instantiation...
unsigned short OpenMPLevel
ExplicitCastExpr - An explicit cast written in the source code.
static bool checkArithmeticOnObjCPointer(Sema &S, SourceLocation opLoc, Expr *op)
Diagnose if arithmetic on the given ObjC pointer is illegal.
ExprResult ActOnPredefinedExpr(SourceLocation Loc, tok::TokenKind Kind)
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
void setInitializedFieldInUnion(FieldDecl *FD)
NamedDecl * getCurFunctionOrMethodDecl()
getCurFunctionOrMethodDecl - Return the Decl for the current ObjC method or C function we're in...
QualType getCorrespondingUnsignedType(QualType T) const
ExprResult ActOnConstantExpression(ExprResult Res)
DeclClass * getCorrectionDeclAs() const
bool isEditorPlaceholder() const
Return true if this identifier is an editor placeholder.
ExprResult SemaConvertVectorExpr(Expr *E, TypeSourceInfo *TInfo, SourceLocation BuiltinLoc, SourceLocation RParenLoc)
SemaConvertVectorExpr - Handle __builtin_convertvector.
DeclarationName getCorrection() const
Gets the DeclarationName of the typo correction.
bool areComparableObjCPointerTypes(QualType LHS, QualType RHS)
QualType getBuiltinVaListType() const
Retrieve the type of the __builtin_va_list type.
Expr * IgnoreParenImpCasts() LLVM_READONLY
IgnoreParenImpCasts - Ignore parentheses and implicit casts.
QualType getPointeeType() const
Gets the type pointed to by this ObjC pointer.
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
ExprResult checkPseudoObjectRValue(Expr *E)
void markSafeWeakUse(const Expr *E)
Record that a given expression is a "safe" access of a weak object (e.g.
ExprResult IgnoredValueConversions(Expr *E)
IgnoredValueConversions - Given that an expression's result is syntactically ignored, perform any conversions that are required.
void LookupOverloadedOperatorName(OverloadedOperatorKind Op, Scope *S, QualType T1, QualType T2, UnresolvedSetImpl &Functions)
Represents a pointer to an Objective C object.
SourceLocation getMemberLoc() const
getMemberLoc - Return the location of the "member", in X->F, it is the location of 'F'...
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
QualType getBuiltinMSVaListType() const
Retrieve the type of the __builtin_ms_va_list type.
CanQualType ObjCBuiltinBoolTy
The standard open() call: int open(const char *path, int oflag, ...);.
ObjCMethodDecl * LookupInstanceMethodInGlobalPool(Selector Sel, SourceRange R, bool receiverIdOrClass=false)
LookupInstanceMethodInGlobalPool - Returns the method and warns if there are multiple signatures...
static bool EvaluatesAsFalse(Sema &S, Expr *E)
Returns true if the given expression can be evaluated as a constant 'false'.
bool empty() const
Return true if no decls were found.
static void DiagnoseBadDivideOrRemainderValues(Sema &S, ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsDiv)
bool isObjCObjectType() const
Not an overloaded operator.
RecordDecl * TheRecordDecl
The captured record type.
ExprResult ActOnUnaryExprOrTypeTraitExpr(SourceLocation OpLoc, UnaryExprOrTypeTrait ExprKind, bool IsType, void *TyOrEx, SourceRange ArgRange)
ActOnUnaryExprOrTypeTraitExpr - Handle sizeof(type) and sizeof expr and the same for alignof and __al...
bool HasSideEffects
Whether the evaluated expression has side effects.
ExprResult CreateOverloadedArraySubscriptExpr(SourceLocation LLoc, SourceLocation RLoc, Expr *Base, Expr *Idx)
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Complex values, per C99 6.2.5p11.
Location wrapper for a TemplateArgument.
QualType getPointerDiffType() const
Return the unique type for "ptrdiff_t" (C99 7.17) defined in <stddef.h>.
Expr * getUninstantiatedDefaultArg()
SourceManager & getSourceManager() const
FunctionDecl * getOperatorNew() const
const T * getAs() const
Member-template getAs<specific type>'.
ExprResult BuildLiteralOperatorCall(LookupResult &R, DeclarationNameInfo &SuffixInfo, ArrayRef< Expr * > Args, SourceLocation LitEndLoc, TemplateArgumentListInfo *ExplicitTemplateArgs=nullptr)
BuildLiteralOperatorCall - Build a UserDefinedLiteral by creating a call to a literal operator descri...
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
CXXMethodDecl * getDevirtualizedMethod(const Expr *Base, bool IsAppleKext)
If it's possible to devirtualize a call to this method, return the called function.
bool ConvertArgumentsForCall(CallExpr *Call, Expr *Fn, FunctionDecl *FDecl, const FunctionProtoType *Proto, ArrayRef< Expr * > Args, SourceLocation RParenLoc, bool ExecConfig=false)
ConvertArgumentsForCall - Converts the arguments specified in Args/NumArgs to the parameter types of ...
bool isAddressSpaceOverlapping(const PointerType &other) const
Returns true if address spaces of pointers overlap.
QualType getCanonicalType() const
static QualType OpenCLCheckVectorConditional(Sema &S, ExprResult &Cond, ExprResult &LHS, ExprResult &RHS, SourceLocation QuestionLoc)
Return the resulting type for the conditional operator in OpenCL (aka "ternary selection operator"...
void PushExpressionEvaluationContext(ExpressionEvaluationContext NewContext, Decl *LambdaContextDecl=nullptr, bool IsDecltype=false)
IntToBlockPointer - The assignment converts an int to a block pointer.
ExprResult BuildQualifiedDeclarationNameExpr(CXXScopeSpec &SS, const DeclarationNameInfo &NameInfo, bool IsAddressOfOperand, const Scope *S, TypeSourceInfo **RecoveryTSI=nullptr)
BuildQualifiedDeclarationNameExpr - Build a C++ qualified declaration name, generally during template...
CanQualType UnsignedLongTy
ObjCInterfaceDecl * getInterfaceDecl() const
If this pointer points to an Objective @interface type, gets the declaration for that interface...
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
TemplateSpecializationKind getTemplateSpecializationKind() const
Determine what kind of template instantiation this function represents.
bool areCompatibleVectorTypes(QualType FirstVec, QualType SecondVec)
Return true if the given vector types are of the same unqualified type or if they are equivalent to t...
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
ExprResult CheckExtVectorCast(SourceRange R, QualType DestTy, Expr *CastExpr, CastKind &Kind)
static void DiagnoseAdditionInShift(Sema &S, SourceLocation OpLoc, Expr *SubExpr, StringRef Shift)
void setSubExpr(Expr *E)
As with any mutator of the AST, be very careful when modifying an existing AST to preserve its invari...
FunctionDecl * getCurFunctionDecl()
getCurFunctionDecl - If inside of a function body, this returns a pointer to the function decl for th...
QualType CheckPointerToMemberOperands(ExprResult &LHS, ExprResult &RHS, ExprValueKind &VK, SourceLocation OpLoc, bool isIndirect)
static bool checkArithmeticBinOpPointerOperands(Sema &S, SourceLocation Loc, Expr *LHSExpr, Expr *RHSExpr)
Check the validity of a binary arithmetic operation w.r.t.
Represents a call to a CUDA kernel function.
bool isObjCQualifiedIdType() const
NamedDecl * getFoundDecl() const
Get the correction declaration found by name lookup (before we looked through using shadow declaratio...
SourceLocation getLocStart() const LLVM_READONLY
static SourceLocation getUDSuffixLoc(Sema &S, SourceLocation TokLoc, unsigned Offset)
getUDSuffixLoc - Create a SourceLocation for a ud-suffix, given the location of the token and the off...
bool isFunctionType() const
ExtVectorType - Extended vector type.
MaterializeTemporaryExpr * CreateMaterializeTemporaryExpr(QualType T, Expr *Temporary, bool BoundToLvalueReference)
Base for LValueReferenceType and RValueReferenceType.
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
CXXConstructorDecl * getConstructor() const
Get the constructor that this expression will (ultimately) call.
CanQualType BoundMemberTy
ActionResult< Stmt * > StmtResult
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
unsigned getAddressSpace() const
bool isCodeCompletionEnabled() const
Determine if we are performing code completion.
static Sema::AssignConvertType checkBlockPointerTypesForAssignment(Sema &S, QualType LHSType, QualType RHSType)
checkBlockPointerTypesForAssignment - This routine determines whether two block pointer types are com...
ExprResult CreateBuiltinUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc, Expr *InputExpr)
uint64_t getCharWidth() const
Return the size of the character type, in bits.
std::string getAsString(const LangOptions &LO) const
static QualType CheckIncrementDecrementOperand(Sema &S, Expr *Op, ExprValueKind &VK, ExprObjectKind &OK, SourceLocation OpLoc, bool IsInc, bool IsPrefix)
CheckIncrementDecrementOperand - unlike most "Check" methods, this routine doesn't need to call Usu...
QualType getObjCIdRedefinitionType() const
Retrieve the type that id has been defined to, which may be different from the built-in id if id has ...
SourceLocation getLocStart() const LLVM_READONLY
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
static bool CheckDeclInExpr(Sema &S, SourceLocation Loc, NamedDecl *D)
Diagnoses obvious problems with the use of the given declaration as an expression.
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
void addDecl(Decl *D)
Add the declaration D into this context.
bool canAssignObjCInterfaces(const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT)
canAssignObjCInterfaces - Return true if the two interface types are compatible for assignment from R...
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream...
unsigned getIntWidth() const
getIntWidth/Align - Return the size of 'signed int' and 'unsigned int' for this target, in bits.
unsigned getLongLongWidth() const
getLongLongWidth/Align - Return the size of 'signed long long' and 'unsigned long long' for this targ...
A template-id, e.g., f<int>.
llvm::DenseMap< VarDecl *, unsigned > CaptureMap
CaptureMap - A map of captured variables to (index+1) into Captures.
void setExprNeedsCleanups(bool SideEffects)
SmallVector< BlockDecl *, 8 > ExprCleanupObjects
ExprCleanupObjects - This is the stack of objects requiring cleanup that are created by the current f...
bool isUnevaluated() const
ExprResult ActOnBuiltinOffsetOf(Scope *S, SourceLocation BuiltinLoc, SourceLocation TypeLoc, ParsedType ParsedArgTy, ArrayRef< OffsetOfComponent > Components, SourceLocation RParenLoc)
A bitfield object is a bitfield on a C or C++ record.
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
static bool tryGCCVectorConvertAndSplat(Sema &S, ExprResult *Scalar, ExprResult *Vector)
Attempt to convert and splat Scalar into a vector whose types matches Vector following GCC conversion...
void markUsed(ASTContext &C)
Mark the declaration used, in the sense of odr-use.
void DiagnoseSentinelCalls(NamedDecl *D, SourceLocation Loc, ArrayRef< Expr * > Args)
DiagnoseSentinelCalls - This routine checks whether a call or message-send is to a declaration with t...
ObjCIvarRefExpr - A reference to an ObjC instance variable.
This is a scope that can contain a declaration.
void DiscardMisalignedMemberAddress(const Type *T, Expr *E)
This function checks if the expression is in the sef of potentially misaligned members and it is conv...
static void diagnoseDistinctPointerComparison(Sema &S, SourceLocation Loc, ExprResult &LHS, ExprResult &RHS, bool IsError)
Diagnose bad pointer comparisons.
QualType InvalidOperands(SourceLocation Loc, ExprResult &LHS, ExprResult &RHS)
the following "Check" methods will return a valid/converted QualType or a null QualType (indicating a...
IdentifierInfo * getIdentifier() const
uint64_t getPointerWidth(unsigned AddrSpace) const
Return the width of pointers on this target, for the specified address space.
ExprResult ActOnIdExpression(Scope *S, CXXScopeSpec &SS, SourceLocation TemplateKWLoc, UnqualifiedId &Id, bool HasTrailingLParen, bool IsAddressOfOperand, std::unique_ptr< CorrectionCandidateCallback > CCC=nullptr, bool IsInlineAsmIdentifier=false, Token *KeywordReplacement=nullptr)
bool checkAddressOfFunctionIsAvailable(const FunctionDecl *Function, bool Complain=false, SourceLocation Loc=SourceLocation())
Returns whether the given function's address can be taken or not, optionally emitting a diagnostic if...
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
Scope * getScopeForContext(DeclContext *Ctx)
Determines the active Scope associated with the given declaration context.
const DeclContext * getCurObjCLexicalContext() const
SourceRange getCorrectionRange() const
static BlockDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L)
AccessControl getAccessControl() const
Reading or writing from this object requires a barrier call.
An integral condition for a 'switch' statement.
ExprResult CreateUnaryExprOrTypeTraitExpr(TypeSourceInfo *TInfo, SourceLocation OpLoc, UnaryExprOrTypeTrait ExprKind, SourceRange R)
Build a sizeof or alignof expression given a type operand.
void DefineImplicitLambdaToBlockPointerConversion(SourceLocation CurrentLoc, CXXConversionDecl *Conv)
Define the "body" of the conversion from a lambda object to a block pointer.
An attributed type is a type to which a type attribute has been applied.
unsigned getFullDataSize() const
Returns the size of the type source info data block.
bool hasAddressSpace() const
ExprResult DefaultVariadicArgumentPromotion(Expr *E, VariadicCallType CT, FunctionDecl *FDecl)
DefaultVariadicArgumentPromotion - Like DefaultArgumentPromotion, but will create a trap if the resul...
Expression is a Null pointer constant built from a literal zero.
Expr * MaybeCreateExprWithCleanups(Expr *SubExpr)
MaybeCreateExprWithCleanups - If the current full-expression requires any cleanups, surround it with a ExprWithCleanups node.
ExprResult BuildDeclRefExpr(ValueDecl *D, QualType Ty, ExprValueKind VK, SourceLocation Loc, const CXXScopeSpec *SS=nullptr)
bool typesAreCompatible(QualType T1, QualType T2, bool CompareUnqualified=false)
Compatibility predicates used to check assignment expressions.
bool isBlockCompatibleObjCPointerType(ASTContext &ctx) const
static void DoMarkVarDeclReferenced(Sema &SemaRef, SourceLocation Loc, VarDecl *Var, Expr *E)
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
bool DiagnoseUnexpandedParameterPack(SourceLocation Loc, TypeSourceInfo *T, UnexpandedParameterPackContext UPPC)
If the given type contains an unexpanded parameter pack, diagnose the error.
Data structure used to record current or nested expression evaluation contexts.
const Expr * getSubExpr() const
QualType CheckBitwiseOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, BinaryOperatorKind Opc)
Describes the sequence of initializations required to initialize a given object or reference with a s...
bool isARCPseudoStrong() const
Determine whether this variable is an ARC pseudo-__strong variable.
Policy getDefaultPolicy()
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
void ProcessDeclAttributes(Scope *S, Decl *D, const Declarator &PD)
ProcessDeclAttributes - Given a declarator (PD) with attributes indicated in it, apply them to D...
static QualType handleFloatConversion(Sema &S, ExprResult &LHS, ExprResult &RHS, QualType LHSType, QualType RHSType, bool IsCompAssign)
Handle arithmethic conversion with floating point types.
void setDefaultArg(Expr *defarg)
static bool isObjCObjectLiteral(ExprResult &E)
Represents a C++ struct/union/class.
Compatible - the types are compatible according to the standard.
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
bool isObjCObjectPointerType() const
bool isPlaceholderType() const
Test for a type which does not represent an actual type-system type but is instead used as a placehol...
SourceLocation getLocStart() const LLVM_READONLY
static QualType getBaseOriginalType(const Expr *Base)
Return original type of the base expression for array section.
ChooseExpr - GNU builtin-in function __builtin_choose_expr.
static bool IsArithmeticBinaryExpr(Expr *E, BinaryOperatorKind *Opcode, Expr **RHSExprs)
IsArithmeticBinaryExpr - Returns true if E is an arithmetic binary expression, either using a built-i...
Optional< sema::TemplateDeductionInfo * > isSFINAEContext() const
Determines whether we are currently in a context where template argument substitution failures are no...
BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...
ObjCIvarDecl - Represents an ObjC instance variable.
Provides information a specialization of a member of a class template, which may be a member function...
ExprResult CorrectDelayedTyposInExpr(Expr *E, VarDecl *InitDecl=nullptr, llvm::function_ref< ExprResult(Expr *)> Filter=[](Expr *E) -> ExprResult{return E;})
Process any TypoExprs in the given Expr and its children, generating diagnostics as appropriate and r...
ArraySizeModifier getSizeModifier() const
bool isLaxVectorConversion(QualType srcType, QualType destType)
Is this a legal conversion between two types, one of which is known to be a vector type...
bool NeedToCaptureVariable(VarDecl *Var, SourceLocation Loc)
Checks if the variable must be captured.
bool isSubscriptPointerArithmetic() const
bool isObjCSelType(QualType T) const
QualType CheckMultiplyDivideOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign, bool IsDivide)
bool isOverloadableType() const
Determines whether this is a type for which one can define an overloaded operator.
Builtin::Context & BuiltinInfo
Location information for a TemplateArgument.
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
void MaybeSuggestAddingStaticToDecl(const FunctionDecl *D)
StringLiteralParser - This decodes string escape characters and performs wide string analysis and Tra...
QualType getVectorType(QualType VectorType, unsigned NumElts, VectorType::VectorKind VecKind) const
Return the unique reference to a vector type of the specified element type and size.
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string...
This class is used for builtin types like 'int'.
void addVLATypeCapture(SourceLocation Loc, QualType CaptureType)
LookupResultKind getResultKind() const
unsigned getLongWidth() const
getLongWidth/Align - Return the size of 'signed long' and 'unsigned long' for this target...
void setParameterCFAudited()
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
void DiagnoseCommaOperator(const Expr *LHS, SourceLocation Loc)
ExpressionEvaluationContext
Describes how the expressions currently being parsed are evaluated at run-time, if at all...
OverloadingResult BestViableFunction(Sema &S, SourceLocation Loc, OverloadCandidateSet::iterator &Best, bool UserDefinedConversion=false)
Find the best viable function on this overload set, if it exists.
static Expr * BuildFloatingLiteral(Sema &S, NumericLiteralParser &Literal, QualType Ty, SourceLocation Loc)
StringLiteral - This represents a string literal expression, e.g.
Defines the clang::TargetInfo interface.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
QualType CheckVectorOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign, bool AllowBothBool, bool AllowBoolConversion)
type checking for vector binary operators.
void UpdateMarkingForLValueToRValue(Expr *E)
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC...
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
bool HasImplicitReturnType
Whether the target type of return statements in this context is deduced (e.g.
ObjCInterfaceDecl * getSuperClass() const
static bool hasAnyTypeDependentArguments(ArrayRef< Expr * > Exprs)
hasAnyTypeDependentArguments - Determines if any of the expressions in Exprs is type-dependent.
NumericLiteralParser - This performs strict semantic analysis of the content of a ppnumber...
ExprResult PerformObjectMemberConversion(Expr *From, NestedNameSpecifier *Qualifier, NamedDecl *FoundDecl, NamedDecl *Member)
Cast a base object to a member's actual type.
void EmitRelatedResultTypeNote(const Expr *E)
If the given expression involves a message send to a method with a related result type...
static bool captureInBlock(BlockScopeInfo *BSI, VarDecl *Var, SourceLocation Loc, const bool BuildAndDiagnose, QualType &CaptureType, QualType &DeclRefType, const bool Nested, Sema &S)
ObjCBoolLiteralExpr - Objective-C Boolean Literal.
decl_type * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
void DiagnoseSelfMove(const Expr *LHSExpr, const Expr *RHSExpr, SourceLocation OpLoc)
Warn if a value is moved to itself.
The name refers to a variable template whose specialization produces a variable.
bool isValid() const
A scope specifier is present, and it refers to a real scope.
A reference to a declared variable, function, enum, etc.
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
virtual bool hasFeature(StringRef Feature) const
Determine whether the given target has the given feature.
bool isSet() const
Deprecated.
The class facilities generation and storage of conversion FixIts.
ExprResult BuildVAArgExpr(SourceLocation BuiltinLoc, Expr *E, TypeSourceInfo *TInfo, SourceLocation RPLoc)
unsigned getLength() const
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type...
QualType getElementType() const
bool hasQualifiers() const
Determine whether this type has any qualifiers.
static bool isOdrUseContext(Sema &SemaRef, bool SkipDependentUses=true)
Are we within a context in which references to resolved functions or to variables result in odr-use...
void setSubStmt(Stmt *SS)
ExprResult ActOnStringLiteral(ArrayRef< Token > StringToks, Scope *UDLScope=nullptr)
ActOnStringLiteral - The specified tokens were lexed as pasted string fragments (e.g.
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given binary opcode.
void NoteAllOverloadCandidates(Expr *E, QualType DestType=QualType(), bool TakingAddress=false)
BasePaths - Represents the set of paths from a derived class to one of its (direct or indirect) bases...
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
void checkUnsafeExprAssigns(SourceLocation Loc, Expr *LHS, Expr *RHS)
checkUnsafeExprAssigns - Check whether +1 expr is being assigned to weak/__unsafe_unretained expressi...
const Expr * getSubExpr() const
void addCapture(VarDecl *Var, bool isBlock, bool isByref, bool isNested, SourceLocation Loc, SourceLocation EllipsisLoc, QualType CaptureType, Expr *Cpy)
void initializeFullCopy(TypeLoc Other)
Initializes this by copying its information from another TypeLoc of the same type.
void suppressDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup.
void setLocation(SourceLocation L)
An l-value expression is a reference to an object with independent storage.
bool isUnresolvedExceptionSpec(ExceptionSpecificationType ESpecType)
void setCaptures(ASTContext &Context, ArrayRef< Capture > Captures, bool CapturesCXXThis)
const llvm::fltSemantics & getFloatTypeSemantics(QualType T) const
Return the APFloat 'semantics' for the specified scalar floating point type.
A trivial tuple used to represent a source range.
SourceLocation getLocation() const
TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, std::unique_ptr< CorrectionCandidateCallback > CCC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr, bool RecordFailure=true)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
IncompatibleObjCQualifiedId - The assignment is between a qualified id type and something else (that ...
ExprResult CheckBooleanCondition(SourceLocation Loc, Expr *E, bool IsConstexpr=false)
CheckBooleanCondition - Diagnose problems involving the use of the given expression as a boolean cond...
NamedDecl - This represents a decl with a name.
void setIdentifier(const IdentifierInfo *Id, SourceLocation IdLoc)
Specify that this unqualified-id was parsed as an identifier.
bool isInvalidType() const
ExprResult BuildVectorLiteral(SourceLocation LParenLoc, SourceLocation RParenLoc, Expr *E, TypeSourceInfo *TInfo)
Build an altivec or OpenCL literal.
ExprResult BuildObjCSubscriptExpression(SourceLocation RB, Expr *BaseExpr, Expr *IndexExpr, ObjCMethodDecl *getterMethod, ObjCMethodDecl *setterMethod)
Build an ObjC subscript pseudo-object expression, given that that's supported by the runtime...
void setAccess(AccessSpecifier AS)
void DiagnoseAlwaysNonNullPointer(Expr *E, Expr::NullPointerConstantKind NullType, bool IsEqual, SourceRange Range)
Diagnose pointers that are always non-null.
Represents a C array with a specified size that is not an integer-constant-expression.
bool CheckCallReturnType(QualType ReturnType, SourceLocation Loc, CallExpr *CE, FunctionDecl *FD)
CheckCallReturnType - Checks that a call expression's return type is complete.
bool isArithmeticType() const
No keyword precedes the qualified type name.
bool ObjCQualifiedIdTypesAreCompatible(QualType LHS, QualType RHS, bool ForCompare)
ObjCQualifiedIdTypesAreCompatible - We know that one of lhs/rhs is an ObjCQualifiedIDType.
sema::LambdaScopeInfo * getCurLambda(bool IgnoreNonLambdaCapturingScope=false)
Retrieve the current lambda scope info, if any.
bool isIncrementDecrementOp() const
ExprResult BuildBinOp(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr)
bool isConstQualified() const
Determine whether this type is const-qualified.
bool allowsPointerArithmetic() const
Does this runtime allow pointer arithmetic on objects?
bool hasSignedIntegerRepresentation() const
Determine whether this type has an signed integer representation of some sort, e.g., it is an signed integer type or a vector.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
static bool isObjCNSObjectType(QualType Ty)
Return true if this is an NSObject object with its NSObject attribute set.
Describes an entity that is being initialized.
static FieldDecl * Create(const ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, Expr *BW, bool Mutable, InClassInitStyle InitStyle)
unsigned NumArgs
NumArgs - The number of template arguments.
bool isObjCIdType() const
True if this is equivalent to the 'id' type, i.e.
static void DiagnoseUnusedOfDecl(Sema &S, NamedDecl *D, SourceLocation Loc)
static bool checkOpenCLConditionVector(Sema &S, Expr *Cond, SourceLocation QuestionLoc)
Return false if this is a valid OpenCL condition vector.
SourceLocation getLocStart() const LLVM_READONLY
void setType(QualType newType)
void removeAddressSpace()
static bool isComparisonOp(Opcode Opc)
static OpaquePtr getFromOpaquePtr(void *P)
Wrapper for source info for pointers.
Optional< NullabilityKind > getNullability(const ASTContext &context) const
Determine the nullability of the given type.
SourceLocation ColonLoc
Location of ':'.
QualType getSingleStepDesugaredType(const ASTContext &Context) const
Return the specified type with one level of "sugar" removed from the type.
void WillReplaceSpecifier(bool ForceReplacement)
StringRef getPlatformName() const
Retrieve the name of the platform as it is used in the availability attribute.
The lookup resulted in an error.
static void checkObjCPointerIntrospection(Sema &S, ExprResult &L, ExprResult &R, SourceLocation OpLoc)
Check if a bitwise-& is performed on an Objective-C pointer.
Represents the canonical version of C arrays with a specified constant size.
static bool IsArithmeticOp(BinaryOperatorKind Opc)
const CXXDestructorDecl * getDestructor() const
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
IncompatibleNestedPointerQualifiers - The assignment is between two nested pointer types...
Declaration of a template function.
void clear()
Clears out any current state.
QualType getBOOLType() const
type of 'BOOL' type.
A class which abstracts out some details necessary for making a call.
static bool isImplicitlyDefinableConstexprFunction(FunctionDecl *Func)
The current expression occurs within a braced-init-list within an unevaluated operand.
NullPointerConstantKind
Enumeration used to describe the kind of Null pointer constant returned from isNullPointerConstant()...
SourceLocation getLocStart() const LLVM_READONLY
One specifier in an expression.
void setElaboratedKeywordLoc(SourceLocation Loc)
bool isOverloadedResult() const
Determines if the results are overloaded.
Attr - This represents one attribute.
ScalarTypeKind getScalarTypeKind() const
Given that this is a scalar type, classify it.
QualType UsualArithmeticConversions(ExprResult &LHS, ExprResult &RHS, bool IsCompAssign=false)
UsualArithmeticConversions - Performs various conversions that are common to binary operators (C99 6...
void startToken()
Reset all flags to cleared.
ExprResult ActOnAddrLabel(SourceLocation OpLoc, SourceLocation LabLoc, LabelDecl *TheDecl)
ActOnAddrLabel - Parse the GNU address of label extension: "&&foo".
TypeSourceInfo * GetTypeForDeclarator(Declarator &D, Scope *S)
GetTypeForDeclarator - Convert the type for the specified declarator to Type instances.
QualType CheckAddressOfOperand(ExprResult &Operand, SourceLocation OpLoc)
CheckAddressOfOperand - The operand of & must be either a function designator or an lvalue designatin...
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
bool hasLocalStorage() const
hasLocalStorage - Returns true if a variable with function scope is a non-static local variable...
ParsedTemplateTy Template
The declaration of the template corresponding to the template-name.
const RecordDecl * getParent() const
getParent - Returns the parent of this field declaration, which is the struct in which this field is ...
void ActOnBlockError(SourceLocation CaretLoc, Scope *CurScope)
ActOnBlockError - If there is an error parsing a block, this callback is invoked to pop the informati...
static void diagnoseUseOfInternalDeclInInlineFunction(Sema &S, const NamedDecl *D, SourceLocation Loc)
Check whether we're in an extern inline function and referring to a variable or function with interna...
Helper class that creates diagnostics with optional template instantiation stacks.
Expr * IgnoreParens() LLVM_READONLY
IgnoreParens - Ignore parentheses.
CanQualType UnsignedIntTy
bool isAddressSpaceSupersetOf(Qualifiers other) const
Returns true if this address space is a superset of the other one.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
llvm::DenseMap< ParmVarDecl *, SourceLocation > UnparsedDefaultArgLocs
bool isPointerType() const
static void RecordModifiableNonNullParam(Sema &S, const Expr *Exp)
Structure used to store a statement, the constant value to which it was evaluated (if any)...
VariadicCallType getVariadicCallType(FunctionDecl *FDecl, const FunctionProtoType *Proto, Expr *Fn)
OverloadedOperatorKind getOverloadedOperator() const
getOverloadedOperator - Which C++ overloaded operator this function represents, if any...
bool isIncompleteOrObjectType() const
Return true if this is an incomplete or object type, in other words, not a function type...
SourceLocation getLocStart() const LLVM_READONLY
static QualType CheckRealImagOperand(Sema &S, ExprResult &V, SourceLocation Loc, bool IsReal)