38 #include "llvm/ADT/APInt.h"
39 #include "llvm/ADT/STLExtras.h"
40 #include "llvm/Support/ErrorHandling.h"
41 using namespace clang;
73 llvm_unreachable(
"Nested name specifier is not a type for inheriting ctor");
78 return CreateParsedType(Type,
87 bool EnteringContext) {
112 bool isDependent =
false;
113 bool LookInScope =
false;
122 SearchType = GetTypeFromParser(ObjectTypePtr);
127 bool AlreadySearched =
false;
128 bool LookAtPrefix =
true;
140 DeclContext *DC = computeDeclContext(SS, EnteringContext);
142 AlreadySearched =
true;
145 }
else if (DC && isa<CXXRecordDecl>(DC)) {
146 LookAtPrefix =
false;
152 if (AlreadySearched) {
154 }
else if (LookAtPrefix && (Prefix = NNS->
getPrefix())) {
157 LookupCtx = computeDeclContext(PrefixSS, EnteringContext);
158 isDependent = isDependentScopeSpecifier(PrefixSS);
159 }
else if (ObjectTypePtr) {
160 LookupCtx = computeDeclContext(SearchType);
163 LookupCtx = computeDeclContext(SS, EnteringContext);
166 }
else if (ObjectTypePtr) {
174 LookupCtx = computeDeclContext(SearchType);
177 "Caller should have completed object type");
185 TypeDecl *NonMatchingTypeDecl =
nullptr;
186 LookupResult Found(*
this, &II, NameLoc, LookupOrdinaryName);
192 if (
Step == 0 && LookupCtx)
193 LookupQualifiedName(Found, LookupCtx);
194 else if (
Step == 1 && LookInScope && S)
195 LookupName(Found, S);
205 MarkAnyDeclReferenced(
Type->getLocation(),
Type,
false);
211 return CreateParsedType(T,
216 NonMatchingTypeDecl =
Type;
228 if (
DeclContext *Ctx = computeDeclContext(SS, EnteringContext)) {
234 if (MemberOfType.
isNull())
235 MemberOfType = SearchType;
237 if (MemberOfType.
isNull())
245 = dyn_cast<ClassTemplateSpecializationDecl>(Record->getDecl())) {
246 if (Spec->getSpecializedTemplate()->getCanonicalDecl() ==
247 Template->getCanonicalDecl())
248 return CreateParsedType(
268 if (SpecTemplate->getCanonicalDecl() == Template->getCanonicalDecl())
269 return CreateParsedType(
280 if (DepTemplate->isIdentifier() &&
281 DepTemplate->getIdentifier() == Template->getIdentifier())
282 return CreateParsedType(
303 if (NonMatchingTypeDecl) {
305 Diag(NameLoc, diag::err_destructor_expr_type_mismatch)
307 Diag(NonMatchingTypeDecl->
getLocation(), diag::note_destructor_type_here)
309 }
else if (ObjectTypePtr)
310 Diag(NameLoc, diag::err_ident_in_dtor_not_a_type)
314 diag::err_destructor_class_name);
317 if (
const CXXRecordDecl *Class = dyn_cast_or_null<CXXRecordDecl>(Ctx))
319 Class->getNameAsString());
330 &&
"only get destructor types from declspecs");
332 QualType SearchType = GetTypeFromParser(ObjectType);
357 Diag(Name.
getLocStart(), diag::err_literal_operator_id_outside_namespace)
368 llvm_unreachable(
"unknown nested name specifier kind");
386 RequireCompleteType(TypeidLoc, T, diag::err_incomplete_typeid))
390 return ExprError(
Diag(TypeidLoc, diag::err_variably_modified_typeid) << T);
401 bool WasEvaluated =
false;
411 CXXRecordDecl *RecordD = cast<CXXRecordDecl>(RecordT->getDecl());
415 if (RequireCompleteType(TypeidLoc, T, diag::err_incomplete_typeid))
430 MarkVTableUsed(TypeidLoc, RecordD);
449 return ExprError(
Diag(TypeidLoc, diag::err_variably_modified_typeid)
451 else if (ActiveTemplateInstantiations.empty() &&
456 ? diag::warn_side_effects_typeid
457 : diag::warn_side_effects_unevaluated_context);
469 if (!getStdNamespace())
470 return ExprError(
Diag(OpLoc, diag::err_need_header_before_typeid));
472 if (!CXXTypeInfoDecl) {
473 IdentifierInfo *TypeInfoII = &PP.getIdentifierTable().get(
"type_info");
475 LookupQualifiedName(R, getStdNamespace());
479 if (!CXXTypeInfoDecl && LangOpts.MSVCCompat) {
483 if (!CXXTypeInfoDecl)
484 return ExprError(
Diag(OpLoc, diag::err_need_header_before_typeid));
487 if (!getLangOpts().RTTI) {
488 return ExprError(
Diag(OpLoc, diag::err_no_typeid_with_fno_rtti));
504 return BuildCXXTypeId(TypeInfoType, OpLoc, TInfo, RParenLoc);
508 return BuildCXXTypeId(TypeInfoType, OpLoc, (
Expr*)TyOrExpr, RParenLoc);
517 bool HasMultipleGUIDs =
false;
519 &HasMultipleGUIDs)) {
520 if (HasMultipleGUIDs)
521 return ExprError(
Diag(TypeidLoc, diag::err_uuidof_with_multiple_guids));
523 return ExprError(
Diag(TypeidLoc, diag::err_uuidof_without_guid));
537 bool HasMultipleGUIDs =
false;
540 if (HasMultipleGUIDs)
541 return ExprError(
Diag(TypeidLoc, diag::err_uuidof_with_multiple_guids));
543 return ExprError(
Diag(TypeidLoc, diag::err_uuidof_without_guid));
562 return ExprError(
Diag(OpLoc, diag::err_need_header_before_ms_uuidof));
578 return BuildCXXUuidof(GuidType, OpLoc, TInfo, RParenLoc);
582 return BuildCXXUuidof(GuidType, OpLoc, (
Expr*)TyOrExpr, RParenLoc);
588 assert((Kind == tok::kw_true || Kind == tok::kw_false) &&
589 "Unknown C++ Boolean value!");
603 bool IsThrownVarInScope =
false;
617 if (
VarDecl *Var = dyn_cast<VarDecl>(DRE->getDecl())) {
618 if (Var->hasLocalStorage() && !Var->getType().isVolatileQualified()) {
621 IsThrownVarInScope =
true;
635 return BuildCXXThrow(OpLoc, Ex, IsThrownVarInScope);
639 bool IsThrownVarInScope) {
641 if (!getLangOpts().CXXExceptions &&
642 !getSourceManager().isInSystemHeader(OpLoc))
643 Diag(OpLoc, diag::err_exceptions_disabled) <<
"throw";
645 if (getCurScope() && getCurScope()->isOpenMPSimdDirectiveScope())
646 Diag(OpLoc, diag::err_omp_simd_region_cannot_use_stmt) <<
"throw";
650 if (CheckCXXThrowOperand(OpLoc, ExceptionObjectTy, Ex))
668 const VarDecl *NRVOVariable =
nullptr;
669 if (IsThrownVarInScope)
670 NRVOVariable = getCopyElisionCandidate(
QualType(), Ex,
false);
673 OpLoc, ExceptionObjectTy,
674 NRVOVariable !=
nullptr);
675 ExprResult Res = PerformMoveOrCopyInitialization(
676 Entity, NRVOVariable,
QualType(), Ex, IsThrownVarInScope);
688 llvm::DenseMap<CXXRecordDecl *, unsigned> &SubobjectsSeen,
689 llvm::SmallPtrSetImpl<CXXRecordDecl *> &VBases,
690 llvm::SetVector<CXXRecordDecl *> &PublicSubobjectsSeen,
691 bool ParentIsPublic) {
693 CXXRecordDecl *BaseDecl = BS.getType()->getAsCXXRecordDecl();
698 NewSubobject = VBases.insert(BaseDecl).second;
703 ++SubobjectsSeen[BaseDecl];
706 bool PublicPath = ParentIsPublic && BS.getAccessSpecifier() ==
AS_public;
708 PublicSubobjectsSeen.insert(BaseDecl);
718 llvm::DenseMap<CXXRecordDecl *, unsigned> SubobjectsSeen;
719 llvm::SmallSet<CXXRecordDecl *, 2> VBases;
720 llvm::SetVector<CXXRecordDecl *> PublicSubobjectsSeen;
721 SubobjectsSeen[RD] = 1;
722 PublicSubobjectsSeen.insert(RD);
726 for (
CXXRecordDecl *PublicSubobject : PublicSubobjectsSeen) {
728 if (SubobjectsSeen[PublicSubobject] > 1)
731 Objects.push_back(PublicSubobject);
741 bool isPointer =
false;
747 if (RequireCompleteType(ThrowLoc, Ty,
748 isPointer ? diag::err_throw_incomplete_ptr
749 : diag::err_throw_incomplete,
750 E->getSourceRange()))
753 if (RequireNonAbstractType(ThrowLoc, ExceptionObjectTy,
754 diag::err_throw_abstract_type, E))
765 MarkVTableUsed(ThrowLoc, RD);
774 MarkFunctionReferenced(E->
getExprLoc(), Destructor);
775 CheckDestructorAccess(E->
getExprLoc(), Destructor,
776 PDiag(diag::err_access_dtor_exception) << Ty);
777 if (DiagnoseUseOfDecl(Destructor, E->
getExprLoc()))
792 for (
CXXRecordDecl *Subobject : UnambiguousPublicSubobjects) {
825 BuildCXXDefaultArgExpr(ThrowLoc, CD, CD->
getParamDecl(
I)).
get();
836 QualType ThisTy = CXXThisTypeOverride;
838 if (method && method->isInstance())
839 ThisTy = method->getThisType(
Context);
843 CurContext->getParent()->getParent()->isRecord()) {
849 cast<CXXRecordDecl>(CurContext->getParent()->getParent()));
860 unsigned CXXThisTypeQuals,
862 : S(S), OldCXXThisTypeOverride(S.CXXThisTypeOverride), Enabled(
false)
864 if (!Enabled || !ContextDecl)
869 Record = Template->getTemplatedDecl();
871 Record = cast<CXXRecordDecl>(ContextDecl);
877 this->Enabled =
true;
900 bool BuildAndDiagnose,
const unsigned *
const FunctionScopeIndexToStopAt) {
905 const unsigned MaxFunctionScopesIndex = FunctionScopeIndexToStopAt ?
908 unsigned NumClosures = 0;
909 for (
unsigned idx = MaxFunctionScopesIndex; idx != 0; idx--) {
912 if (CSI->CXXThisCaptureIndex != 0) {
919 if (BuildAndDiagnose)
920 Diag(Loc, diag::err_this_capture) << Explicit;
934 if (BuildAndDiagnose)
935 Diag(Loc, diag::err_this_capture) << Explicit;
940 if (!BuildAndDiagnose)
return false;
944 for (
unsigned idx = MaxFunctionScopesIndex; NumClosures;
945 --idx, --NumClosures) {
947 Expr *ThisExpr =
nullptr;
956 bool isNested = NumClosures > 1;
968 if (ThisTy.
isNull())
return Diag(Loc, diag::err_invalid_this_use);
1019 bool ListInitialization = LParenLoc.
isInvalid();
1020 assert((!ListInitialization || (Exprs.size() == 1 && isa<InitListExpr>(Exprs[0])))
1021 &&
"List initialization must have initializer list as expression.");
1023 ListInitialization ? Exprs[0]->getSourceRange().getEnd() : RParenLoc);
1029 if (Exprs.size() == 1 && !ListInitialization) {
1030 Expr *Arg = Exprs[0];
1041 if (!ListInitialization)
1043 diag::err_value_init_for_array_type) << FullRange);
1048 return ExprError(
Diag(TyBeginLoc, diag::err_value_init_for_function_type)
1053 diag::err_invalid_incomplete_type_use, FullRange))
1057 diag::err_allocation_of_abstract_type))
1062 Exprs.size() ? ListInitialization
1069 if (Result.
isInvalid() || !ListInitialization)
1074 Inner = BTE->getSubExpr();
1075 if (!isa<CXXTemporaryObjectExpr>(Inner)) {
1087 CK_NoOp, Result.
get(),
nullptr, LParenLoc, RParenLoc);
1099 if (!record)
return false;
1112 if (ops.
empty())
return false;
1125 if (isa<FunctionTemplateDecl>(del)) {
1136 if (!cast<CXXMethodDecl>(del)->isUsualDeallocationFunction()) {
1172 Expr *ArraySize =
nullptr;
1177 if (TypeContainsAuto)
1199 if (!NumElts->isTypeDependent() && !NumElts->isValueDependent()) {
1205 assert(IntWidth &&
"Builtin type of size 0?");
1206 llvm::APSInt
Value(IntWidth);
1214 diag::err_new_array_nonconst)
1230 if (
ParenListExpr *List = dyn_cast_or_null<ParenListExpr>(Initializer))
1231 DirectInitRange = List->getSourceRange();
1251 return PLE->getNumExprs() == 0;
1252 if (isa<ImplicitValueInitExpr>(Init))
1255 return !CCE->isListInitialization() &&
1256 CCE->getConstructor()->isDefaultConstructor();
1258 assert(isa<InitListExpr>(Init) &&
1259 "Shouldn't create list CXXConstructExprs for arrays.");
1276 bool TypeMayContainAuto) {
1281 if (DirectInitRange.
isValid()) {
1282 assert(Initializer &&
"Have parens but no initializer.");
1284 }
else if (Initializer && isa<InitListExpr>(Initializer))
1287 assert((!Initializer || isa<ImplicitValueInitExpr>(Initializer) ||
1288 isa<CXXConstructExpr>(Initializer)) &&
1289 "Initializer expression that cannot have been implicitly created.");
1294 unsigned NumInits = Initializer ? 1 : 0;
1295 if (
ParenListExpr *List = dyn_cast_or_null<ParenListExpr>(Initializer)) {
1297 Inits = List->getExprs();
1298 NumInits = List->getNumExprs();
1304 return ExprError(
Diag(StartLoc, diag::err_auto_new_requires_ctor_arg)
1305 << AllocType << TypeRange);
1307 (NumInits == 1 && isa<InitListExpr>(Inits[0])))
1309 diag::err_auto_new_list_init)
1310 << AllocType << TypeRange);
1312 Expr *FirstBad = Inits[1];
1314 diag::err_auto_new_ctor_multiple_expressions)
1315 << AllocType << TypeRange);
1317 Expr *Deduce = Inits[0];
1320 return ExprError(
Diag(StartLoc, diag::err_auto_new_deduction_failure)
1321 << AllocType << Deduce->
getType()
1322 << TypeRange << Deduce->getSourceRange());
1323 if (DeducedType.
isNull())
1325 AllocType = DeducedType;
1336 AllocType = Array->getElementType();
1346 diag::warn_dangling_std_initializer_list)
1347 << 0 << Inits[0]->getSourceRange();
1363 ArraySize = result.
get();
1380 if (!ConvertedSize.isInvalid() &&
1383 Diag(StartLoc, diag::warn_cxx98_compat_array_size_conversion)
1384 << ArraySize->
getType() << 0 <<
"'size_t'";
1391 SizeConvertDiagnoser(
Expr *ArraySize)
1393 ArraySize(ArraySize) {}
1397 return S.
Diag(Loc, diag::err_array_size_not_integral)
1403 return S.
Diag(Loc, diag::err_array_size_incomplete_type)
1404 << T << ArraySize->getSourceRange();
1409 return S.
Diag(Loc, diag::err_array_size_explicit_conversion) << T << ConvTy;
1420 return S.
Diag(Loc, diag::err_array_size_ambiguous_conversion) << T;
1434 ? diag::warn_cxx98_compat_array_size_conversion
1435 : diag::ext_array_size_conversion)
1438 } SizeDiagnoser(ArraySize);
1446 ArraySize = ConvertedSize.
get();
1467 if (Value < llvm::APSInt(
1468 llvm::APInt::getNullValue(Value.getBitWidth()),
1469 Value.isUnsigned())) {
1471 Diag(ArraySize->getLocStart(),
1472 diag::warn_typecheck_negative_array_new_size)
1473 << ArraySize->getSourceRange();
1476 diag::err_typecheck_negative_array_size)
1477 << ArraySize->getSourceRange());
1479 unsigned ActiveSizeBits =
1483 Diag(ArraySize->getLocStart(),
1484 diag::warn_array_new_too_large)
1485 << Value.toString(10)
1486 << ArraySize->getSourceRange();
1489 diag::err_array_too_large)
1490 << Value.toString(10)
1491 << ArraySize->getSourceRange());
1494 }
else if (TypeIdParens.
isValid()) {
1496 Diag(ArraySize->getLocStart(), diag::ext_new_paren_array_nonconst)
1497 << ArraySize->getSourceRange()
1516 UseGlobal, AllocType, ArraySize, PlacementArgs,
1517 OperatorNew, OperatorDelete))
1522 bool UsualArrayDeleteWantsSize =
false;
1524 UsualArrayDeleteWantsSize
1538 PlacementArgs, AllPlaceArgs, CallType))
1541 if (!AllPlaceArgs.empty())
1542 PlacementArgs = AllPlaceArgs;
1552 if (PlacementArgs.empty() && OperatorNew &&
1557 if (Align > SuitableAlign)
1558 Diag(StartLoc, diag::warn_overaligned_type)
1572 Inits[NumInits - 1]->getLocEnd());
1573 Diag(StartLoc, diag::err_new_array_init_args) << InitRange;
1576 if (
InitListExpr *ILE = dyn_cast_or_null<InitListExpr>(Initializer)) {
1580 unsigned NumElements = ILE->getNumInits() + 1;
1591 llvm::makeArrayRef(Inits, NumInits))) {
1607 DirectInitRange.
getEnd());
1620 dyn_cast_or_null<CXXBindTemporaryExpr>(FullInit.
get()))
1621 FullInit = Binder->getSubExpr();
1623 Initializer = FullInit.
get();
1632 if (OperatorDelete) {
1645 cast<CXXRecordDecl>(BaseRecordType->getDecl()))) {
1648 PDiag(diag::err_access_dtor)
1658 UsualArrayDeleteWantsSize, PlacementArgs, TypeIdParens,
1659 ArraySize, initStyle, Initializer, ResultType, AllocTypeInfo,
1660 Range, DirectInitRange);
1670 return Diag(Loc, diag::err_bad_new_type)
1671 << AllocType << 0 << R;
1673 return Diag(Loc, diag::err_bad_new_type)
1674 << AllocType << 1 << R;
1679 diag::err_allocation_of_abstract_type))
1682 return Diag(Loc, diag::err_variably_modified_new_type)
1685 return Diag(Loc, diag::err_address_space_qualified_new)
1692 return Diag(Loc, diag::err_arc_new_array_without_ownership)
1707 return Method->isUsualDeallocationFunction();
1724 bool UseGlobal,
QualType AllocType,
1745 AllocArgs[0] = &Size;
1746 std::copy(PlaceArgs.begin(), PlaceArgs.end(), AllocArgs.begin() + 1);
1755 IsArray ? OO_Array_New : OO_New);
1757 IsArray ? OO_Array_Delete : OO_Delete);
1775 FallbackEnabled, OperatorNew,
1776 !FallbackEnabled)) {
1777 if (!FallbackEnabled)
1787 false, OperatorNew))
1795 OperatorDelete =
nullptr;
1817 if (FoundDelete.
empty()) {
1831 bool isPlacementNew = (!PlaceArgs.empty() || OperatorNew->
param_size() != 1);
1833 if (isPlacementNew) {
1859 ExpectedFunctionType
1864 DEnd = FoundDelete.
end();
1868 = dyn_cast<FunctionTemplateDecl>((*D)->getUnderlyingDecl())) {
1876 Fn = cast<FunctionDecl>((*D)->getUnderlyingDecl());
1879 Matches.push_back(std::make_pair(D.getPair(), Fn));
1886 DEnd = FoundDelete.
end();
1888 if (
FunctionDecl *Fn = dyn_cast<FunctionDecl>((*D)->getUnderlyingDecl()))
1890 Matches.push_back(std::make_pair(D.getPair(), Fn));
1903 if (
getLangOpts().SizedDeallocation && Matches.size() == 2) {
1904 if (Matches[0].second->getNumParams() == 1)
1905 Matches.erase(Matches.begin());
1907 Matches.erase(Matches.begin() + 1);
1908 assert(Matches[0].second->getNumParams() == 2 &&
1909 "found an unexpected usual deallocation function");
1917 if (Matches.size() == 1) {
1918 OperatorDelete = Matches[0].second;
1926 if (!PlaceArgs.empty() &&
getLangOpts().CPlusPlus11 &&
1928 Diag(StartLoc, diag::err_placement_new_non_placement_delete)
1930 PlaceArgs.back()->getLocEnd());
1967 if (AllowMissing || !Diagnose)
1969 return Diag(StartLoc, diag::err_ovl_no_viable_function_in_call)
1980 Alloc != AllocEnd; ++Alloc) {
2014 Diag(StartLoc, diag::err_ovl_no_viable_function_in_call)
2022 Diag(StartLoc, diag::err_ovl_ambiguous_call)
2030 Diag(StartLoc, diag::err_ovl_deleted_call)
2031 << Best->Function->isDeleted()
2040 llvm_unreachable(
"Unreachable, bad result from BestViableFunction");
2116 bool AssumeSaneOperatorNew =
getLangOpts().AssumeSaneOperatorNew;
2120 VoidPtr, SizeT,
QualType(), AssumeSaneOperatorNew);
2123 VoidPtr, SizeT,
QualType(), AssumeSaneOperatorNew);
2145 bool AddRestrictAttr) {
2147 unsigned NumParams = Param2.
isNull() ? 1 : 2;
2152 Alloc != AllocEnd; ++Alloc) {
2155 if (
FunctionDecl *Func = dyn_cast<FunctionDecl>(*Alloc)) {
2156 if (Func->getNumParams() == NumParams) {
2159 ->getType().getUnqualifiedType());
2163 ->getType().getUnqualifiedType())
2166 if (InitialParam1Type == Param1 &&
2167 (NumParams == 1 || InitialParam2Type == Param2)) {
2168 if (AddRestrictAttr && !Func->hasAttr<RestrictAttr>())
2169 Func->addAttr(RestrictAttr::CreateImplicit(
2170 Context, RestrictAttr::GNU_malloc));
2174 Func->setHidden(
false);
2184 bool HasBadAllocExceptionSpec
2187 if (HasBadAllocExceptionSpec) {
2190 assert(
StdBadAlloc &&
"Must have std::bad_alloc declared");
2199 QualType Params[] = { Param1, Param2 };
2202 Return, llvm::makeArrayRef(Params, NumParams), EPI);
2206 FnType,
nullptr,
SC_None,
false,
true);
2211 VisibilityAttr::Default));
2213 if (AddRestrictAttr)
2215 RestrictAttr::CreateImplicit(
Context, RestrictAttr::GNU_malloc));
2218 for (
unsigned I = 0;
I != NumParams; ++
I) {
2225 Alloc->setParams(llvm::makeArrayRef(ParamDecls, NumParams));
2232 bool CanProvideSize,
2244 DEnd = FoundDelete.
end();
2248 Matches.push_back(Fn);
2258 if (
getLangOpts().SizedDeallocation && Matches.size() == 2) {
2259 unsigned NumArgs = CanProvideSize ? 2 : 1;
2260 if (Matches[0]->getNumParams() !=
NumArgs)
2261 Matches.erase(Matches.begin());
2263 Matches.erase(Matches.begin() + 1);
2264 assert(Matches[0]->getNumParams() == NumArgs &&
2265 "found an unexpected usual deallocation function");
2271 assert(Matches.size() == 1 &&
2272 "unexpectedly have multiple usual deallocation functions");
2273 return Matches.front();
2295 if (isa<FunctionTemplateDecl>(ND))
2298 if (cast<CXXMethodDecl>(ND)->isUsualDeallocationFunction())
2299 Matches.push_back(F.getPair());
2306 if (Matches.size() == 1) {
2307 Operator = cast<CXXMethodDecl>(Matches[0]->getUnderlyingDecl());
2311 Diag(StartLoc, diag::err_deleted_function_use);
2324 }
else if (!Matches.empty()) {
2326 Diag(StartLoc, diag::err_ambiguous_suitable_delete_member_function_found)
2330 F = Matches.begin(), FEnd = Matches.end(); F != FEnd; ++F)
2331 Diag((*F)->getUnderlyingDecl()->getLocation(),
2332 diag::note_member_declared_here) << Name;
2339 if (!Found.
empty()) {
2341 Diag(StartLoc, diag::err_no_suitable_delete_member_function_found)
2346 Diag((*F)->getUnderlyingDecl()->getLocation(),
2347 diag::note_member_declared_here) << Name;
2359 class MismatchingNewDeleteDetector {
2361 enum MismatchResult {
2367 MemberInitMismatches,
2376 explicit MismatchingNewDeleteDetector(
bool EndOfTU)
2377 : IsArrayForm(
false), Field(nullptr), EndOfTU(EndOfTU),
2378 HasUndefinedConstructors(
false) {}
2395 MismatchResult analyzeField(
FieldDecl *Field,
bool DeleteWasArrayForm);
2405 bool HasUndefinedConstructors;
2417 MismatchResult analyzeMemberExpr(
const MemberExpr *ME);
2440 MismatchResult analyzeInClassInitializer();
2444 MismatchingNewDeleteDetector::MismatchResult
2445 MismatchingNewDeleteDetector::analyzeDeleteExpr(
const CXXDeleteExpr *DE) {
2447 assert(DE &&
"Expected delete-expression");
2450 if (
const MemberExpr *ME = dyn_cast<const MemberExpr>(E)) {
2451 return analyzeMemberExpr(ME);
2452 }
else if (
const DeclRefExpr *D = dyn_cast<const DeclRefExpr>(E)) {
2453 if (!hasMatchingVarInit(D))
2454 return VarInitMismatches;
2460 MismatchingNewDeleteDetector::getNewExprFromInitListOrExpr(
const Expr *E) {
2461 assert(E !=
nullptr &&
"Expected a valid initializer expression");
2463 if (
const InitListExpr *ILE = dyn_cast<const InitListExpr>(E)) {
2464 if (ILE->getNumInits() == 1)
2465 E = dyn_cast<const CXXNewExpr>(ILE->getInit(0)->IgnoreParenImpCasts());
2468 return dyn_cast_or_null<const CXXNewExpr>(
E);
2471 bool MismatchingNewDeleteDetector::hasMatchingNewInCtorInit(
2475 (NE = getNewExprFromInitListOrExpr(CI->
getInit()))) {
2476 if (NE->
isArray() == IsArrayForm)
2479 NewExprs.push_back(NE);
2484 bool MismatchingNewDeleteDetector::hasMatchingNewInCtor(
2490 HasUndefinedConstructors =
true;
2493 for (
const auto *CI : cast<const CXXConstructorDecl>(Definition)->inits()) {
2494 if (hasMatchingNewInCtorInit(CI))
2500 MismatchingNewDeleteDetector::MismatchResult
2501 MismatchingNewDeleteDetector::analyzeInClassInitializer() {
2502 assert(Field !=
nullptr &&
"This should be called only for members");
2503 const Expr *InitExpr = Field->getInClassInitializer();
2505 return EndOfTU ? NoMismatch : AnalyzeLater;
2506 if (
const CXXNewExpr *NE = getNewExprFromInitListOrExpr(InitExpr)) {
2507 if (NE->
isArray() != IsArrayForm) {
2508 NewExprs.push_back(NE);
2509 return MemberInitMismatches;
2515 MismatchingNewDeleteDetector::MismatchResult
2516 MismatchingNewDeleteDetector::analyzeField(
FieldDecl *Field,
2517 bool DeleteWasArrayForm) {
2518 assert(Field !=
nullptr &&
"Analysis requires a valid class member.");
2519 this->Field = Field;
2520 IsArrayForm = DeleteWasArrayForm;
2522 for (
const auto *CD : RD->
ctors()) {
2523 if (hasMatchingNewInCtor(CD))
2526 if (HasUndefinedConstructors)
2527 return EndOfTU ? NoMismatch : AnalyzeLater;
2528 if (!NewExprs.empty())
2529 return MemberInitMismatches;
2534 MismatchingNewDeleteDetector::MismatchResult
2535 MismatchingNewDeleteDetector::analyzeMemberExpr(
const MemberExpr *ME) {
2536 assert(ME !=
nullptr &&
"Expected a member expression");
2538 return analyzeField(F, IsArrayForm);
2542 bool MismatchingNewDeleteDetector::hasMatchingVarInit(
const DeclRefExpr *D) {
2545 if (VD->hasInit() && (NE = getNewExprFromInitListOrExpr(VD->getInit())) &&
2546 NE->
isArray() != IsArrayForm) {
2547 NewExprs.push_back(NE);
2550 return NewExprs.empty();
2555 const MismatchingNewDeleteDetector &Detector) {
2558 if (!Detector.IsArrayForm)
2567 SemaRef.
Diag(DeleteLoc, diag::warn_mismatched_delete_new)
2568 << Detector.IsArrayForm << H;
2570 for (
const auto *NE : Detector.NewExprs)
2572 << Detector.IsArrayForm;
2575 void Sema::AnalyzeDeleteExprMismatch(
const CXXDeleteExpr *DE) {
2578 MismatchingNewDeleteDetector Detector(
false);
2579 switch (Detector.analyzeDeleteExpr(DE)) {
2580 case MismatchingNewDeleteDetector::VarInitMismatches:
2581 case MismatchingNewDeleteDetector::MemberInitMismatches: {
2585 case MismatchingNewDeleteDetector::AnalyzeLater: {
2590 case MismatchingNewDeleteDetector::NoMismatch:
2596 bool DeleteWasArrayForm) {
2597 MismatchingNewDeleteDetector Detector(
true);
2598 switch (Detector.analyzeField(Field, DeleteWasArrayForm)) {
2599 case MismatchingNewDeleteDetector::VarInitMismatches:
2600 llvm_unreachable(
"This analysis should have been done for class members.");
2601 case MismatchingNewDeleteDetector::AnalyzeLater:
2602 llvm_unreachable(
"Analysis cannot be postponed any point beyond end of "
2603 "translation unit.");
2604 case MismatchingNewDeleteDetector::MemberInitMismatches:
2607 case MismatchingNewDeleteDetector::NoMismatch:
2618 bool ArrayForm,
Expr *ExE) {
2628 bool ArrayFormAsWritten = ArrayForm;
2629 bool UsualArrayDeleteWantsSize =
false;
2647 if (ConvPtrType->getPointeeType()->isIncompleteOrObjectType())
2654 return S.
Diag(Loc, diag::err_delete_operand) << T;
2659 return S.
Diag(Loc, diag::err_delete_incomplete_class_type) << T;
2665 return S.
Diag(Loc, diag::err_delete_explicit_conversion) << T << ConvTy;
2676 return S.
Diag(Loc, diag::err_ambiguous_delete_operand) << T;
2688 llvm_unreachable(
"conversion functions are permitted");
2696 if (!Converter.match(Type))
2705 return Diag(Ex.
get()->getLocStart(),
2706 diag::err_address_space_qualified_delete)
2714 Diag(StartLoc, diag::ext_delete_void_ptr_operand)
2715 << Type << Ex.
get()->getSourceRange();
2718 << Type << Ex.
get()->getSourceRange());
2723 diag::warn_delete_incomplete, Ex.
get())) {
2725 PointeeRD = cast<CXXRecordDecl>(RT->getDecl());
2730 Diag(StartLoc, diag::warn_delete_array_type)
2731 << Type << Ex.
get()->getSourceRange()
2737 ArrayForm ? OO_Array_Delete : OO_Delete);
2751 UsualArrayDeleteWantsSize =
2756 else if (OperatorDelete && isa<CXXMethodDecl>(OperatorDelete))
2757 UsualArrayDeleteWantsSize = (OperatorDelete->
getNumParams() == 2);
2763 const_cast<CXXDestructorDecl*>(Dtor));
2782 Diag(StartLoc, diag::warn_delete_abstract_non_virtual_dtor)
2784 }
else if (!ArrayForm) {
2787 Diag(StartLoc, diag::warn_delete_non_virtual_dtor) << PointeeElem;
2794 if (!OperatorDelete)
2798 (!ArrayForm || UsualArrayDeleteWantsSize ||
2808 PDiag(diag::err_access_dtor) << PointeeElem);
2815 UsualArrayDeleteWantsSize, OperatorDelete, Ex.
get(), StartLoc);
2816 AnalyzeDeleteExprMismatch(Result);
2824 bool ConvertToBoolean) {
2834 diag::err_invalid_use_of_function_type)
2838 diag::err_invalid_use_of_array_type)
2848 if (ConvertToBoolean) {
2878 From = Cast->getSubExpr();
2890 if (!ToPtrType->getPointeeType().hasQualifiers()) {
2891 switch (StrLit->getKind()) {
2898 return (ToPointeeType->getKind() == BuiltinType::Char_U ||
2899 ToPointeeType->getKind() == BuiltinType::Char_S);
2901 return ToPointeeType->isWideCharType();
2915 bool HadMultipleCandidates,
2918 default: llvm_unreachable(
"Unhandled cast kind!");
2924 diag::err_allocation_of_abstract_type))
2937 CastLoc, Ty, cast<CXXConstructorDecl>(Method),
2938 ConstructorArgs, HadMultipleCandidates,
2939 false,
false,
false,
2957 HadMultipleCandidates);
2958 if (Result.isInvalid())
2963 nullptr, Result.get()->getValueKind());
2995 assert(FD &&
"no conversion function for user-defined conversion seq");
3027 From->getLocStart(),
3037 From = CastArg.
get();
3045 PDiag(diag::err_typecheck_ambiguous_condition)
3046 << From->getSourceRange());
3050 llvm_unreachable(
"Cannot perform an ellipsis conversion");
3089 ConstructorArgs,
false,
3090 false,
false,
false,
3096 false,
false,
false,
3119 ToAtomicType = ToType;
3120 ToType = ToAtomic->getValueType();
3123 QualType InitialFromType = FromType;
3125 switch (SCS.
First) {
3128 FromType = FromAtomic->getValueType().getUnqualifiedType();
3137 assert(!FromRes.isInvalid() &&
"Can't perform deduced conversion?!");
3138 From = FromRes.get();
3139 FromType = From->getType();
3156 llvm_unreachable(
"Improper first standard conversion");
3203 "only enums with fixed underlying type can promote to bool");
3257 Diag(From->getLocStart(),
3258 diag::ext_typecheck_convert_incompatible_pointer)
3259 << ToType << From->
getType() << Action
3260 << From->getSourceRange() << 0;
3262 Diag(From->getLocStart(),
3263 diag::ext_typecheck_convert_incompatible_pointer)
3264 << From->
getType() << ToType << Action
3265 << From->getSourceRange() << 0;
3275 Diag(From->getLocStart(),
3276 diag::err_arc_weak_unavailable_assign);
3278 Diag(From->getLocStart(),
3279 diag::err_arc_convesion_of_weak_unavailable)
3281 << From->getSourceRange();
3339 From->getLocStart(),
3340 From->getSourceRange(),
3347 &BasePath, CCK).
get();
3360 nullptr, CCK).
get();
3367 QualType ElType = ToComplex->getElementType();
3389 assert(FromComplex);
3428 From = FromRes.
get();
3430 "Improper transparent union conversion");
3447 llvm_unreachable(
"Improper second standard conversion");
3450 switch (SCS.
Third) {
3461 CK_NoOp, VK,
nullptr, CCK).
get();
3466 ? diag::ext_deprecated_string_literal_conversion
3467 : diag::warn_deprecated_string_literal_conversion)
3475 llvm_unreachable(
"Improper third standard conversion");
3480 if (!ToAtomicType.
isNull()) {
3491 From->getLocStart());
3515 default: llvm_unreachable(
"not a UTT");
3568 Loc, ArgTy, diag::err_incomplete_type_used_in_type_trait_expr);
3577 Loc, ArgTy, diag::err_incomplete_type_used_in_type_trait_expr);
3618 Loc, ElTy, diag::err_incomplete_type_used_in_type_trait_expr);
3629 if ((RD->*HasTrivial)() && !(RD->*HasNonTrivial)())
3636 bool FoundOperator =
false;
3639 Op != OpEnd; ++Op) {
3640 if (isa<FunctionTemplateDecl>(*Op))
3644 if((Operator->*IsDesiredOp)()) {
3645 FoundOperator =
true;
3653 return FoundOperator;
3660 assert(!T->
isDependentType() &&
"Cannot evaluate traits of dependent type");
3664 default: llvm_unreachable(
"not a UTT");
3764 return RD->
hasAttr<FinalAttr>();
3793 if (
CXXRecordDecl *RD = C.getBaseElementType(T)->getAsCXXRecordDecl())
3803 if (
CXXRecordDecl *RD = C.getBaseElementType(T)->getAsCXXRecordDecl())
3824 if (
CXXRecordDecl *RD = C.getBaseElementType(T)->getAsCXXRecordDecl())
3870 if (
auto *RD = C.getBaseElementType(T)->getAsCXXRecordDecl()) {
3906 if (
CXXRecordDecl *RD = C.getBaseElementType(T)->getAsCXXRecordDecl())
3918 if (C.getBaseElementType(T).isConstQualified())
3957 bool FoundConstructor =
false;
3963 if (isa<FunctionTemplateDecl>(ND))
3967 FoundConstructor =
true;
3980 return FoundConstructor;
3991 if (
CXXRecordDecl *RD = C.getBaseElementType(T)->getAsCXXRecordDecl()) {
3996 bool FoundConstructor =
false;
3999 if (isa<FunctionTemplateDecl>(ND))
4003 FoundConstructor =
true;
4015 return FoundConstructor;
4024 return Destructor->isVirtual();
4054 llvm_unreachable(
"Unknown ObjC lifetime qualifier");
4068 Args[1]->getType(), RParenLoc);
4087 assert(!Args.empty());
4092 for (
const auto *TSI : Args) {
4098 diag::err_incomplete_type_used_in_type_trait_expr))
4114 ArgExprs.reserve(Args.size() - 1);
4115 for (
unsigned I = 1, N = Args.size();
I != N; ++
I) {
4119 OpaqueArgExprs.push_back(
4124 for (
Expr &E : OpaqueArgExprs)
4125 ArgExprs.push_back(&E);
4158 return !Result.
get()->hasNonTrivialCall(S.
Context);
4161 llvm_unreachable(
"unhandled type trait");
4164 default: llvm_unreachable(
"not a TT");
4176 *
this, Kind, KWLoc, Args[0]->getType()))
4179 bool Dependent =
false;
4180 for (
unsigned I = 0, N = Args.size();
I != N; ++
I) {
4181 if (Args[
I]->getType()->isDependentType()) {
4199 ConvertedArgs.reserve(Args.size());
4201 for (
unsigned I = 0, N = Args.size();
I != N; ++
I) {
4207 ConvertedArgs.push_back(TInfo);
4216 "Cannot evaluate traits of dependent types");
4226 if (!lhsRecord)
return false;
4229 if (!rhsRecord)
return false;
4232 == (lhsRecord == rhsRecord));
4234 if (lhsRecord == rhsRecord)
4242 diag::err_incomplete_type_used_in_type_trait_expr))
4245 return cast<CXXRecordDecl>(rhsRecord->
getDecl())
4246 ->isDerivedFrom(cast<CXXRecordDecl>(lhsRecord->
getDecl()));
4300 Expr *FromPtr = &From;
4332 diag::err_incomplete_type_used_in_type_trait_expr))
4336 diag::err_incomplete_type_used_in_type_trait_expr))
4374 return !Result.get()->hasNonTrivialCall(Self.
Context);
4377 llvm_unreachable(
"unhandled type trait");
4380 default: llvm_unreachable(
"not a BTT");
4382 llvm_unreachable(
"Unknown type trait or not implemented");
4401 assert(!T->
isDependentType() &&
"Cannot evaluate traits of dependent type");
4409 T = AT->getElementType();
4419 diag::err_dimension_expr_not_constant_integer,
4422 if (Value.isSigned() && Value.isNegative()) {
4423 Self.
Diag(KeyLoc, diag::err_dimension_expr_not_constant_integer)
4424 << DimExpr->getSourceRange();
4427 Dim = Value.getLimitedValue();
4431 bool Matched =
false;
4438 T = AT->getElementType();
4443 return CAT->getSize().getLimitedValue();
4449 llvm_unreachable(
"Unknown type trait or not implemented");
4492 llvm_unreachable(
"Expression trait not covered by switch");
4519 "placeholders should have been weeded out by now");
4531 const char *OpSpelling = isIndirect ?
"->*" :
".*";
4539 Diag(Loc, diag::err_bad_memptr_rhs)
4540 << OpSpelling << RHSType << RHS.
get()->getSourceRange();
4561 Diag(Loc, diag::err_bad_memptr_lhs)
4562 << OpSpelling << 1 << LHSType
4571 OpSpelling, (
int)isIndirect)) {
4576 Diag(Loc, diag::err_bad_memptr_lhs) << OpSpelling
4584 RHS.
get()->getLocEnd()),
4598 Diag(Loc, diag::err_pointer_to_member_type) << isIndirect;
4617 switch (Proto->getRefQualifier()) {
4624 Diag(Loc, diag::err_pointer_to_member_oper_value_classify)
4625 << RHSType << 1 << LHS.
get()->getSourceRange();
4630 Diag(Loc, diag::err_pointer_to_member_oper_value_classify)
4631 << RHSType << 0 << LHS.
get()->getSourceRange();
4646 }
else if (isIndirect) {
4664 bool &HaveConversion,
4666 HaveConversion =
false;
4687 HaveConversion =
true;
4692 return InitSeq.
Diagnose(Self, Entity, Kind, From);
4702 bool FDerivedFromT = FRec && TRec && FRec != TRec &&
4704 if (FRec && TRec && (FRec == TRec || FDerivedFromT ||
4709 if (FRec == TRec || FDerivedFromT) {
4714 HaveConversion =
true;
4719 return InitSeq.
Diagnose(Self, Entity, Kind, From);
4738 HaveConversion = !InitSeq.
Failed();
4741 return InitSeq.
Diagnose(Self, Entity, Kind, From);
4789 Self.
Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands)
4790 << LHS.
get()->getType() << RHS.
get()->getType()
4791 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
4795 Self.
Diag(QuestionLoc, diag::err_conditional_ambiguous_ovl)
4796 << LHS.
get()->getType() << RHS.
get()->getType()
4797 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
4803 llvm_unreachable(
"Conditional operator has only built-in overloads");
4858 if (LVoid || RVoid) {
4865 if (LThrow != RThrow) {
4866 Expr *NonThrow = LThrow ? RHS.
get() : LHS.
get();
4880 Diag(QuestionLoc, diag::err_conditional_void_nonvoid)
4881 << (LVoid ? RTy : LTy) << (LVoid ? 0 : 1)
4882 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
4896 bool HaveL2R, HaveR2L;
4903 if (HaveL2R && HaveR2L) {
4904 Diag(QuestionLoc, diag::err_conditional_ambiguous)
4905 << LTy << RTy << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
4916 }
else if (HaveR2L) {
4937 if (RCVR.isStrictSupersetOf(LCVR)) {
4955 if (Same && LVK == RVK && LVK !=
VK_RValue &&
4968 if (!Same && (LTy->isRecordType() || RTy->
isRecordType())) {
4984 RTy = RHS.get()->getType();
4993 if (LTy->isRecordType()) {
4996 diag::err_allocation_of_abstract_type))
5051 bool NonStandardCompositeType =
false;
5054 : &NonStandardCompositeType);
5055 if (!Composite.
isNull()) {
5056 if (NonStandardCompositeType)
5058 diag::ext_typecheck_cond_incompatible_operands_nonstandard)
5059 << LTy << RTy << Composite
5060 << LHS.
get()->getSourceRange() << RHS.get()->getSourceRange();
5074 Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands)
5075 << LHS.
get()->
getType() << RHS.get()->getType()
5076 << LHS.
get()->getSourceRange() << RHS.get()->getSourceRange();
5096 bool *NonStandardCompositeType) {
5097 if (NonStandardCompositeType)
5098 *NonStandardCompositeType =
false;
5110 !T2->isAnyPointerType() && !T2->isMemberPointerType()) {
5116 if (T2->isNullPtrType() &&
5125 if (T2->isMemberPointerType())
5141 (!T2->isPointerType() && !T2->isMemberPointerType()))
5156 QualifierVector QualifierUnion;
5158 ContainingClassVector;
5159 ContainingClassVector MemberOfClass;
5162 unsigned NeedConstBefore = 0;
5172 if (NonStandardCompositeType &&
5174 NeedConstBefore = QualifierUnion.size();
5176 QualifierUnion.push_back(
5178 MemberOfClass.push_back(std::make_pair(
nullptr,
nullptr));
5190 if (NonStandardCompositeType &&
5192 NeedConstBefore = QualifierUnion.size();
5194 QualifierUnion.push_back(
5196 MemberOfClass.push_back(std::make_pair(MemPtr1->
getClass(),
5207 if (NeedConstBefore && NonStandardCompositeType) {
5211 for (
unsigned I = 0;
I != NeedConstBefore; ++
I) {
5214 *NonStandardCompositeType =
true;
5220 ContainingClassVector::reverse_iterator MOC
5221 = MemberOfClass.rbegin();
5222 for (QualifierVector::reverse_iterator
5223 I = QualifierUnion.rbegin(),
5224 E = QualifierUnion.rend();
5225 I !=
E; (void)++
I, ++MOC) {
5227 if (MOC->first && MOC->second) {
5252 if (E1ToC1 && E2ToC1) {
5261 if (E1ToC2 && E2ToC2) {
5270 = E1ToC1.
Perform(*
this, Entity1, Kind, E1);
5277 = E2ToC1.
Perform(*
this, Entity1, Kind, E2);
5278 if (E2Result.isInvalid())
5280 E2 = E2Result.getAs<
Expr>();
5290 if (!E1ToC2 || !E2ToC2)
5295 = E1ToC2.
Perform(*
this, Entity2, Kind, E1);
5302 = E2ToC2.
Perform(*
this, Entity2, Kind, E2);
5303 if (E2Result.isInvalid())
5305 E2 = E2Result.getAs<
Expr>();
5314 assert(!isa<CXXBindTemporaryExpr>(E) &&
"Double-bound temporary?");
5325 bool ReturnsRetained;
5329 if (
CallExpr *Call = dyn_cast<CallExpr>(E)) {
5336 T = BinOp->getRHS()->getType();
5337 else if (
MemberExpr *Mem = dyn_cast<MemberExpr>(Callee))
5338 T = Mem->getMemberDecl()->getType();
5349 assert(FTy &&
"call to value not of function type?");
5354 }
else if (isa<StmtExpr>(E)) {
5355 ReturnsRetained =
true;
5359 }
else if (isa<CastExpr>(E) &&
5360 isa<BlockExpr>(cast<CastExpr>(E)->getSubExpr())) {
5369 D = Send->getMethodDecl();
5370 }
else if (
ObjCBoxedExpr *BoxedExpr = dyn_cast<ObjCBoxedExpr>(E)) {
5371 D = BoxedExpr->getBoxingMethod();
5373 D = ArrayLit->getArrayWithObjectsMethod();
5375 = dyn_cast<ObjCDictionaryLiteral>(E)) {
5376 D = DictLit->getDictWithObjectsMethod();
5379 ReturnsRetained = (D && D->
hasAttr<NSReturnsRetainedAttr>());
5384 if (!ReturnsRetained &&
5411 RT = cast<RecordType>(T);
5413 case Type::ConstantArray:
5414 case Type::IncompleteArray:
5415 case Type::VariableArray:
5416 case Type::DependentSizedArray:
5436 PDiag(diag::err_access_dtor_temp)
5467 assert(SubExpr &&
"subexpression can't be null!");
5487 assert(SubStmt &&
"sub-statement can't be null!");
5511 assert(
ExprEvalContexts.back().IsDecltype &&
"not in a decltype expression");
5523 if (
ParenExpr *PE = dyn_cast<ParenExpr>(E)) {
5527 if (SubExpr.
get() == PE->getSubExpr())
5536 if (RHS.
get() == BO->getRHS())
5539 BO->getLHS(), RHS.
get(),
BO_Comma, BO->getType(), BO->getValueKind(),
5540 BO->getObjectKind(), BO->getOperatorLoc(), BO->isFPContractable());
5564 if (Call == TopCall)
5579 if (Bind == TopBind)
5591 PDiag(diag::err_access_dtor_temp)
5607 unsigned SkipStart = OperatorArrows.size(), SkipCount = 0;
5610 if (OperatorArrows.size() > Limit) {
5612 SkipStart = (Limit - 1) / 2 + (Limit - 1) % 2;
5613 SkipCount = OperatorArrows.size() - (Limit - 1);
5616 for (
unsigned I = 0;
I < OperatorArrows.size(); ) {
5617 if (
I == SkipStart) {
5618 S.
Diag(OperatorArrows[
I]->getLocation(),
5619 diag::note_operator_arrows_suppressed)
5623 S.
Diag(OperatorArrows[
I]->getLocation(), diag::note_operator_arrow_here)
5624 << OperatorArrows[
I]->getCallResultType();
5634 bool &MayBePseudoDestructor) {
5638 Base = Result.
get();
5642 Base = Result.
get();
5645 MayBePseudoDestructor =
false;
5650 if (OpKind == tok::arrow)
5655 MayBePseudoDestructor =
true;
5662 if (OpKind == tok::arrow) {
5664 bool NoArrowOperatorFound =
false;
5665 bool FirstIteration =
true;
5668 llvm::SmallPtrSet<CanQualType,8> CTypes;
5673 if (OperatorArrows.size() >=
getLangOpts().ArrowDepth) {
5674 Diag(OpLoc, diag::err_operator_arrow_depth_exceeded)
5675 << StartingType <<
getLangOpts().ArrowDepth << Base->getSourceRange();
5677 Diag(OpLoc, diag::note_operator_arrow_depth)
5690 : &NoArrowOperatorFound);
5692 if (NoArrowOperatorFound) {
5693 if (FirstIteration) {
5694 Diag(OpLoc, diag::err_typecheck_member_reference_suggestion)
5695 << BaseType << 1 << Base->getSourceRange()
5697 OpKind = tok::period;
5700 Diag(OpLoc, diag::err_typecheck_member_reference_arrow)
5701 << BaseType << Base->getSourceRange();
5705 diag::note_member_reference_arrow_from_operator_arrow);
5710 Base = Result.
get();
5712 OperatorArrows.push_back(OpCall->getDirectCallee());
5715 if (!CTypes.insert(CBaseType).second) {
5716 Diag(OpLoc, diag::err_operator_arrow_circular) << StartingType;
5720 FirstIteration =
false;
5723 if (OpKind == tok::arrow &&
5746 MayBePseudoDestructor =
true;
5750 MayBePseudoDestructor =
true;
5778 Base = result.
get();
5788 if (OpKind == tok::arrow) {
5793 S.
Diag(OpLoc, diag::err_typecheck_member_reference_suggestion)
5794 << ObjectType <<
true
5799 OpKind = tok::period;
5817 if (
CheckArrow(*
this, ObjectType, Base, OpKind, OpLoc))
5823 Diag(OpLoc, diag::ext_pseudo_dtor_on_void) << Base->getSourceRange();
5825 Diag(OpLoc, diag::err_pseudo_dtor_base_not_scalar)
5826 << ObjectType << Base->getSourceRange();
5834 if (DestructedTypeInfo) {
5840 Diag(DestructedTypeStart, diag::err_pseudo_dtor_type_mismatch)
5841 << ObjectType << DestructedType << Base->getSourceRange()
5845 DestructedType = ObjectType;
5847 DestructedTypeStart);
5856 Diag(DestructedTypeStart, diag::err_arc_pseudo_dtor_inconstant_quals)
5857 << ObjectType << DestructedType << Base->getSourceRange()
5862 DestructedType = ObjectType;
5864 DestructedTypeStart);
5877 if (ScopeTypeInfo) {
5883 diag::err_pseudo_dtor_type_mismatch)
5884 << ObjectType << ScopeType << Base->getSourceRange()
5888 ScopeTypeInfo =
nullptr;
5894 OpKind == tok::arrow, OpLoc,
5914 "Invalid first type name in pseudo-destructor");
5917 "Invalid second type name in pseudo-destructor");
5920 if (
CheckArrow(*
this, ObjectType, Base, OpKind, OpLoc))
5941 S, &SS,
true,
false, ObjectTypePtrForLookup);
5953 diag::err_pseudo_dtor_destructor_non_type)
5959 DestructedType = ObjectType;
5974 if (T.isInvalid() || !T.get()) {
5976 DestructedType = ObjectType;
5983 if (!DestructedType.
isNull()) {
5984 if (!DestructedTypeInfo)
5998 S, &SS,
true,
false, ObjectTypePtrForLookup);
6001 diag::err_pseudo_dtor_destructor_non_type)
6023 if (T.isInvalid() || !T.get()) {
6031 if (!ScopeType.
isNull() && !ScopeTypeInfo)
6037 ScopeTypeInfo, CCLoc, TildeLoc,
6047 if (
CheckArrow(*
this, ObjectType, Base, OpKind, OpLoc))
6066 bool HadMultipleCandidates) {
6077 SubE = BE->getSubExpr();
6078 if (isa<LambdaExpr>(SubE)) {
6102 if (HadMultipleCandidates)
6112 Exp.
get()->getLocEnd());
6132 Diag(Operand->
getExprLoc(), diag::warn_side_effects_unevaluated_context);
6154 if (isa<DeclRefExpr>(E))
6158 if (isa<ArraySubscriptExpr>(E))
6162 if (isa<MemberExpr>(E))
6172 if (BO->isPtrMemOp())
6187 dyn_cast<BinaryConditionalOperator>(E)) {
6188 if (
OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(BCO->getTrueExpr()))
6194 if (isa<PseudoObjectExpr>(E) || isa<ObjCIvarRefExpr>(
E))
6242 if (!T->getDecl()->isComplete()) {
6256 diag::err_incomplete_type);
6274 if (isa<ParmVarDecl>(Var))
return true;
6275 const VarDecl *DefVD =
nullptr;
6280 if (DefVD->
isWeak())
return false;
6308 "The current call operator must be synchronized with Sema's CurContext");
6318 const unsigned NumPotentialCaptures =
6320 for (
unsigned I = 0;
I != NumPotentialCaptures; ++
I) {
6321 Expr *VarExpr =
nullptr;
6336 !IsFullExprInstantiationDependent)
6343 FunctionScopesArrayRef, Var, S)) {
6344 const unsigned FunctionScopeIndexOfCapturableLambda = Index.getValue();
6346 &FunctionScopeIndexOfCapturableLambda);
6348 const bool IsVarNeverAConstantExpression =
6350 if (!IsFullExprInstantiationDependent || IsVarNeverAConstantExpression) {
6362 DeclRefType,
nullptr)) {
6368 DeclRefType,
nullptr);
6379 FunctionScopesArrayRef,
nullptr, S)) {
6380 const unsigned FunctionScopeIndexOfCapturableLambda = Index.getValue();
6383 &FunctionScopeIndexOfCapturableLambda);
6406 R.setLookupName(ND->getDeclName());
6408 if (ND->isCXXClassMember()) {
6412 Record = NNS->getAsType()->getAsCXXRecordDecl();
6415 dyn_cast<
CXXRecordDecl>(ND->getDeclContext()->getRedeclContext());
6417 R.setNamingClass(Record);
6421 bool MightBeImplicitMember;
6423 MightBeImplicitMember =
true;
6425 MightBeImplicitMember =
false;
6426 else if (R.isOverloadedResult())
6427 MightBeImplicitMember =
false;
6428 else if (R.isUnresolvableResult())
6429 MightBeImplicitMember =
true;
6431 MightBeImplicitMember = isa<FieldDecl>(ND) ||
6432 isa<IndirectFieldDecl>(ND) ||
6433 isa<MSPropertyDecl>(ND);
6435 if (MightBeImplicitMember)
6439 }
else if (
auto *Ivar = dyn_cast<ObjCIvarDecl>(ND)) {
6441 Ivar->getIdentifier());
6455 : TypoExprs(TypoExprs) {}
6457 TypoExprs.insert(TE);
6462 class TransformTypos :
public TreeTransform<TransformTypos> {
6467 llvm::function_ref<ExprResult(Expr *)> ExprFilter;
6469 llvm::SmallDenseMap<TypoExpr *, ExprResult, 2> TransformCache;
6470 llvm::SmallDenseMap<OverloadExpr *, Expr *, 4> OverloadResolution;
6476 void EmitAllDiagnostics() {
6477 for (
auto E : TypoExprs) {
6479 auto &
State = SemaRef.getTypoExprState(TE);
6480 if (State.DiagHandler) {
6490 Replacement.
isInvalid() ?
nullptr : Replacement.
get()))
6493 State.DiagHandler(TC);
6495 SemaRef.clearDelayedTypo(TE);
6508 bool CheckAndAdvanceTypoExprCorrectionStreams() {
6509 for (
auto TE : TypoExprs) {
6510 auto &State = SemaRef.getTypoExprState(TE);
6511 TransformCache.erase(TE);
6512 if (!State.Consumer->finished())
6514 State.Consumer->resetCorrectionStream();
6520 if (
auto *OE = dyn_cast_or_null<OverloadExpr>(E))
6521 E = OverloadResolution[OE];
6525 if (
auto *DRE = dyn_cast<DeclRefExpr>(E))
6526 return DRE->getFoundDecl();
6527 if (
auto *ME = dyn_cast<MemberExpr>(E))
6538 if (Trap.hasErrorOccurred() || Res.
isInvalid())
6541 return ExprFilter(Res.
get());
6546 : BaseTransform(SemaRef), InitDecl(InitDecl), ExprFilter(Filter) {}
6551 Expr *ExecConfig =
nullptr) {
6552 auto Result = BaseTransform::RebuildCallExpr(Callee, LParenLoc, Args,
6553 RParenLoc, ExecConfig);
6554 if (
auto *OE = dyn_cast<OverloadExpr>(Callee)) {
6557 if (
auto *BE = dyn_cast<CXXBindTemporaryExpr>(ResultCall))
6558 ResultCall = BE->getSubExpr();
6559 if (
auto *CE = dyn_cast<CallExpr>(ResultCall))
6560 OverloadResolution[OE] = CE->getCallee();
6573 Res = TryTransform(E);
6578 !CheckAndAdvanceTypoExprCorrectionStreams())
6591 while (!AmbiguousTypoExprs.empty()) {
6592 auto TE = AmbiguousTypoExprs.back();
6593 auto Cached = TransformCache[TE];
6595 State.Consumer->saveCurrentPosition();
6596 TransformCache.erase(TE);
6598 State.Consumer->resetCorrectionStream();
6599 TransformCache.erase(TE);
6603 AmbiguousTypoExprs.remove(TE);
6604 State.Consumer->restoreSavedPosition();
6605 TransformCache[TE] = Cached;
6611 FindTypoExprs(TypoExprs).TraverseStmt(E);
6613 EmitAllDiagnostics();
6622 auto &CacheEntry = TransformCache[
E];
6623 if (!TypoExprs.insert(E) && !CacheEntry.isUnset()) {
6628 assert(State.Consumer &&
"Cannot transform a cleared TypoExpr");
6632 while (
TypoCorrection TC = State.Consumer->getNextCorrection()) {
6636 State.RecoveryHandler(SemaRef, E, TC) :
6643 if ((Next = State.Consumer->peekNextCorrection()) &&
6645 AmbiguousTypoExprs.insert(E);
6647 AmbiguousTypoExprs.remove(E);
6650 "Typo was transformed into a valid-but-null ExprResult");
6651 return CacheEntry = NE;
6669 assert(TyposInContext < ~0U &&
"Recursive call of CorrectDelayedTyposInExpr");
6671 auto TyposResolved = DelayedTypos.size();
6672 auto Result = TransformTypos(*
this, InitDecl, Filter).Transform(E);
6674 TyposResolved -= DelayedTypos.size();
6679 assert(TyposResolved == 0 &&
"Corrected typo but got same Expr back?");
6685 bool DiscardedValue,
6687 bool IsLambdaInitCaptureInitializer) {
6690 if (!FullExpr.
get())
6708 if (!IsLambdaInitCaptureInitializer &&
6713 if (DiscardedValue &&
getLangOpts().DebuggerCastResultToId &&
6720 if (DiscardedValue) {
6734 CheckCompletedExpr(FullExpr.
get(), CC, IsConstexpr);
6782 if (IsInLambdaDeclContext && CurrentLSI &&
6783 CurrentLSI->hasPotentialCaptures() && !FullExpr.
isInvalid())
6827 llvm_unreachable(
"Invalid LookupResult Kind!");
6840 if (!Unexpanded.empty()) {
bool isDependentName() const
Determines whether the name itself is dependent, e.g., because it involves a C++ type that is itself ...
static bool CheckArrow(Sema &S, QualType &ObjectType, Expr *&Base, tok::TokenKind &OpKind, SourceLocation OpLoc)
unsigned getFlags() const
getFlags - Return the flags for this scope.
A call to an overloaded operator written using operator syntax.
unsigned getAddressSpace() const
Return the address space of this type.
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
bool isObjCObjectOrInterfaceType() const
DeclAccessPair FoundConversionFunction
The declaration that we found via name lookup, which might be the same as ConversionFunction or it mi...
Defines the clang::ASTContext interface.
bool isAddressOfOperand() const
SourceLocation getEnd() const
CanThrowResult canThrow(const Expr *E)
unsigned DeprecatedStringLiteralToCharPtr
Whether this is the deprecated conversion of a string literal to a pointer to non-const character dat...
QualType getCurrentThisType()
Try to retrieve the type of the 'this' pointer.
This is the scope of a C++ try statement.
ExprResult ActOnArrayTypeTrait(ArrayTypeTrait ATT, SourceLocation KWLoc, ParsedType LhsTy, Expr *DimExpr, SourceLocation RParen)
ActOnArrayTypeTrait - Parsed one of the bianry type trait support pseudo-functions.
CastKind getCastKind() const
The null pointer literal (C++11 [lex.nullptr])
void clearPotentialCaptures()
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...
bool FindDeallocationFunction(SourceLocation StartLoc, CXXRecordDecl *RD, DeclarationName Name, FunctionDecl *&Operator, bool Diagnose=true)
Name lookup found a set of overloaded functions that met the criteria.
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 EllipsisConversion
EllipsisConversion - When this is true, it means user-defined conversion sequence starts with a ...
bool isNullPtrType() const
static bool EvaluateExpressionTrait(ExpressionTrait ET, Expr *E)
ExprResult PerformContextuallyConvertToBool(Expr *From)
PerformContextuallyConvertToBool - Perform a contextual conversion of the expression From to bool (C+...
bool Diagnose(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, ArrayRef< Expr * > Args)
Diagnose an potentially-invalid initialization sequence.
bool isNonOverloadPlaceholderType() const
Test for a placeholder type other than Overload; see BuiltinType::isNonOverloadPlaceholderType.
PointerType - C99 6.7.5.1 - Pointer Declarators.
bool isAtLeastAsQualifiedAs(QualType Other) const
Determine whether this type is at least as qualified as the other given type, requiring exact equalit...
Stores the type being destroyed by a pseudo-destructor expression.
A (possibly-)qualified type.
This is a scope that corresponds to the parameters within a function prototype.
Simple class containing the result of Sema::CorrectTypo.
static bool IsSpecialDiscardedValue(Expr *E)
bool CheckExceptionSpecCompatibility(Expr *From, QualType ToType)
void EraseUnwantedCUDAMatches(const FunctionDecl *Caller, SmallVectorImpl< FunctionDecl * > &Matches)
Finds a function in Matches with highest calling priority from Caller context and erases all function...
bool checkLiteralOperatorId(const CXXScopeSpec &SS, const UnqualifiedId &Id)
QualType getConversionType() const
Returns the type that this conversion function is converting to.
bool hasTrivialDestructor() const
Determine whether this class has a trivial destructor (C++ [class.dtor]p3)
DestructionKind isDestructedType() const
Returns a nonzero value if objects of this type require non-trivial work to clean up after...
bool isMemberPointerType() const
static InitializedEntity InitializeException(SourceLocation ThrowLoc, QualType Type, bool NRVO)
Create the initialization entity for an exception object.
SourceLocation StartLocation
The location of the first token that describes this unqualified-id, which will be the location of the...
static const CastKind CK_Invalid
const FunctionProtoType * ResolveExceptionSpec(SourceLocation Loc, const FunctionProtoType *FPT)
bool tryAddTopLevelDecl(NamedDecl *D, DeclarationName Name)
Try to add the given declaration to the top level scope, if it (or a redeclaration of it) hasn't alre...
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc...
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
SourceLocation TemplateNameLoc
TemplateNameLoc - The location of the template name within the source.
Qualifiers::ObjCLifetime getObjCARCImplicitLifetime() const
Return the implicit lifetime for this type, which must not be dependent.
DeclClass * getAsSingle() const
static void collectPublicBases(CXXRecordDecl *RD, llvm::DenseMap< CXXRecordDecl *, unsigned > &SubobjectsSeen, llvm::SmallPtrSetImpl< CXXRecordDecl * > &VBases, llvm::SetVector< CXXRecordDecl * > &PublicSubobjectsSeen, bool ParentIsPublic)
QualType CXXThisTypeOverride
When non-NULL, the C++ 'this' expression is allowed despite the current context not being a non-stati...
IdentifierInfo * Identifier
When Kind == IK_Identifier, the parsed identifier, or when Kind == IK_UserLiteralId, the identifier suffix.
bool isGenericLambdaCallOperatorSpecialization(const CXXMethodDecl *MD)
bool isFixed() const
Returns true if this is an Objective-C, C++11, or Microsoft-style enumeration with a fixed underlying...
Filter makeFilter()
Create a filter for this result set.
FunctionType - C99 6.7.5.3 - Function Declarators.
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
Provides information about an attempted template argument deduction, whose success or failure was des...
QualType getRValueReferenceType(QualType T) const
Return the uniqued reference to the type for an rvalue reference to the specified type...
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
Microsoft __if_not_exists.
static void getUnambiguousPublicSubobjects(CXXRecordDecl *RD, llvm::SmallVectorImpl< CXXRecordDecl * > &Objects)
const Scope * getParent() const
getParent - Return the scope that this is nested in.
ActionResult< Expr * > ExprResult
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in...
Complex conversions (C99 6.3.1.6)
bool hasPlaceholderType() const
Returns whether this expression has a placeholder type.
void erase()
Erase the last element returned from this iterator.
bool isRecordType() const
UserDefinedConversionSequence UserDefined
When ConversionKind == UserDefinedConversion, provides the details of the user-defined conversion seq...
static bool FindConditionalOverload(Sema &Self, ExprResult &LHS, ExprResult &RHS, SourceLocation QuestionLoc)
Try to find a common type for two according to C++0x 5.16p5.
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
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...
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 ActOnNoexceptExpr(SourceLocation KeyLoc, SourceLocation LParen, Expr *Operand, SourceLocation RParen)
ExprResult CheckBooleanCondition(Expr *E, SourceLocation Loc)
CheckBooleanCondition - Diagnose problems involving the use of the given expression as a boolean cond...
AccessResult CheckConstructorAccess(SourceLocation Loc, CXXConstructorDecl *D, const InitializedEntity &Entity, AccessSpecifier Access, bool IsCopyBindingRefToTemp=false)
Checks access to a constructor.
void addDefaultArgExprForConstructor(const CXXConstructorDecl *CD, unsigned ParmIdx, Expr *DAE)
AssignConvertType
AssignConvertType - All of the 'assignment' semantic checks return this enum to indicate whether the ...
ExprResult PerformContextualImplicitConversion(SourceLocation Loc, Expr *FromE, ContextualImplicitConverter &Converter)
Perform a contextual implicit conversion.
bool isLiteralType(const ASTContext &Ctx) const
Return true if this is a literal type (C++11 [basic.types]p10)
bool LookupParsedName(LookupResult &R, Scope *S, CXXScopeSpec *SS, bool AllowBuiltinCreation=false, bool EnteringContext=false)
Performs name lookup for a name that was parsed in the source code, and may contain a C++ scope speci...
ExprResult BuildBlockForLambdaConversion(SourceLocation CurrentLocation, SourceLocation ConvLocation, CXXConversionDecl *Conv, Expr *Src)
bool isEnumeralType() const
ParenExpr - This represents a parethesized expression, e.g.
ExprResult forceUnknownAnyToType(Expr *E, QualType ToType)
Force an expression with unknown-type to an expression of the given type.
static InitializationKind CreateDirect(SourceLocation InitLoc, SourceLocation LParenLoc, SourceLocation RParenLoc)
Create a direct initialization.
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type...
TemplateSpecializationType(TemplateName T, const TemplateArgument *Args, unsigned NumArgs, QualType Canon, QualType Aliased)
bool hasErrorOccurred() const
Determine whether any SFINAE errors have been trapped.
QualType getPointeeType() const
The base class of the type hierarchy.
This indicates that the scope corresponds to a function, which means that labels are set here...
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
unsigned IncompatibleObjC
IncompatibleObjC - Whether this is an Objective-C conversion that we should warn about (if we actuall...
unsigned getCVRQualifiers() const
Retrieve the set of CVR (const-volatile-restrict) qualifiers applied to this type.
QualType getRecordType(const RecordDecl *Decl) const
One instance of this struct is used for each type in a declarator that is parsed. ...
bool isCopyConstructor(unsigned &TypeQuals) const
Whether this constructor is a copy constructor (C++ [class.copy]p2, which can be used to copy the cla...
Represents an array type, per C99 6.7.5.2 - Array Declarators.
void MarkDeclRefReferenced(DeclRefExpr *E)
Perform reference-marking and odr-use handling for a DeclRefExpr.
static InitializationKind CreateDefault(SourceLocation InitLoc)
Create a default initialization.
static void CheckIfAnyEnclosingLambdasMustCaptureAnyPotentialCaptures(Expr *const FE, LambdaScopeInfo *const CurrentLSI, Sema &S)
Check if the current lambda has any potential captures that must be captured by any of its enclosing ...
NestedNameSpecifier * getPrefix() const
Return the prefix of this nested name specifier.
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Calls Lexer::getLocForEndOfToken()
Represents a call to a C++ constructor.
static ExprValueKind getValueKindForType(QualType T)
getValueKindForType - Given a formal return or parameter type, give its value kind.
An Embarcadero array type trait, as used in the implementation of __array_rank and __array_extent...
Ambiguous candidates found.
CK_FloatingToIntegral - Floating point to integral.
bool isBooleanType() const
A container of type source information.
bool hasPotentialThisCapture() const
Conversions between compatible types in C99.
bool isBlockPointerType() const
static bool evaluateTypeTrait(Sema &S, TypeTrait Kind, SourceLocation KWLoc, ArrayRef< TypeSourceInfo * > Args, SourceLocation RParenLoc)
static CXXFunctionalCastExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, TypeSourceInfo *Written, CastKind Kind, Expr *Op, const CXXCastPath *Path, SourceLocation LPLoc, SourceLocation RPLoc)
ExprResult ActOnExpressionTrait(ExpressionTrait OET, SourceLocation KWLoc, Expr *Queried, SourceLocation RParen)
ActOnExpressionTrait - Parsed one of the unary type trait support pseudo-functions.
[ARC] Consumes a retainable object pointer that has just been produced, e.g.
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 isCopyAssignmentOperator() const
Determine whether this is a copy-assignment operator, regardless of whether it was declared implicitl...
static InitializedEntity InitializeTemporary(QualType Type)
Create the initialization entity for a temporary.
CK_IntegralToFloating - Integral to floating point.
bool DisableTypoCorrection
Tracks whether we are in a context where typo correction is disabled.
An identifier, stored as an IdentifierInfo*.
This file provides some common utility functions for processing Lambda related AST Constructs...
void Adopt(NestedNameSpecifierLoc Other)
Adopt an existing nested-name-specifier (with source-range information).
RAII object that enters a new expression evaluation context.
VarDecl - An instance of this class is created to represent a variable declaration or definition...
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
CK_IntegralCast - A cast between integral types (other than to boolean).
ExprResult PerformObjectArgumentInitialization(Expr *From, NestedNameSpecifier *Qualifier, NamedDecl *FoundDecl, CXXMethodDecl *Method)
PerformObjectArgumentInitialization - Perform initialization of the implicit object parameter for the...
IfExistsResult
Describes the result of an "if-exists" condition check.
Expr * getInit() const
Get the initializer.
Information about one declarator, including the parsed type information and the identifier.
DiagnosticsEngine & Diags
ExprResult CheckConditionVariable(VarDecl *ConditionVar, SourceLocation StmtLoc, bool ConvertToBoolean)
Check the use of the given variable as a C++ condition in an if, while, do-while, or switch statement...
DeclContext * computeDeclContext(QualType T)
Compute the DeclContext that is associated with the given type.
Extra information about a function prototype.
AccessSpecifier getAccess() const
AccessResult CheckDestructorAccess(SourceLocation Loc, CXXDestructorDecl *Dtor, const PartialDiagnostic &PDiag, QualType objectType=QualType())
std::string getDeletedOrUnavailableSuffix(const FunctionDecl *FD)
Retrieve the message suffix that should be added to a diagnostic complaining about the given function...
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
RAII class that determines when any errors have occurred between the time the instance was created an...
ObjCMethodDecl - Represents an instance or class method declaration.
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
A namespace, stored as a NamespaceDecl*.
bool HadMultipleCandidates
HadMultipleCandidates - When this is true, it means that the conversion function was resolved from an...
bool isTrivialType(ASTContext &Context) const
Return true if this is a trivial type per (C++0x [basic.types]p9)
Removal of noreturn from a type (Clang)
bool isMemberDataPointerType() const
static InitializationKind CreateDirectList(SourceLocation InitLoc)
bool hasNonTrivialMoveAssignment() const
Determine whether this class has a non-trivial move assignment operator (C++11 [class.copy]p25)
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.
A C++ throw-expression (C++ [except.throw]).
static bool doesUsualArrayDeleteWantSize(Sema &S, SourceLocation loc, QualType allocType)
doesUsualArrayDeleteWantSize - Answers whether the usual operator delete[] for the given type has a s...
ParmVarDecl - Represents a parameter to a function.
bool isObjCRetainableType() const
NullPointerConstantKind isNullPointerConstant(ASTContext &Ctx, NullPointerConstantValueDependence NPC) const
isNullPointerConstant - C99 6.3.2.3p3 - Test if this reduces down to a Null pointer constant...
bool isMoveAssignmentOperator() const
Determine whether this is a move assignment operator.
Defines the clang::Expr interface and subclasses for C++ expressions.
bool isEmpty() const
No scope specifier.
The collection of all-type qualifiers we support.
Information about a template-id annotation token.
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.
static CXXUnresolvedConstructExpr * Create(const ASTContext &C, TypeSourceInfo *Type, SourceLocation LParenLoc, ArrayRef< Expr * > Args, SourceLocation RParenLoc)
QualType getArrayDecayedType(QualType T) const
Return the properly qualified result of decaying the specified array type to a pointer.
bool hasTrivialCopyConstructor() const
Determine whether this class has a trivial copy constructor (C++ [class.copy]p6, C++11 [class...
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 setCorrectionDecl(NamedDecl *CDecl)
Clears the list of NamedDecls before adding the new one.
static void noteOperatorArrows(Sema &S, ArrayRef< FunctionDecl * > OperatorArrows)
Note a set of 'operator->' functions that were used for a member access.
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.
QualType FindCompositeObjCPointerType(ExprResult &LHS, ExprResult &RHS, SourceLocation QuestionLoc)
FindCompositeObjCPointerType - Helper method to find composite type of two objective-c pointer types ...
bool isFunctionTemplateSpecialization() const
Determine whether this function is a function template specialization.
static bool ConvertForConditional(Sema &Self, ExprResult &E, QualType T)
Perform an "extended" implicit conversion as returned by TryClassUnification.
TemplateIdAnnotation * TemplateId
When Kind == IK_TemplateId or IK_ConstructorTemplateId, the template-id annotation that contains the ...
DeclarationName getName() const
getName - Returns the embedded declaration name.
Boolean conversions (C++ 4.12)
Represents a class template specialization, which refers to a class template with a given set of temp...
One of these records is kept for each identifier that is lexed.
Name lookup results in an ambiguity; use getAmbiguityKind to figure out what kind of ambiguity we hav...
bool isScalarType() const
bool isEmpty() const
Determine whether this is an empty class in the sense of (C++11 [meta.unary.prop]).
DeclarationNameInfo GetNameFromUnqualifiedId(const UnqualifiedId &Name)
Retrieves the declaration name from a parsed unqualified-id.
OpaquePtr< QualType > ParsedType
An opaque type for threading parsed type information through the parser.
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
bool isDirectReferenceBinding() const
Determine whether this initialization is a direct reference binding (C++ [dcl.init.ref]).
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
void DropFirstTypeObject()
A C++ nested-name-specifier augmented with source location information.
Represents a dependent template name that cannot be resolved prior to template instantiation.
Converts between different integral complex types.
The results of name lookup within a DeclContext.
bool isObjCARCImplicitlyUnretainedType() const
Determines if this type, which must satisfy isObjCLifetimeType(), is implicitly __unsafe_unretained r...
bool hasNonTrivialCopyConstructor() const
Determine whether this class has a non-trivial copy constructor (C++ [class.copy]p6, C++11 [class.copy]p12)
bool IsDerivedFrom(SourceLocation Loc, QualType Derived, QualType Base)
Determine whether the type Derived is a C++ class that is derived from the type Base.
const ASTMatchFinder::BindKind Bind
QualType getLifetimeQualifiedType(QualType type, Qualifiers::ObjCLifetime lifetime)
Return a type with the given lifetime qualifier.
bool isReferenceType() const
QualType getReturnType() const
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
bool isAnyPointerType() const
Identity conversion (no conversion)
void AddBuiltinOperatorCandidates(OverloadedOperatorKind Op, SourceLocation OpLoc, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet)
AddBuiltinOperatorCandidates - Add the appropriate built-in operator overloads to the candidate set (...
bool isAbstractType(SourceLocation Loc, QualType T)
TypeResult ActOnTemplateIdType(CXXScopeSpec &SS, SourceLocation TemplateKWLoc, TemplateTy Template, SourceLocation TemplateLoc, SourceLocation LAngleLoc, ASTTemplateArgsPtr TemplateArgs, SourceLocation RAngleLoc, bool IsCtorOrDtorName=false)
Floating point conversions (C++ 4.8)
The iterator over UnresolvedSets.
SourceRange getLocalSourceRange() const
Get the local source range.
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
CK_FloatingCast - Casting between floating types of different size.
static const TST TST_error
ExprResult ActOnCXXUuidof(SourceLocation OpLoc, SourceLocation LParenLoc, bool isType, void *TyOrExpr, SourceLocation RParenLoc)
ActOnCXXUuidof - Parse __uuidof( something ).
ExprResult BuildArrayTypeTrait(ArrayTypeTrait ATT, SourceLocation KWLoc, TypeSourceInfo *TSInfo, Expr *DimExpr, SourceLocation RParen)
CK_VectorSplat - A conversion from an arithmetic type to a vector of that element type...
static DeclRefExpr * Create(const ASTContext &Context, NestedNameSpecifierLoc QualifierLoc, SourceLocation TemplateKWLoc, ValueDecl *D, bool RefersToEnclosingVariableOrCapture, SourceLocation NameLoc, QualType T, ExprValueKind VK, NamedDecl *FoundD=nullptr, const TemplateArgumentListInfo *TemplateArgs=nullptr)
ExprResult ActOnCXXNullPtrLiteral(SourceLocation Loc)
ActOnCXXNullPtrLiteral - Parse 'nullptr'.
bool hasNonTrivialDefaultConstructor() const
Determine whether this class has a non-trivial default constructor (C++11 [class.ctor]p5).
SourceLocation getTypeSpecTypeLoc() const
static unsigned getNumAddressingBits(ASTContext &Context, QualType ElementType, const llvm::APInt &NumElements)
Determine the number of bits required to address a member of.
ParsedType getDestructorName(SourceLocation TildeLoc, IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec &SS, ParsedType ObjectType, bool EnteringContext)
ObjCArrayLiteral - used for objective-c array containers; as in: @["Hello", NSApp, [NSNumber numberWithInt:42]];.
CK_NullToPointer - Null pointer constant to pointer, ObjC pointer, or block pointer.
static bool hasNontrivialObjCLifetime(QualType T)
Determine whether T has a non-trivial Objective-C lifetime in ARC mode.
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.
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
No entity found met the criteria within the current instantiation,, but there were dependent base cla...
Stmt * MaybeCreateStmtWithCleanups(Stmt *SubStmt)
void NoteDeletedFunction(FunctionDecl *FD)
Emit a note explaining that this function is deleted.
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
void getPotentialVariableCapture(unsigned Idx, VarDecl *&VD, Expr *&E) const
Floating point promotions (C++ 4.6)
bool hasStatic
True if this dimension included the 'static' keyword.
ExprResult ActOnStartCXXMemberReference(Scope *S, Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind, ParsedType &ObjectType, bool &MayBePseudoDestructor)
SourceLocation getBeginLoc() const
Get the begin source location.
Describes an C or C++ initializer list.
A C++ typeid expression (C++ [expr.typeid]), which gets the type_info that corresponds to the supplie...
bool isIntegralOrUnscopedEnumerationType() const
Determine whether this type is an integral or unscoped enumeration type.
CK_IntegralToBoolean - Integral to boolean.
This is a scope that corresponds to a block/closure object.
ExprResult ActOnCXXThrow(Scope *S, SourceLocation OpLoc, Expr *expr)
ActOnCXXThrow - Parse throw expressions.
Represents a C++ unqualified-id that has been parsed.
bool isCompleteType(SourceLocation Loc, QualType T)
void setNameLoc(SourceLocation Loc)
NamespaceDecl * getOrCreateStdNamespace()
Retrieve the special "std" namespace, which may require us to implicitly define the namespace...
Represents the results of name lookup.
void DeclareGlobalNewDelete()
DeclareGlobalNewDelete - Declare the global forms of operator new and delete.
const TargetInfo & getTargetInfo() const
An lvalue ref-qualifier was provided (&).
bool DiagnoseUnexpandedParameterPacks(SourceLocation Loc, UnexpandedParameterPackContext UPPC, ArrayRef< UnexpandedParameterPack > Unexpanded)
Diagnose unexpanded parameter packs.
bool DiagnoseUseOfDecl(NamedDecl *D, SourceLocation Loc, const ObjCInterfaceDecl *UnknownObjCClass=nullptr, bool ObjCPropertyAccess=false)
Determine whether the use of this declaration is valid, and emit any corresponding diagnostics...
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...
const LangOptions & getLangOpts() const
unsigned getNumTypeObjects() const
Return the number of types applied to this declarator.
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
ParsedType getTypeName(const IdentifierInfo &II, SourceLocation NameLoc, Scope *S, CXXScopeSpec *SS=nullptr, bool isClassName=false, bool HasTrailingDot=false, ParsedType ObjectType=ParsedType(), bool IsCtorOrDtorName=false, bool WantNontrivialTypeSourceInfo=false, IdentifierInfo **CorrectedII=nullptr)
If the identifier refers to a type name within this scope, return the declaration of that type...
bool isFundamentalType() const
Tests whether the type is categorized as a fundamental type.
Succeeded, but refers to a deleted function.
const CXXScopeSpec * getSS() const
bool CheckCXXThrowOperand(SourceLocation ThrowLoc, QualType ThrowTy, Expr *E)
CheckCXXThrowOperand - Validate the operand of a throw.
ObjCMethodFamily getMethodFamily() const
Determines the family of this method.
ExprResult BuildCXXNew(SourceRange Range, bool UseGlobal, SourceLocation PlacementLParen, MultiExprArg PlacementArgs, SourceLocation PlacementRParen, SourceRange TypeIdParens, QualType AllocType, TypeSourceInfo *AllocTypeInfo, Expr *ArraySize, SourceRange DirectInitRange, Expr *Initializer, bool TypeMayContainAuto=true)
const CXXRecordDecl * getParent() const
Returns the parent of this method declaration, which is the class in which this method is defined...
bool isObjCLifetimeType() const
Returns true if objects of this type have lifetime semantics under ARC.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
char * location_data() const
Retrieve the data associated with the source-location information.
SourceLocation getLocStart() const LLVM_READONLY
TypeDecl - Represents a declaration of a type.
A builtin binary operation expression such as "x + y" or "x <= y".
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
RecordDecl * getDecl() const
ImplicitConversionKind Second
Second - The second conversion can be an integral promotion, floating point promotion, integral conversion, floating point conversion, floating-integral conversion, pointer conversion, pointer-to-member conversion, or boolean conversion.
ParsedTemplateArgument * getTemplateArgs()
Retrieves a pointer to the template arguments.
static InitializationKind CreateValue(SourceLocation InitLoc, SourceLocation LParenLoc, SourceLocation RParenLoc, bool isImplicit=false)
Create a value initialization.
CheckedConversionKind
The kind of conversion being performed.
bool isUnsignedIntegerType() const
Return true if this is an integer type that is unsigned, according to C99 6.2.5p6 [which returns true...
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...
LazyDeclPtr StdBadAlloc
The C++ "std::bad_alloc" class, which is defined by the C++ standard library.
IfExistsResult CheckMicrosoftIfExistsSymbol(Scope *S, CXXScopeSpec &SS, const DeclarationNameInfo &TargetNameInfo)
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...
New-expression has a C++98 paren-delimited initializer.
TypoExpr - Internal placeholder for expressions where typo correction still needs to be performed and...
Qualification conversions (C++ 4.4)
bool isAmbiguous() const
Determine whether this initialization failed due to an ambiguity.
ExprResult ActOnCXXThis(SourceLocation loc)
bool isWeak() const
Determine whether this symbol is weakly-imported, or declared with the weak or weak-ref attr...
Represents a C++ nested-name-specifier or a global scope specifier.
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
TypeSourceInfo * getTypeSourceInfo() const
TypeClass getTypeClass() const
bool isStructureType() const
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.
ArrayTypeTrait
Names for the array type traits.
CXXTemporary * getTemporary()
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'.
ExprResult DefaultFunctionArrayLvalueConversion(Expr *E, bool Diagnose=true)
An ordinary object is located at an address in memory.
bool isLambdaCallOperator(const CXXMethodDecl *MD)
SmallVector< BoundNodes, 1 > match(MatcherT Matcher, const NodeT &Node, ASTContext &Context)
Returns the results of matching Matcher on Node.
The number of conversion kinds.
A class that does preorder depth-first traversal on the entire Clang AST and visits each node...
CastKind PrepareScalarCast(ExprResult &src, QualType destType)
Prepares for a scalar cast, performing all the necessary stages except the final cast and returning t...
ImplicitConversionKind Third
Third - The third conversion can be a qualification conversion.
detail::InMemoryDirectory::const_iterator I
ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R, bool NeedsADL, bool AcceptInvalidDecl=false)
bool ExprNeedsCleanups
ExprNeedsCleanups - True if the current evaluation context requires cleanups to be run at its conclus...
Integral promotions (C++ 4.5)
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)
bool IsStringLiteralToNonConstPointerConversion(Expr *From, QualType ToType)
Helper function to determine whether this is the (deprecated) C++ conversion from a string literal to...
This object can be modified without requiring retains or releases.
bool isUnevaluatedContext() const
Determines whether we are currently in a context that is not evaluated as per C++ [expr] p5...
bool isDefined(const FunctionDecl *&Definition) const
isDefined - Returns true if the function is defined at all, including a deleted definition.
SourceLocation TemplateKWLoc
TemplateKWLoc - The location of the template keyword within the source.
Represents the this expression in C++.
bool isAbstract() const
Determine whether this class has a pure virtual function.
New-expression has no initializer as written.
unsigned getPreferredTypeAlign(const Type *T) const
Return the "preferred" alignment of the specified type T for the current target, in bits...
static InitializedEntity InitializeNew(SourceLocation NewLoc, QualType Type)
Create the initialization entity for an object allocated via new.
TypeTrait
Names for traits that operate specifically on types.
SourceLocation LAngleLoc
The location of the '<' before the template argument list.
EnumDecl * getDecl() const
RAII class used to determine whether SFINAE has trapped any errors that occur during template argumen...
QualType getValueType() const
Gets the type contained by this atomic type, i.e.
ConditionalOperator - The ?: ternary operator.
ExtInfo getExtInfo() const
Sema - This implements semantic analysis and AST building for C.
Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
CompoundStmt - This represents a group of statements like { stmt stmt }.
TST getTypeSpecType() const
const DeclarationNameInfo & getLookupNameInfo() const
Gets the name info to look up.
QualType getParamType(unsigned i) const
Represents a prototype with parameter type info, e.g.
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
bool hasIrrelevantDestructor() const
Determine whether this class has a destructor which has no semantic effect.
static NamedDecl * getDeclFromExpr(Expr *E)
Transparent Union Conversions.
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
Retains information about a captured region.
bool isStdInitializerList(QualType Ty, QualType *Element)
Tests whether Ty is an instance of std::initializer_list and, if it is and Element is not NULL...
CastKind
CastKind - The kind of operation required for a conversion.
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat)
DeclarationNameTable DeclarationNames
QualType getLogicalOperationType() const
The result type of logical operations, '<', '>', '!=', etc.
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...
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on a template...
SourceLocation PotentialThisCaptureLocation
CK_FunctionToPointerDecay - Function to pointer decay.
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
Converts between different floating point complex types.
ExprResult BuildTypeTrait(TypeTrait Kind, SourceLocation KWLoc, ArrayRef< TypeSourceInfo * > Args, SourceLocation RParenLoc)
bool isRealFloatingType() const
Floating point categories.
An Objective-C property is a logical field of an Objective-C object which is read and written via Obj...
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
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?
unsigned param_size() const
bool isUndeducedType() const
Determine whether this type is an undeduced type, meaning that it somehow involves a C++11 'auto' typ...
Expr - This represents one expression.
bool isOrdinaryOrBitFieldObject() const
Converts an integral complex to an integral real of the source's element type by discarding the imagi...
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
static ExprResult BuildCXXCastArgument(Sema &S, SourceLocation CastLoc, QualType Ty, CastKind Kind, CXXMethodDecl *Method, DeclAccessPair FoundDecl, bool HadMultipleCandidates, Expr *From)
CXXRecordDecl * getNamingClass() const
Returns the 'naming class' for this lookup, i.e.
static unsigned getMaxSizeBits(ASTContext &Context)
Determine the maximum number of active bits that an array's size can require, which limits the maximu...
CK_BitCast - A conversion which causes a bit pattern of one type to be reinterpreted as a bit pattern...
bool isDeclScope(Decl *D)
isDeclScope - Return true if this is the scope that the specified decl is declared in...
ExprResult BuildCXXTypeConstructExpr(TypeSourceInfo *Type, SourceLocation LParenLoc, MultiExprArg Exprs, SourceLocation RParenLoc)
ActOnCXXTypeConstructExpr - Parse construction of a specified type.
static bool EvaluateUnaryTypeTrait(Sema &Self, TypeTrait UTT, SourceLocation KeyLoc, QualType T)
NestedNameSpecifier * getCorrectionSpecifier() const
Gets the NestedNameSpecifier needed to use the typo correction.
static SourceLocation findLocationAfterToken(SourceLocation loc, tok::TokenKind TKind, const SourceManager &SM, const LangOptions &LangOpts, bool SkipTrailingWhitespaceAndNewLine)
Checks that the given token is the first token that occurs after the given location (this excludes co...
StandardConversionSequence After
After - Represents the standard conversion that occurs after the actual user-defined conversion...
This file defines the classes used to store parsed information about declaration-specifiers and decla...
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
Represents a C++ destructor within a class.
New-expression has a C++11 list-initializer.
ExprResult ActOnPseudoDestructorExpr(Scope *S, Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind, CXXScopeSpec &SS, UnqualifiedId &FirstTypeName, SourceLocation CCLoc, SourceLocation TildeLoc, UnqualifiedId &SecondTypeName)
TranslationUnitDecl * getTranslationUnitDecl() const
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup.
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 ...
const ParmVarDecl * getParamDecl(unsigned i) const
CXXConstructorDecl * CopyConstructor
CopyConstructor - The copy constructor that is used to perform this conversion, when the conversion i...
ObjCDictionaryLiteral - AST node to represent objective-c dictionary literals; as in:"name" : NSUserN...
Overload resolution succeeded.
bool isFloatingType() const
ExprResult CheckPlaceholderExpr(Expr *E)
Check for operands with placeholder types and complain if found.
Classification Classify(ASTContext &Ctx) const
Classify - Classify this expression according to the C++11 expression taxonomy.
Represents a C++ template name within the type system.
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
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.
A namespace alias, stored as a NamespaceAliasDecl*.
Floating-integral conversions (C++ 4.9)
void DiscardCleanupsInEvaluationContext()
Specifies that a value-dependent expression of integral or dependent type should be considered a null...
static bool EvaluateBinaryTypeTrait(Sema &Self, TypeTrait BTT, QualType LhsT, QualType RhsT, SourceLocation KeyLoc)
ExprResult ActOnTypeTrait(TypeTrait Kind, SourceLocation KWLoc, ArrayRef< ParsedType > Args, SourceLocation RParenLoc)
Parsed one of the type trait support pseudo-functions.
void NoteCandidates(Sema &S, OverloadCandidateDisplayKind OCD, ArrayRef< Expr * > Args, StringRef Opc="", SourceLocation Loc=SourceLocation())
PrintOverloadCandidates - When overload resolution fails, prints diagnostic messages containing the c...
ExprResult BuildCXXUuidof(QualType TypeInfoType, SourceLocation TypeidLoc, TypeSourceInfo *Operand, SourceLocation RParenLoc)
Build a Microsoft __uuidof expression with a type operand.
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...
SourceLocation Loc
Loc - The place where this type was defined.
StandardConversionSequence Standard
When ConversionKind == StandardConversion, provides the details of the standard conversion sequence...
CK_ConstructorConversion - Conversion by constructor.
QualType getObjCIdType() const
Represents the Objective-CC id type.
void AddTemplateOverloadCandidate(FunctionTemplateDecl *FunctionTemplate, DeclAccessPair FoundDecl, TemplateArgumentListInfo *ExplicitTemplateArgs, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false)
Add a C++ function template specialization as a candidate in the candidate set, using template argume...
An expression that sends a message to the given Objective-C object or class.
Converts from an integral complex to a floating complex.
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
static uint64_t EvaluateArrayTypeTrait(Sema &Self, ArrayTypeTrait ATT, QualType T, Expr *DimExpr, SourceLocation KeyLoc)
SmallVector< ActiveTemplateInstantiation, 16 > ActiveTemplateInstantiations
List of active template instantiations.
ExprResult BuildPossibleImplicitMemberExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, const TemplateArgumentListInfo *TemplateArgs, const Scope *S)
Builds an expression which might be an implicit member expression.
ParsedType getInheritingConstructorName(CXXScopeSpec &SS, SourceLocation NameLoc, IdentifierInfo &Name)
Handle the result of the special case name lookup for inheriting constructor declarations.
CXXRecordDecl * getStdBadAlloc() const
void CleanupVarDeclMarking()
class LLVM_ALIGNAS(8) TemplateSpecializationType unsigned NumArgs
Represents a type template specialization; the template must be a class template, a type alias templa...
ExprResult ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal, bool ArrayForm, Expr *Operand)
ActOnCXXDelete - Parsed a C++ 'delete' expression.
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
bool isStrictSupersetOf(Qualifiers Other) const
Determine whether this set of qualifiers is a strict superset of another set of qualifiers, not considering qualifier compatibility.
Represents a C++ conversion function within a class.
QualType getCVRQualifiedType(QualType T, unsigned CVR) const
Return a type with additional const, volatile, or restrict qualifiers.
The result type of a method or function.
A type, stored as a Type*.
const LookupResult & getLookupResult() const
bool hasNonTrivialCopyAssignment() const
Determine whether this class has a non-trivial copy assignment operator (C++ [class.copy]p11, C++11 [class.copy]p25)
unsigned getEditDistance(bool Normalized=true) const
Gets the "edit distance" of the typo correction from the typo.
const Expr * getAnyInitializer() const
getAnyInitializer - Get the initializer for this variable, no matter which declaration it is attached...
const TypoExprState & getTypoExprState(TypoExpr *TE) const
CK_ArrayToPointerDecay - Array to pointer decay.
CXXDestructorDecl * LookupDestructor(CXXRecordDecl *Class)
Look for the destructor of the given class.
bool isObjectType() const
Determine whether this type is an object type.
static InitializationKind CreateCopy(SourceLocation InitLoc, SourceLocation EqualLoc, bool AllowExplicitConvs=false)
Create a copy initialization.
ExprResult ActOnFinishFullExpr(Expr *Expr)
static CXXRecordDecl * Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, CXXRecordDecl *PrevDecl=nullptr, bool DelayTypeCreation=false)
ExprResult BuildPseudoDestructorExpr(Expr *Base, SourceLocation OpLoc, tok::TokenKind OpKind, const CXXScopeSpec &SS, TypeSourceInfo *ScopeType, SourceLocation CCLoc, SourceLocation TildeLoc, PseudoDestructorTypeStorage DestroyedType)
QualType FindCompositePointerType(SourceLocation Loc, Expr *&E1, Expr *&E2, bool *NonStandardCompositeType=nullptr)
Find a merged pointer type and convert the two expressions to it.
ExprResult BuildCXXNoexceptExpr(SourceLocation KeyLoc, Expr *Operand, SourceLocation RParen)
Lvalue-to-rvalue conversion (C++ 4.1)
ExprResult ActOnParenExpr(SourceLocation L, SourceLocation R, Expr *E)
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
bool isNothrow(const ASTContext &Ctx, bool ResultIfDependent=false) const
Determine whether this function type has a non-throwing exception specification.
CanThrowResult
Possible results from evaluation of a noexcept expression.
ParsedType getDestructorType(const DeclSpec &DS, ParsedType ObjectType)
There is no lifetime qualification on this type.
ExprResult ActOnDecltypeExpression(Expr *E)
Process the expression contained within a decltype.
DeclContext * getEntity() const
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...
Integral conversions (C++ 4.7)
Complex promotions (Clang extension)
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...
static CXXBindTemporaryExpr * Create(const ASTContext &C, CXXTemporary *Temp, Expr *SubExpr)
ImplicitConversionSequence - Represents an implicit conversion sequence, which may be a standard conv...
ExprResult BuildCXXThrow(SourceLocation OpLoc, Expr *Ex, bool IsThrownVarInScope)
bool FindAllocationOverload(SourceLocation StartLoc, SourceRange Range, DeclarationName Name, MultiExprArg Args, DeclContext *Ctx, bool AllowMissing, FunctionDecl *&Operator, bool Diagnose=true)
Find an fitting overload for the allocation function in the specified scope.
ExceptionSpecificationType Type
The kind of exception specification this is.
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...
CK_UserDefinedConversion - Conversion using a user defined type conversion function.
enum clang::DeclaratorChunk::@183 Kind
Encodes a location in the source.
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
unsigned getNumParams() const
getNumParams - Return the number of parameters this function must have based on its FunctionType...
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.
CastKind PrepareCastToObjCObjectPointer(ExprResult &E)
Prepare a conversion of the given expression to an ObjC object pointer type.
QualType getElementType() const
QualType withCVRQualifiers(unsigned CVR) const
Represents a C++ temporary.
Expr * getRepAsExpr() const
bool isValid() const
Return true if this is a valid SourceLocation object.
OverloadedOperatorKind getCXXOverloadedOperator() const
getCXXOverloadedOperator - If this name is the name of an overloadable operator in C++ (e...
Represents a new-expression for memory allocation and constructor calls, e.g: "new CXXNewExpr(foo)"...
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
Represents a call to a member function that may be written either with member call syntax (e...
CK_NullToMemberPointer - Null pointer constant to member pointer.
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location, which defaults to the empty location.
static const UuidAttr * GetUuidAttrOfType(QualType QT, bool *HasMultipleGUIDsPtr=nullptr)
Grabs __declspec(uuid()) off a type, or returns 0 if we cannot resolve to a single GUID...
IdentifierTable & getIdentifierTable()
A vector splat from an arithmetic type.
Optional< unsigned > getStackIndexOfNearestEnclosingCaptureCapableLambda(ArrayRef< const sema::FunctionScopeInfo * > FunctionScopes, VarDecl *VarToCapture, Sema &S)
Examines the FunctionScopeInfo stack to determine the nearest enclosing lambda (to the current lambda...
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.
static ExprWithCleanups * Create(const ASTContext &C, EmptyShell empty, unsigned numObjects)
CK_DerivedToBase - A conversion from a C++ class pointer to a base class pointer. ...
ExprResult DefaultLvalueConversion(Expr *E)
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
No ref-qualifier was provided.
void setDestructor(const CXXDestructorDecl *Dtor)
Objective-C ARC writeback conversion.
bool CheckObjCARCUnavailableWeakConversion(QualType castType, QualType ExprType)
bool isInvalid() const
An error occurred during parsing of the scope specifier.
const ConstantArrayType * getAsConstantArrayType(QualType T) const
Name lookup found an unresolvable value declaration and cannot yet complete.
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...
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...
TemplateDeductionResult DeduceTemplateArguments(ClassTemplatePartialSpecializationDecl *Partial, const TemplateArgumentList &TemplateArgs, sema::TemplateDeductionInfo &Info)
Perform template argument deduction to determine whether the given template arguments match the given...
Look up any declaration with any name.
AssignConvertType CheckTransparentUnionArgumentConstraints(QualType ArgType, ExprResult &RHS)
bool CheckMemberPointerConversion(Expr *From, QualType ToType, CastKind &Kind, CXXCastPath &BasePath, bool IgnoreBaseAccess)
CheckMemberPointerConversion - Check the member pointer conversion from the expression From to the ty...
const Type * getBaseElementTypeUnsafe() const
Get the base element type of this type, potentially discarding type qualifiers.
A class for iterating through a result set and possibly filtering out results.
Pointer conversions (C++ 4.10)
Converts from an integral real to an integral complex whose element type matches the source...
Lookup for candidates for a call using operator syntax.
static Expr * captureThis(ASTContext &Context, RecordDecl *RD, QualType ThisTy, SourceLocation Loc)
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
static bool VariableCanNeverBeAConstantExpression(VarDecl *Var, ASTContext &Context)
SourceLocation getBegin() const
Requests that all candidates be shown.
const T * castAs() const
Member-template castAs<specific type>.
bool isTypeDependent() const
isTypeDependent - Determines whether this expression is type-dependent (C++ [temp.dep.expr]), which means that its type could change from one template instantiation to the next.
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
No entity found met the criteria.
bool isFileContext() const
bool isVectorType() const
bool isThisOutsideMemberFunctionBody(QualType BaseType)
Determine whether the given type is the type of *this that is used outside of the body of a member fu...
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
The name is a dependent name, so the results will differ from one instantiation to the next...
An expression trait intrinsic.
bool isMemberFunctionPointerType() const
Derived-to-base (C++ [over.best.ics])
Complex-real conversions (C99 6.3.1.7)
An rvalue ref-qualifier was provided (&&).
Assigning into this object requires a lifetime extension.
StmtExpr - This is the GNU Statement Expression extension: ({int X=4; X;}).
ObjCBoxedExpr - used for generalized expression boxing.
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
OverloadCandidateSet - A set of overload candidates, used in C++ overload resolution (C++ 13...
Constant expression in a noptr-new-declarator.
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
ExprResult ActOnCXXNew(SourceLocation StartLoc, bool UseGlobal, SourceLocation PlacementLParen, MultiExprArg PlacementArgs, SourceLocation PlacementRParen, SourceRange TypeIdParens, Declarator &D, Expr *Initializer)
ActOnCXXNew - Parsed a C++ 'new' expression.
MutableArrayRef< Expr * > MultiExprArg
QualType getType() const
Return the type wrapped by this type source info.
static bool CheckUnaryTypeTraitTypeCompleteness(Sema &S, TypeTrait UTT, SourceLocation Loc, QualType ArgTy)
Check the completeness of a type in a unary type trait.
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
bool hasTrivialCopyAssignment() const
Determine whether this class has a trivial copy assignment operator (C++ [class.copy]p11, C++11 [class.copy]p25)
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
QualType getDependentNameType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, QualType Canon=QualType()) const
bool containsPlaceholderType() const
A POD class for pairing a NamedDecl* with an access specifier.
AccessResult CheckAllocationAccess(SourceLocation OperatorLoc, SourceRange PlacementRange, CXXRecordDecl *NamingClass, DeclAccessPair FoundDecl, bool Diagnose=true)
Checks access to an overloaded operator new or delete.
ExprResult BuildOverloadedArrowExpr(Scope *S, Expr *Base, SourceLocation OpLoc, bool *NoArrowOperatorFound=nullptr)
BuildOverloadedArrowExpr - Build a call to an overloaded operator-> (if one exists), where Base is an expression of class type and Member is the name of the member we're trying to find.
ExprResult BuildCXXMemberCallExpr(Expr *Exp, NamedDecl *FoundDecl, CXXConversionDecl *Method, bool HadMultipleCandidates)
The scope of a struct/union/class definition.
QualType getCallReturnType(const ASTContext &Ctx) const
getCallReturnType - Get the return type of the call expr.
SourceRange getSourceRange() const LLVM_READONLY
Get the source range that spans this declarator.
void MarkMemberReferenced(MemberExpr *E)
Perform reference-marking and odr-use handling for a MemberExpr.
sema::LambdaScopeInfo * getCurLambda()
Retrieve the current lambda scope info, if any.
Converts a floating point complex to floating point real of the source's element type.
ExprResult PerformCopyInitialization(const InitializedEntity &Entity, SourceLocation EqualLoc, ExprResult Init, bool TopLevelOfInitList=false, bool AllowExplicit=false)
void DiagnoseAmbiguousConversion(Sema &S, SourceLocation CaretLoc, const PartialDiagnostic &PDiag) const
Diagnoses an ambiguous conversion.
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 collectUnexpandedParameterPacks(TemplateArgument Arg, SmallVectorImpl< UnexpandedParameterPack > &Unexpanded)
Collect the set of unexpanded parameter packs within the given template argument. ...
DeclContextLookupResult LookupConstructors(CXXRecordDecl *Class)
Look up the constructors for the given class.
This file provides some common utility functions for processing Lambdas.
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
static const Type * getElementType(const Expr *BaseExpr)
Abstract base class used to perform a contextual implicit conversion from an expression to any type p...
static ExprResult attemptRecovery(Sema &SemaRef, const TypoCorrectionConsumer &Consumer, TypoCorrection TC)
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
ExprResult BuildExpressionTrait(ExpressionTrait OET, SourceLocation KWLoc, Expr *Queried, SourceLocation RParen)
Represents a delete expression for memory deallocation and destructor calls, e.g. ...
static bool isLegalArrayNewInitializer(CXXNewExpr::InitializationStyle Style, Expr *Init)
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.
static const TST TST_decltype
OverloadedOperatorKind
Enumeration specifying the different kinds of C++ overloaded operators.
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return 0.
CXXDestructorDecl * getDestructor() const
Returns the destructor decl for this class.
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.
void addCopyConstructorForExceptionObject(CXXRecordDecl *RD, CXXConstructorDecl *CD)
CXXScopeSpec SS
The nested-name-specifier that precedes the template name.
SourceLocation RAngleLoc
The location of the '>' after the template argument list.
bool isInvalidDecl() const
bool getProducesResult() const
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
IdentifierInfo * getAsIdentifier() const
Retrieve the identifier stored in this nested name specifier.
Conversions allowed in C, but not C++.
Array-to-pointer conversion (C++ 4.2)
bool isStandardLayoutType() const
Test if this type is a standard-layout type.
QualType getExceptionObjectType(QualType T) const
bool GlobalNewDeleteDeclared
A flag to remember whether the implicit forms of operator new and delete have been declared...
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
bool hasTrivialDefaultConstructor() const
Determine whether this class has a trivial default constructor (C++11 [class.ctor]p5).
DeclarationName - The name of a declaration.
StandardConversionSequence Before
Represents the standard conversion that occurs before the actual user-defined conversion.
bool isLValue() const
isLValue - True if this expression is an "l-value" according to the rules of the current language...
ExprResult prepareVectorSplat(QualType VectorTy, Expr *SplattedExpr)
Prepare SplattedExpr for a vector splat operation, adding implicit casts if necessary.
bool isThisDeclarationADefinition() const
isThisDeclarationADefinition - Returns whether this specific declaration of the function is also a de...
SourceLocation getLocStart() const LLVM_READONLY
bool hasTrivialMoveConstructor() const
Determine whether this class has a trivial move constructor (C++11 [class.copy]p12) ...
Requests that only viable candidates be shown.
CK_BlockPointerToObjCPointerCast - Casting a block pointer to an ObjC pointer.
detail::InMemoryDirectory::const_iterator E
A pointer to member type per C++ 8.3.3 - Pointers to members.
ExprResult BuildCXXFunctionalCastExpr(TypeSourceInfo *TInfo, SourceLocation LParenLoc, Expr *CastExpr, SourceLocation RParenLoc)
IdentifierResolver IdResolver
bool isSingleResult() const
Determines if this names a single result which is not an unresolved value using decl.
A conversion of a floating point real to a floating point complex of the original type...
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
static CastKind ScalarTypeToBooleanCastKind(QualType ScalarTy)
ScalarTypeToBooleanCastKind - Returns the cast kind corresponding to the conversion from scalar type ...
CXXThisScopeRAII(Sema &S, Decl *ContextDecl, unsigned CXXThisTypeQuals, bool Enabled=true)
Introduce a new scope where 'this' may be allowed (when enabled), using the given declaration (which ...
bool isLValueReferenceType() const
FieldDecl * getMember() const
If this is a member initializer, returns the declaration of the non-static data member being initiali...
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
A type that was preceded by the 'template' keyword, stored as a Type*.
bool isLambda() const
Determine whether this class describes a lambda function object.
[ARC] Reclaim a retainable object pointer object that may have been produced and autoreleased as part...
Expr * IgnoreParenImpCasts() LLVM_READONLY
IgnoreParenImpCasts - Ignore parentheses and implicit casts.
bool isRValueReferenceType() const
llvm::MapVector< FieldDecl *, DeleteLocs > DeleteExprs
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
FunctionDecl * ConversionFunction
ConversionFunction - The function that will perform the user-defined conversion.
ExprResult IgnoredValueConversions(Expr *E)
IgnoredValueConversions - Given that an expression's result is syntactically ignored, perform any conversions that are required.
Represents a C++11 noexcept expression (C++ [expr.unary.noexcept]).
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
Name lookup found a single declaration that met the criteria.
bool empty() const
Return true if no decls were found.
static void DiagnoseMismatchedNewDelete(Sema &SemaRef, SourceLocation DeleteLoc, const MismatchingNewDeleteDetector &Detector)
StmtResult ActOnFinishFullStmt(Stmt *Stmt)
void setHadMultipleCandidates(bool V=true)
Sets the flag telling whether this expression refers to a method that was resolved from an overloaded...
ExprResult CheckCXXBooleanCondition(Expr *CondExpr)
CheckCXXBooleanCondition - Returns true if conversion to bool is invalid.
bool hasTrivialMoveAssignment() const
Determine whether this class has a trivial move assignment operator (C++11 [class.copy]p25)
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.
bool isTriviallyCopyableType(ASTContext &Context) const
Return true if this is a trivially copyable type (C++0x [basic.types]p9)
SourceManager & getSourceManager() const
The lookup is a reference to this name that is not for the purpose of redeclaring the name...
const T * getAs() const
Member-template getAs<specific type>'.
Represents a C++ base or member initializer.
void addThisCapture(bool isNested, SourceLocation Loc, QualType CaptureType, Expr *Cpy)
ExprResult ActOnCXXBoolLiteral(SourceLocation OpLoc, tok::TokenKind Kind)
ActOnCXXBoolLiteral - Parse {true,false} literals.
bool CheckDerivedToBaseConversion(QualType Derived, QualType Base, SourceLocation Loc, SourceRange Range, CXXCastPath *BasePath=nullptr, bool IgnoreAccess=false)
QualType CheckPointerToMemberOperands(ExprResult &LHS, ExprResult &RHS, ExprValueKind &VK, SourceLocation OpLoc, bool isIndirect)
ExprResult ActOnCXXTypeConstructExpr(ParsedType TypeRep, SourceLocation LParenLoc, MultiExprArg Exprs, SourceLocation RParenLoc)
ActOnCXXTypeConstructExpr - Parse construction of a specified type.
NamedDecl * getFoundDecl() const
Get the correction declaration found by name lookup (before we looked through using shadow declaratio...
SourceLocation getLocStart() const LLVM_READONLY
bool isFunctionType() const
QualType BuildDecltypeType(Expr *E, SourceLocation Loc, bool AsUnevaluated=true)
If AsUnevaluated is false, E is treated as though it were an evaluated context, such as when building...
Converts from T to _Atomic(T).
CanQualType BoundMemberTy
SmallVector< ExpressionEvaluationContextRecord, 8 > ExprEvalContexts
A stack of expression evaluation contexts.
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
AccessResult CheckMemberOperatorAccess(SourceLocation Loc, Expr *ObjectExpr, Expr *ArgExpr, DeclAccessPair FoundDecl)
Checks access to an overloaded member operator, including conversion operators.
bool isTrivial() const
Whether this function is "trivial" in some specialized C++ senses.
Converts from a floating complex to an integral complex.
uint64_t getCharWidth() const
Return the size of the character type, in bits.
ExprResult ActOnCXXTypeid(SourceLocation OpLoc, SourceLocation LParenLoc, bool isType, void *TyOrExpr, SourceLocation RParenLoc)
ActOnCXXTypeid - Parse typeid( something ).
Block Pointer conversions.
static bool isInvalid(SourceLocation Loc, bool *Invalid)
static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)
Create a code modification hint that inserts the given code string at a specific location.
void addDecl(Decl *D)
Add the declaration D into this context.
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.
A template-id, e.g., f<int>.
QualType getTagDeclType(const TagDecl *Decl) const
Return the unique reference to the type for the specified TagDecl (struct/union/class/enum) decl...
SmallVector< BlockDecl *, 8 > ExprCleanupObjects
ExprCleanupObjects - This is the stack of objects requiring cleanup that are created by the current f...
ExprResult BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType, CXXConstructorDecl *Constructor, MultiExprArg Exprs, bool HadMultipleCandidates, bool IsListInitialization, bool IsStdInitListInitialization, bool RequiresZeroInit, unsigned ConstructKind, SourceRange ParenRange)
BuildCXXConstructExpr - Creates a complete call to a constructor, including handling of its default a...
Represents a base class of a C++ class.
A bitfield object is a bitfield on a C or C++ record.
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
void DiagnoseSentinelCalls(NamedDecl *D, SourceLocation Loc, ArrayRef< Expr * > Args)
DiagnoseSentinelCalls - This routine checks whether a call or message-send is to a declaration with t...
ArrayRef< QualType > Exceptions
Explicitly-specified list of exception types.
uint64_t getPointerWidth(unsigned AddrSpace) const
Return the width of pointers on this target, for the specified address space.
bool isDefaultConstructor() const
Whether this constructor is a default constructor (C++ [class.ctor]p5), which can be used to default-...
static bool TryClassUnification(Sema &Self, Expr *From, Expr *To, SourceLocation QuestionLoc, bool &HaveConversion, QualType &ToType)
Try to convert a type to another according to C++0x 5.16p3.
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
SourceRange getCorrectionRange() const
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
const Type * getClass() const
Reading or writing from this object requires a barrier call.
bool isPODType(ASTContext &Context) const
Determine whether this is a Plain Old Data (POD) type (C++ 3.9p10).
bool hasNonTrivialMoveConstructor() const
Determine whether this class has a non-trivial move constructor (C++11 [class.copy]p12) ...
Expr * MaybeCreateExprWithCleanups(Expr *SubExpr)
MaybeCreateExprWithCleanups - If the current full-expression requires any cleanups, surround it with a ExprWithCleanups node.
bool typesAreCompatible(QualType T1, QualType T2, bool CompareUnqualified=false)
Compatibility predicates used to check assignment expressions.
Function-to-pointer (C++ 4.3)
bool Failed() const
Determine whether the initialization sequence is invalid.
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.
static bool isNonPlacementDeallocationFunction(Sema &S, FunctionDecl *FD)
Determine whether the given function is a non-placement deallocation function.
Describes the sequence of initializations required to initialize a given object or reference with a s...
Captures information about "declaration specifiers".
void AddOverloadCandidate(FunctionDecl *Function, DeclAccessPair FoundDecl, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet, bool SuppressUserConversions=false, bool PartialOverloading=false, bool AllowExplicit=false)
AddOverloadCandidate - Adds the given function to the set of candidate functions, using the given fun...
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
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.
A user-defined literal name, e.g., operator "" _i.
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...
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...
static CXXTemporary * Create(const ASTContext &C, const CXXDestructorDecl *Destructor)
Expr * NumElts
This is the size of the array, or null if [] or [*] was specified.
FunctionDecl * FindUsualDeallocationFunction(SourceLocation StartLoc, bool CanProvideSize, DeclarationName Name)
static bool HasNoThrowOperator(const RecordType *RT, OverloadedOperatorKind Op, Sema &Self, SourceLocation KeyLoc, ASTContext &C, bool(CXXRecordDecl::*HasTrivial)() const, bool(CXXRecordDecl::*HasNonTrivial)() const, bool(CXXMethodDecl::*IsDesiredOp)() const)
bool isCompoundType() const
Tests whether the type is categorized as a compound type.
static TypeTraitExpr * Create(const ASTContext &C, QualType T, SourceLocation Loc, TypeTrait Kind, ArrayRef< TypeSourceInfo * > Args, SourceLocation RParenLoc, bool Value)
Create a new type trait expression.
ExprResult CorrectDelayedTyposInExpr(Expr *E, VarDecl *InitDecl=nullptr, llvm::function_ref< ExprResult(Expr *)> Filter=[](Expr *E) -> ExprResult{return E;})
Process any TypoExprs in the given Expr and its children, generating diagnostics as appropriate and r...
bool CheckAllocatedType(QualType AllocType, SourceLocation Loc, SourceRange R)
Checks that a type is suitable as the allocated type in a new-expression.
void DeclareGlobalAllocationFunction(DeclarationName Name, QualType Return, QualType Param1, QualType Param2=QualType(), bool addRestrictAttr=false)
DeclareGlobalAllocationFunction - Declares a single implicit global allocation function if it doesn't...
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
Declaration of a class template.
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'.
LookupResultKind getResultKind() const
Converts from _Atomic(T) to T.
OverloadingResult BestViableFunction(Sema &S, SourceLocation Loc, OverloadCandidateSet::iterator &Best, bool UserDefinedConversion=false)
Find the best viable function on this overload set, if it exists.
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.
static bool hasAnyTypeDependentArguments(ArrayRef< Expr * > Exprs)
hasAnyTypeDependentArguments - Determines if any of the expressions in Exprs is type-dependent.
static Qualifiers fromCVRMask(unsigned CVR)
void EmitRelatedResultTypeNote(const Expr *E)
If the given expression involves a message send to a method with a related result type...
bool isIncompleteArrayType() const
ExprResult CheckConvertedConstantExpression(Expr *From, QualType T, llvm::APSInt &Value, CCEKind CCE)
static OpaquePtr make(QualTypeP)
CK_NoOp - A conversion which does not affect the type other than (possibly) adding qualifiers...
bool isValid() const
A scope specifier is present, and it refers to a real scope.
A reference to a declared variable, function, enum, etc.
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
bool isSet() const
Deprecated.
unsigned getSuitableAlign() const
Return the alignment that is suitable for storing any object with a fundamental alignment requirement...
The current expression and its subexpressions occur within an unevaluated operand (C++11 [expr]p7)...
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type...
QualType getElementType() const
Expr * getDefaultArgExprForConstructor(const CXXConstructorDecl *CD, unsigned ParmIdx)
void MarkFunctionReferenced(SourceLocation Loc, FunctionDecl *Func, bool OdrUse=true)
Mark a function referenced, and check whether it is odr-used (C++ [basic.def.odr]p2, C99 6.9p3)
unsigned getNumPotentialVariableCaptures() const
Zero constant to event (OpenCL1.2 6.12.10)
ImplicitConversionKind First
First – The first conversion can be an lvalue-to-rvalue conversion, array-to-pointer conversion...
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
const Expr * getSubExpr() const
No viable function found.
DeduceAutoResult DeduceAutoType(TypeSourceInfo *AutoType, Expr *&Initializer, QualType &Result)
void suppressDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup.
const DeclaratorChunk & getTypeObject(unsigned i) const
Return the specified TypeInfo from this declarator.
An l-value expression is a reference to an object with independent storage.
bool isInterfaceType() const
A trivial tuple used to represent a source range.
SourceLocation getLocation() const
bool CompleteConstructorCall(CXXConstructorDecl *Constructor, MultiExprArg ArgsPtr, SourceLocation Loc, SmallVectorImpl< Expr * > &ConvertedArgs, bool AllowExplicit=false, bool IsListInitialization=false)
Given a constructor and the set of arguments provided for the constructor, convert the arguments and ...
void diagnoseNullableToNonnullConversion(QualType DstType, QualType SrcType, SourceLocation Loc)
Warn if we're implicitly casting from a _Nullable pointer type to a _Nonnull one. ...
NamedDecl - This represents a decl with a name.
bool isInvalidType() const
A boolean literal, per ([C++ lex.bool] Boolean literals).
void setAccess(AccessSpecifier AS)
bool isVariableExprMarkedAsNonODRUsed(Expr *CapturingVarExpr) const
bool CheckCallReturnType(QualType ReturnType, SourceLocation Loc, CallExpr *CE, FunctionDecl *FD)
CheckCallReturnType - Checks that a call expression's return type is complete.
bool isArithmeticType() const
ARCConversionResult CheckObjCARCConversion(SourceRange castRange, QualType castType, Expr *&op, CheckedConversionKind CCK, bool Diagnose=true, bool DiagnoseCFAudited=false, BinaryOperatorKind Opc=BO_PtrMemD)
Checks for invalid conversions and casts between retainable pointers and other pointer kinds...
bool CheckCXXThisCapture(SourceLocation Loc, bool Explicit=false, bool BuildAndDiagnose=true, const unsigned *const FunctionScopeIndexToStopAt=nullptr)
Make sure the value of 'this' is actually available in the current context, if it is a potentially ev...
A Microsoft C++ __uuidof expression, which gets the _GUID that corresponds to the supplied type or ex...
No keyword precedes the qualified type name.
bool isSignedIntegerType() const
Return true if this is an integer type that is signed, according to C99 6.2.5p4 [char, signed char, short, int, long..], or an enum decl which has a signed representation.
ExprResult BuildBinOp(Scope *S, SourceLocation OpLoc, BinaryOperatorKind Opc, Expr *LHSExpr, Expr *RHSExpr)
bool isConstQualified() const
Determine whether this type is const-qualified.
Pointer-to-member conversions (C++ 4.11)
bool isNull() const
Return true if this QualType doesn't point to a type yet.
bool isPolymorphic() const
Whether this class is polymorphic (C++ [class.virtual]), which means that the class contains or inher...
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.
SourceLocation getLocEnd() const LLVM_READONLY
The global specifier '::'. There is no stored value.
CK_ToVoid - Cast to void, discarding the computed value.
static OpaquePtr getFromOpaquePtr(void *P)
ExprResult BuildCXXTypeId(QualType TypeInfoType, SourceLocation TypeidLoc, TypeSourceInfo *Operand, SourceLocation RParenLoc)
Build a C++ typeid expression with a type operand.
void WillReplaceSpecifier(bool ForceReplacement)
bool isBeingDefined() const
isBeingDefined - Return true if this decl is currently being defined.
bool isIntegralType(ASTContext &Ctx) const
Determine whether this type is an integral type.
Represents the canonical version of C arrays with a specified constant size.
This scope corresponds to an Objective-C method body.
ExceptionSpecInfo ExceptionSpec
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
The symbol does not exist.
Declaration of a template function.
void clear()
Clears out any current state.
bool FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range, bool UseGlobal, QualType AllocType, bool IsArray, MultiExprArg PlaceArgs, FunctionDecl *&OperatorNew, FunctionDecl *&OperatorDelete)
FindAllocationFunctions - Finds the overloads of operator new and delete that are appropriate for the...
QualType getUnqualifiedArrayType(QualType T, Qualifiers &Quals)
Return this type as a completely-unqualified array type, capturing the qualifiers in Quals...
QualType UsualArithmeticConversions(ExprResult &LHS, ExprResult &RHS, bool IsCompAssign=false)
UsualArithmeticConversions - Performs various conversions that are common to binary operators (C99 6...
TypeSourceInfo * GetTypeForDeclarator(Declarator &D, Scope *S)
GetTypeForDeclarator - Convert the type for the specified declarator to Type instances.
bool isIntegerType() const
isIntegerType() does not include complex integers (a GCC extension).
ParsedTemplateTy Template
The declaration of the template corresponding to the template-name.
const RecordDecl * getParent() const
getParent - Returns the parent of this field declaration, which is the struct in which this method is...
Helper class that creates diagnostics with optional template instantiation stacks.
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
Expr * IgnoreParens() LLVM_READONLY
IgnoreParens - Ignore parentheses.
DeclAccessPair getFoundDecl() const
Retrieves the declaration found by lookup.
bool hasInClassInitializer() const
hasInClassInitializer - Determine whether this member has a C++11 in-class initializer.
bool isPointerType() const
Structure used to store a statement, the constant value to which it was evaluated (if any)...
OverloadedOperatorKind getOverloadedOperator() const
getOverloadedOperator - Which C++ overloaded operator this function represents, if any...
StandardConversionSequence - represents a standard conversion sequence (C++ 13.3.3.1.1).