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) {
819 for (
unsigned I = 1, E = CD->
getNumParams(); I != E; ++I) {
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];
1036 if (!ListInitialization)
1038 diag::err_value_init_for_array_type) << FullRange);
1044 diag::err_invalid_incomplete_type_use, FullRange))
1048 diag::err_allocation_of_abstract_type))
1053 Exprs.size() ? ListInitialization
1060 if (Result.
isInvalid() || !ListInitialization)
1065 Inner = BTE->getSubExpr();
1066 if (!isa<CXXTemporaryObjectExpr>(Inner)) {
1078 CK_NoOp, Result.
get(),
nullptr, LParenLoc, RParenLoc);
1090 if (!record)
return false;
1103 if (ops.
empty())
return false;
1116 if (isa<FunctionTemplateDecl>(del)) {
1127 if (!cast<CXXMethodDecl>(del)->isUsualDeallocationFunction()) {
1163 Expr *ArraySize =
nullptr;
1168 if (TypeContainsAuto)
1190 if (!NumElts->isTypeDependent() && !NumElts->isValueDependent()) {
1196 assert(IntWidth &&
"Builtin type of size 0?");
1197 llvm::APSInt
Value(IntWidth);
1205 diag::err_new_array_nonconst)
1221 if (
ParenListExpr *List = dyn_cast_or_null<ParenListExpr>(Initializer))
1222 DirectInitRange = List->getSourceRange();
1242 return PLE->getNumExprs() == 0;
1243 if (isa<ImplicitValueInitExpr>(Init))
1246 return !CCE->isListInitialization() &&
1247 CCE->getConstructor()->isDefaultConstructor();
1249 assert(isa<InitListExpr>(Init) &&
1250 "Shouldn't create list CXXConstructExprs for arrays.");
1267 bool TypeMayContainAuto) {
1272 if (DirectInitRange.
isValid()) {
1273 assert(Initializer &&
"Have parens but no initializer.");
1275 }
else if (Initializer && isa<InitListExpr>(Initializer))
1278 assert((!Initializer || isa<ImplicitValueInitExpr>(Initializer) ||
1279 isa<CXXConstructExpr>(Initializer)) &&
1280 "Initializer expression that cannot have been implicitly created.");
1285 unsigned NumInits = Initializer ? 1 : 0;
1286 if (
ParenListExpr *List = dyn_cast_or_null<ParenListExpr>(Initializer)) {
1288 Inits = List->getExprs();
1289 NumInits = List->getNumExprs();
1295 return ExprError(
Diag(StartLoc, diag::err_auto_new_requires_ctor_arg)
1296 << AllocType << TypeRange);
1298 (NumInits == 1 && isa<InitListExpr>(Inits[0])))
1300 diag::err_auto_new_list_init)
1301 << AllocType << TypeRange);
1303 Expr *FirstBad = Inits[1];
1305 diag::err_auto_new_ctor_multiple_expressions)
1306 << AllocType << TypeRange);
1308 Expr *Deduce = Inits[0];
1311 return ExprError(
Diag(StartLoc, diag::err_auto_new_deduction_failure)
1312 << AllocType << Deduce->
getType()
1313 << TypeRange << Deduce->getSourceRange());
1314 if (DeducedType.
isNull())
1316 AllocType = DeducedType;
1327 AllocType = Array->getElementType();
1337 diag::warn_dangling_std_initializer_list)
1338 << 0 << Inits[0]->getSourceRange();
1354 ArraySize = result.
get();
1371 if (!ConvertedSize.isInvalid() &&
1374 Diag(StartLoc, diag::warn_cxx98_compat_array_size_conversion)
1375 << ArraySize->
getType() << 0 <<
"'size_t'";
1382 SizeConvertDiagnoser(
Expr *ArraySize)
1384 ArraySize(ArraySize) {}
1388 return S.
Diag(Loc, diag::err_array_size_not_integral)
1394 return S.
Diag(Loc, diag::err_array_size_incomplete_type)
1395 << T << ArraySize->getSourceRange();
1400 return S.
Diag(Loc, diag::err_array_size_explicit_conversion) << T << ConvTy;
1411 return S.
Diag(Loc, diag::err_array_size_ambiguous_conversion) << T;
1425 ? diag::warn_cxx98_compat_array_size_conversion
1426 : diag::ext_array_size_conversion)
1429 } SizeDiagnoser(ArraySize);
1437 ArraySize = ConvertedSize.
get();
1458 if (Value < llvm::APSInt(
1459 llvm::APInt::getNullValue(Value.getBitWidth()),
1460 Value.isUnsigned())) {
1462 Diag(ArraySize->getLocStart(),
1463 diag::warn_typecheck_negative_array_new_size)
1464 << ArraySize->getSourceRange();
1467 diag::err_typecheck_negative_array_size)
1468 << ArraySize->getSourceRange());
1470 unsigned ActiveSizeBits =
1474 Diag(ArraySize->getLocStart(),
1475 diag::warn_array_new_too_large)
1476 << Value.toString(10)
1477 << ArraySize->getSourceRange();
1480 diag::err_array_too_large)
1481 << Value.toString(10)
1482 << ArraySize->getSourceRange());
1485 }
else if (TypeIdParens.
isValid()) {
1487 Diag(ArraySize->getLocStart(), diag::ext_new_paren_array_nonconst)
1488 << ArraySize->getSourceRange()
1507 UseGlobal, AllocType, ArraySize, PlacementArgs,
1508 OperatorNew, OperatorDelete))
1513 bool UsualArrayDeleteWantsSize =
false;
1515 UsualArrayDeleteWantsSize
1529 PlacementArgs, AllPlaceArgs, CallType))
1532 if (!AllPlaceArgs.empty())
1533 PlacementArgs = AllPlaceArgs;
1543 if (PlacementArgs.empty() && OperatorNew &&
1548 if (Align > SuitableAlign)
1549 Diag(StartLoc, diag::warn_overaligned_type)
1563 Inits[NumInits - 1]->getLocEnd());
1564 Diag(StartLoc, diag::err_new_array_init_args) << InitRange;
1567 if (
InitListExpr *ILE = dyn_cast_or_null<InitListExpr>(Initializer)) {
1571 unsigned NumElements = ILE->getNumInits() + 1;
1582 llvm::makeArrayRef(Inits, NumInits))) {
1598 DirectInitRange.
getEnd());
1611 dyn_cast_or_null<CXXBindTemporaryExpr>(FullInit.
get()))
1612 FullInit = Binder->getSubExpr();
1614 Initializer = FullInit.
get();
1623 if (OperatorDelete) {
1636 cast<CXXRecordDecl>(BaseRecordType->getDecl()))) {
1639 PDiag(diag::err_access_dtor)
1649 UsualArrayDeleteWantsSize, PlacementArgs, TypeIdParens,
1650 ArraySize, initStyle, Initializer, ResultType, AllocTypeInfo,
1651 Range, DirectInitRange);
1661 return Diag(Loc, diag::err_bad_new_type)
1662 << AllocType << 0 << R;
1664 return Diag(Loc, diag::err_bad_new_type)
1665 << AllocType << 1 << R;
1670 diag::err_allocation_of_abstract_type))
1673 return Diag(Loc, diag::err_variably_modified_new_type)
1676 return Diag(Loc, diag::err_address_space_qualified_new)
1683 return Diag(Loc, diag::err_arc_new_array_without_ownership)
1698 return Method->isUsualDeallocationFunction();
1715 bool UseGlobal,
QualType AllocType,
1736 AllocArgs[0] = &Size;
1737 std::copy(PlaceArgs.begin(), PlaceArgs.end(), AllocArgs.begin() + 1);
1746 IsArray ? OO_Array_New : OO_New);
1748 IsArray ? OO_Array_Delete : OO_Delete);
1766 FallbackEnabled, OperatorNew,
1767 !FallbackEnabled)) {
1768 if (!FallbackEnabled)
1778 false, OperatorNew))
1786 OperatorDelete =
nullptr;
1808 if (FoundDelete.
empty()) {
1822 bool isPlacementNew = (!PlaceArgs.empty() || OperatorNew->
param_size() != 1);
1824 if (isPlacementNew) {
1844 for (
unsigned I = 1, N = Proto->
getNumParams(); I < N; ++I)
1850 ExpectedFunctionType
1855 DEnd = FoundDelete.
end();
1859 = dyn_cast<FunctionTemplateDecl>((*D)->getUnderlyingDecl())) {
1867 Fn = cast<FunctionDecl>((*D)->getUnderlyingDecl());
1870 Matches.push_back(std::make_pair(D.getPair(), Fn));
1877 DEnd = FoundDelete.
end();
1879 if (
FunctionDecl *Fn = dyn_cast<FunctionDecl>((*D)->getUnderlyingDecl()))
1881 Matches.push_back(std::make_pair(D.getPair(), Fn));
1894 if (
getLangOpts().SizedDeallocation && Matches.size() == 2) {
1895 if (Matches[0].second->getNumParams() == 1)
1896 Matches.erase(Matches.begin());
1898 Matches.erase(Matches.begin() + 1);
1899 assert(Matches[0].second->getNumParams() == 2 &&
1900 "found an unexpected usual deallocation function");
1908 if (Matches.size() == 1) {
1909 OperatorDelete = Matches[0].second;
1917 if (!PlaceArgs.empty() &&
getLangOpts().CPlusPlus11 &&
1919 Diag(StartLoc, diag::err_placement_new_non_placement_delete)
1921 PlaceArgs.back()->getLocEnd());
1958 if (AllowMissing || !Diagnose)
1960 return Diag(StartLoc, diag::err_ovl_no_viable_function_in_call)
1971 Alloc != AllocEnd; ++Alloc) {
2005 Diag(StartLoc, diag::err_ovl_no_viable_function_in_call)
2013 Diag(StartLoc, diag::err_ovl_ambiguous_call)
2021 Diag(StartLoc, diag::err_ovl_deleted_call)
2022 << Best->Function->isDeleted()
2031 llvm_unreachable(
"Unreachable, bad result from BestViableFunction");
2107 bool AssumeSaneOperatorNew =
getLangOpts().AssumeSaneOperatorNew;
2111 VoidPtr, SizeT,
QualType(), AssumeSaneOperatorNew);
2114 VoidPtr, SizeT,
QualType(), AssumeSaneOperatorNew);
2136 bool AddRestrictAttr) {
2138 unsigned NumParams = Param2.
isNull() ? 1 : 2;
2143 Alloc != AllocEnd; ++Alloc) {
2146 if (
FunctionDecl *Func = dyn_cast<FunctionDecl>(*Alloc)) {
2147 if (Func->getNumParams() == NumParams) {
2150 ->getType().getUnqualifiedType());
2154 ->getType().getUnqualifiedType())
2157 if (InitialParam1Type == Param1 &&
2158 (NumParams == 1 || InitialParam2Type == Param2)) {
2159 if (AddRestrictAttr && !Func->hasAttr<RestrictAttr>())
2160 Func->addAttr(RestrictAttr::CreateImplicit(
2161 Context, RestrictAttr::GNU_malloc));
2165 Func->setHidden(
false);
2175 bool HasBadAllocExceptionSpec
2178 if (HasBadAllocExceptionSpec) {
2181 assert(
StdBadAlloc &&
"Must have std::bad_alloc declared");
2190 QualType Params[] = { Param1, Param2 };
2193 Return, llvm::makeArrayRef(Params, NumParams), EPI);
2197 FnType,
nullptr,
SC_None,
false,
true);
2202 VisibilityAttr::Default));
2204 if (AddRestrictAttr)
2206 RestrictAttr::CreateImplicit(
Context, RestrictAttr::GNU_malloc));
2209 for (
unsigned I = 0; I != NumParams; ++I) {
2216 Alloc->setParams(llvm::makeArrayRef(ParamDecls, NumParams));
2223 bool CanProvideSize,
2235 DEnd = FoundDelete.
end();
2239 Matches.push_back(Fn);
2249 if (
getLangOpts().SizedDeallocation && Matches.size() == 2) {
2250 unsigned NumArgs = CanProvideSize ? 2 : 1;
2251 if (Matches[0]->getNumParams() != NumArgs)
2252 Matches.erase(Matches.begin());
2254 Matches.erase(Matches.begin() + 1);
2255 assert(Matches[0]->getNumParams() == NumArgs &&
2256 "found an unexpected usual deallocation function");
2259 assert(Matches.size() == 1 &&
2260 "unexpectedly have multiple usual deallocation functions");
2261 return Matches.front();
2283 if (isa<FunctionTemplateDecl>(ND))
2286 if (cast<CXXMethodDecl>(ND)->isUsualDeallocationFunction())
2287 Matches.push_back(F.getPair());
2291 if (Matches.size() == 1) {
2292 Operator = cast<CXXMethodDecl>(Matches[0]->getUnderlyingDecl());
2296 Diag(StartLoc, diag::err_deleted_function_use);
2309 }
else if (!Matches.empty()) {
2311 Diag(StartLoc, diag::err_ambiguous_suitable_delete_member_function_found)
2315 F = Matches.begin(), FEnd = Matches.end(); F != FEnd; ++F)
2316 Diag((*F)->getUnderlyingDecl()->getLocation(),
2317 diag::note_member_declared_here) << Name;
2324 if (!Found.
empty()) {
2326 Diag(StartLoc, diag::err_no_suitable_delete_member_function_found)
2331 Diag((*F)->getUnderlyingDecl()->getLocation(),
2332 diag::note_member_declared_here) << Name;
2344 class MismatchingNewDeleteDetector {
2346 enum MismatchResult {
2352 MemberInitMismatches,
2361 explicit MismatchingNewDeleteDetector(
bool EndOfTU)
2362 : IsArrayForm(
false), Field(nullptr), EndOfTU(EndOfTU),
2363 HasUndefinedConstructors(
false) {}
2380 MismatchResult analyzeField(
FieldDecl *Field,
bool DeleteWasArrayForm);
2390 bool HasUndefinedConstructors;
2402 MismatchResult analyzeMemberExpr(
const MemberExpr *ME);
2425 MismatchResult analyzeInClassInitializer();
2429 MismatchingNewDeleteDetector::MismatchResult
2430 MismatchingNewDeleteDetector::analyzeDeleteExpr(
const CXXDeleteExpr *DE) {
2432 assert(DE &&
"Expected delete-expression");
2435 if (
const MemberExpr *ME = dyn_cast<const MemberExpr>(E)) {
2436 return analyzeMemberExpr(ME);
2437 }
else if (
const DeclRefExpr *D = dyn_cast<const DeclRefExpr>(E)) {
2438 if (!hasMatchingVarInit(D))
2439 return VarInitMismatches;
2445 MismatchingNewDeleteDetector::getNewExprFromInitListOrExpr(
const Expr *E) {
2446 assert(E !=
nullptr &&
"Expected a valid initializer expression");
2448 if (
const InitListExpr *ILE = dyn_cast<const InitListExpr>(E)) {
2449 if (ILE->getNumInits() == 1)
2450 E = dyn_cast<const CXXNewExpr>(ILE->getInit(0)->IgnoreParenImpCasts());
2453 return dyn_cast_or_null<const CXXNewExpr>(E);
2456 bool MismatchingNewDeleteDetector::hasMatchingNewInCtorInit(
2460 (NE = getNewExprFromInitListOrExpr(CI->
getInit()))) {
2461 if (NE->
isArray() == IsArrayForm)
2464 NewExprs.push_back(NE);
2469 bool MismatchingNewDeleteDetector::hasMatchingNewInCtor(
2475 HasUndefinedConstructors =
true;
2478 for (
const auto *CI : cast<const CXXConstructorDecl>(Definition)->inits()) {
2479 if (hasMatchingNewInCtorInit(CI))
2485 MismatchingNewDeleteDetector::MismatchResult
2486 MismatchingNewDeleteDetector::analyzeInClassInitializer() {
2487 assert(Field !=
nullptr &&
"This should be called only for members");
2489 getNewExprFromInitListOrExpr(Field->getInClassInitializer())) {
2490 if (NE->
isArray() != IsArrayForm) {
2491 NewExprs.push_back(NE);
2492 return MemberInitMismatches;
2498 MismatchingNewDeleteDetector::MismatchResult
2499 MismatchingNewDeleteDetector::analyzeField(
FieldDecl *Field,
2500 bool DeleteWasArrayForm) {
2501 assert(Field !=
nullptr &&
"Analysis requires a valid class member.");
2502 this->Field = Field;
2503 IsArrayForm = DeleteWasArrayForm;
2505 for (
const auto *CD : RD->
ctors()) {
2506 if (hasMatchingNewInCtor(CD))
2509 if (HasUndefinedConstructors)
2510 return EndOfTU ? NoMismatch : AnalyzeLater;
2511 if (!NewExprs.empty())
2512 return MemberInitMismatches;
2517 MismatchingNewDeleteDetector::MismatchResult
2518 MismatchingNewDeleteDetector::analyzeMemberExpr(
const MemberExpr *ME) {
2519 assert(ME !=
nullptr &&
"Expected a member expression");
2521 return analyzeField(F, IsArrayForm);
2525 bool MismatchingNewDeleteDetector::hasMatchingVarInit(
const DeclRefExpr *D) {
2528 if (VD->hasInit() && (NE = getNewExprFromInitListOrExpr(VD->getInit())) &&
2529 NE->
isArray() != IsArrayForm) {
2530 NewExprs.push_back(NE);
2533 return NewExprs.empty();
2538 const MismatchingNewDeleteDetector &Detector) {
2541 if (!Detector.IsArrayForm)
2550 SemaRef.
Diag(DeleteLoc, diag::warn_mismatched_delete_new)
2551 << Detector.IsArrayForm << H;
2553 for (
const auto *NE : Detector.NewExprs)
2555 << Detector.IsArrayForm;
2558 void Sema::AnalyzeDeleteExprMismatch(
const CXXDeleteExpr *DE) {
2561 MismatchingNewDeleteDetector Detector(
false);
2562 switch (Detector.analyzeDeleteExpr(DE)) {
2563 case MismatchingNewDeleteDetector::VarInitMismatches:
2564 case MismatchingNewDeleteDetector::MemberInitMismatches: {
2568 case MismatchingNewDeleteDetector::AnalyzeLater: {
2573 case MismatchingNewDeleteDetector::NoMismatch:
2579 bool DeleteWasArrayForm) {
2580 MismatchingNewDeleteDetector Detector(
true);
2581 switch (Detector.analyzeField(Field, DeleteWasArrayForm)) {
2582 case MismatchingNewDeleteDetector::VarInitMismatches:
2583 llvm_unreachable(
"This analysis should have been done for class members.");
2584 case MismatchingNewDeleteDetector::AnalyzeLater:
2585 llvm_unreachable(
"Analysis cannot be postponed any point beyond end of "
2586 "translation unit.");
2587 case MismatchingNewDeleteDetector::MemberInitMismatches:
2590 case MismatchingNewDeleteDetector::NoMismatch:
2601 bool ArrayForm,
Expr *ExE) {
2611 bool ArrayFormAsWritten = ArrayForm;
2612 bool UsualArrayDeleteWantsSize =
false;
2630 if (ConvPtrType->getPointeeType()->isIncompleteOrObjectType())
2637 return S.
Diag(Loc, diag::err_delete_operand) << T;
2642 return S.
Diag(Loc, diag::err_delete_incomplete_class_type) << T;
2648 return S.
Diag(Loc, diag::err_delete_explicit_conversion) << T << ConvTy;
2659 return S.
Diag(Loc, diag::err_ambiguous_delete_operand) << T;
2671 llvm_unreachable(
"conversion functions are permitted");
2679 if (!Converter.match(Type))
2688 return Diag(Ex.
get()->getLocStart(),
2689 diag::err_address_space_qualified_delete)
2697 Diag(StartLoc, diag::ext_delete_void_ptr_operand)
2698 << Type << Ex.
get()->getSourceRange();
2701 << Type << Ex.
get()->getSourceRange());
2704 diag::warn_delete_incomplete, Ex.
get())) {
2706 PointeeRD = cast<CXXRecordDecl>(RT->getDecl());
2711 Diag(StartLoc, diag::warn_delete_array_type)
2712 << Type << Ex.
get()->getSourceRange()
2718 ArrayForm ? OO_Array_Delete : OO_Delete);
2732 UsualArrayDeleteWantsSize =
2737 else if (OperatorDelete && isa<CXXMethodDecl>(OperatorDelete))
2738 UsualArrayDeleteWantsSize = (OperatorDelete->
getNumParams() == 2);
2744 const_cast<CXXDestructorDecl*>(Dtor));
2763 Diag(StartLoc, diag::warn_delete_abstract_non_virtual_dtor)
2765 }
else if (!ArrayForm) {
2768 Diag(StartLoc, diag::warn_delete_non_virtual_dtor) << PointeeElem;
2775 if (!OperatorDelete)
2779 (!ArrayForm || UsualArrayDeleteWantsSize ||
2789 PDiag(diag::err_access_dtor) << PointeeElem);
2796 UsualArrayDeleteWantsSize, OperatorDelete, Ex.
get(), StartLoc);
2797 AnalyzeDeleteExprMismatch(Result);
2805 bool ConvertToBoolean) {
2815 diag::err_invalid_use_of_function_type)
2819 diag::err_invalid_use_of_array_type)
2829 if (ConvertToBoolean) {
2859 From = Cast->getSubExpr();
2871 if (!ToPtrType->getPointeeType().hasQualifiers()) {
2872 switch (StrLit->getKind()) {
2879 return (ToPointeeType->getKind() == BuiltinType::Char_U ||
2880 ToPointeeType->getKind() == BuiltinType::Char_S);
2882 return ToPointeeType->isWideCharType();
2896 bool HadMultipleCandidates,
2899 default: llvm_unreachable(
"Unhandled cast kind!");
2905 diag::err_allocation_of_abstract_type))
2918 CastLoc, Ty, cast<CXXConstructorDecl>(Method),
2919 ConstructorArgs, HadMultipleCandidates,
2920 false,
false,
false,
2938 HadMultipleCandidates);
2939 if (Result.isInvalid())
2944 nullptr, Result.get()->getValueKind());
2976 assert(FD &&
"no conversion function for user-defined conversion seq");
3008 From->getLocStart(),
3018 From = CastArg.
get();
3026 PDiag(diag::err_typecheck_ambiguous_condition)
3027 << From->getSourceRange());
3031 llvm_unreachable(
"Cannot perform an ellipsis conversion");
3070 ConstructorArgs,
false,
3071 false,
false,
false,
3077 false,
false,
false,
3100 ToAtomicType = ToType;
3101 ToType = ToAtomic->getValueType();
3105 switch (SCS.
First) {
3108 FromType = FromAtomic->getValueType().getUnqualifiedType();
3117 assert(!FromRes.isInvalid() &&
"Can't perform deduced conversion?!");
3118 From = FromRes.get();
3119 FromType = From->getType();
3136 llvm_unreachable(
"Improper first standard conversion");
3183 "only enums with fixed underlying type can promote to bool");
3237 Diag(From->getLocStart(),
3238 diag::ext_typecheck_convert_incompatible_pointer)
3239 << ToType << From->
getType() << Action
3240 << From->getSourceRange() << 0;
3242 Diag(From->getLocStart(),
3243 diag::ext_typecheck_convert_incompatible_pointer)
3244 << From->
getType() << ToType << Action
3245 << From->getSourceRange() << 0;
3255 Diag(From->getLocStart(),
3256 diag::err_arc_weak_unavailable_assign);
3258 Diag(From->getLocStart(),
3259 diag::err_arc_convesion_of_weak_unavailable)
3261 << From->getSourceRange();
3319 From->getLocStart(),
3320 From->getSourceRange(),
3327 &BasePath, CCK).
get();
3341 if (elType != From->
getType()) {
3354 QualType ElType = ToComplex->getElementType();
3376 assert(FromComplex);
3415 From = FromRes.
get();
3417 "Improper transparent union conversion");
3433 llvm_unreachable(
"Improper second standard conversion");
3436 switch (SCS.
Third) {
3447 CK_NoOp, VK,
nullptr, CCK).
get();
3452 ? diag::ext_deprecated_string_literal_conversion
3453 : diag::warn_deprecated_string_literal_conversion)
3461 llvm_unreachable(
"Improper third standard conversion");
3466 if (!ToAtomicType.
isNull()) {
3495 default: llvm_unreachable(
"not a UTT");
3582 Loc, ElTy, diag::err_incomplete_type_used_in_type_trait_expr);
3593 if ((RD->*HasTrivial)() && !(RD->*HasNonTrivial)())
3600 bool FoundOperator =
false;
3603 Op != OpEnd; ++Op) {
3604 if (isa<FunctionTemplateDecl>(*Op))
3608 if((Operator->*IsDesiredOp)()) {
3609 FoundOperator =
true;
3617 return FoundOperator;
3624 assert(!T->
isDependentType() &&
"Cannot evaluate traits of dependent type");
3628 default: llvm_unreachable(
"not a UTT");
3726 return RD->
hasAttr<FinalAttr>();
3730 if (FinalAttr *FA = RD->
getAttr<FinalAttr>())
3731 return FA->isSpelledAsSealed();
3760 if (
CXXRecordDecl *RD = C.getBaseElementType(T)->getAsCXXRecordDecl())
3770 if (
CXXRecordDecl *RD = C.getBaseElementType(T)->getAsCXXRecordDecl())
3791 if (
CXXRecordDecl *RD = C.getBaseElementType(T)->getAsCXXRecordDecl())
3834 if (
CXXRecordDecl *RD = C.getBaseElementType(T)->getAsCXXRecordDecl())
3846 if (C.getBaseElementType(T).isConstQualified())
3885 bool FoundConstructor =
false;
3889 ConEnd = R.
end(); Con != ConEnd; ++Con) {
3893 if (isa<FunctionTemplateDecl>(*Con))
3897 FoundConstructor =
true;
3910 return FoundConstructor;
3921 if (
CXXRecordDecl *RD = C.getBaseElementType(T)->getAsCXXRecordDecl()) {
3926 bool FoundConstructor =
false;
3929 ConEnd = R.
end(); Con != ConEnd; ++Con) {
3931 if (isa<FunctionTemplateDecl>(*Con))
3935 FoundConstructor =
true;
3947 return FoundConstructor;
3956 return Destructor->isVirtual();
3986 llvm_unreachable(
"Unknown ObjC lifetime qualifier");
4000 Args[1]->getType(), RParenLoc);
4019 assert(!Args.empty());
4024 for (
unsigned I = 0, N = Args.size(); I != N; ++I) {
4025 QualType ArgTy = Args[I]->getType();
4030 diag::err_incomplete_type_used_in_type_trait_expr))
4035 if (Args[0]->getType()->isIncompleteType())
4039 CXXRecordDecl *RD = Args[0]->getType()->getAsCXXRecordDecl();
4045 ArgExprs.reserve(Args.size() - 1);
4046 for (
unsigned I = 1, N = Args.size(); I != N; ++I) {
4050 OpaqueArgExprs.push_back(
4055 for (
Expr &E : OpaqueArgExprs)
4056 ArgExprs.push_back(&E);
4089 return !Result.
get()->hasNonTrivialCall(S.
Context);
4092 llvm_unreachable(
"unhandled type trait");
4095 default: llvm_unreachable(
"not a TT");
4107 *
this, Kind, KWLoc, Args[0]->getType()))
4110 bool Dependent =
false;
4111 for (
unsigned I = 0, N = Args.size(); I != N; ++I) {
4112 if (Args[I]->getType()->isDependentType()) {
4130 ConvertedArgs.reserve(Args.size());
4132 for (
unsigned I = 0, N = Args.size(); I != N; ++I) {
4138 ConvertedArgs.push_back(TInfo);
4147 "Cannot evaluate traits of dependent types");
4157 if (!lhsRecord)
return false;
4160 if (!rhsRecord)
return false;
4163 == (lhsRecord == rhsRecord));
4165 if (lhsRecord == rhsRecord)
4173 diag::err_incomplete_type_used_in_type_trait_expr))
4176 return cast<CXXRecordDecl>(rhsRecord->
getDecl())
4177 ->isDerivedFrom(cast<CXXRecordDecl>(lhsRecord->
getDecl()));
4232 Expr *FromPtr = &From;
4264 diag::err_incomplete_type_used_in_type_trait_expr))
4268 diag::err_incomplete_type_used_in_type_trait_expr))
4306 return !Result.get()->hasNonTrivialCall(Self.
Context);
4309 llvm_unreachable(
"unhandled type trait");
4312 default: llvm_unreachable(
"not a BTT");
4314 llvm_unreachable(
"Unknown type trait or not implemented");
4333 assert(!T->
isDependentType() &&
"Cannot evaluate traits of dependent type");
4341 T = AT->getElementType();
4351 diag::err_dimension_expr_not_constant_integer,
4354 if (Value.isSigned() && Value.isNegative()) {
4355 Self.
Diag(KeyLoc, diag::err_dimension_expr_not_constant_integer)
4356 << DimExpr->getSourceRange();
4359 Dim = Value.getLimitedValue();
4363 bool Matched =
false;
4370 T = AT->getElementType();
4375 return CAT->getSize().getLimitedValue();
4381 llvm_unreachable(
"Unknown type trait or not implemented");
4424 llvm_unreachable(
"Expression trait not covered by switch");
4451 "placeholders should have been weeded out by now");
4463 const char *OpSpelling = isIndirect ?
"->*" :
".*";
4471 Diag(Loc, diag::err_bad_memptr_rhs)
4472 << OpSpelling << RHSType << RHS.
get()->getSourceRange();
4493 Diag(Loc, diag::err_bad_memptr_lhs)
4494 << OpSpelling << 1 << LHSType
4503 OpSpelling, (
int)isIndirect)) {
4508 Diag(Loc, diag::err_bad_memptr_lhs) << OpSpelling
4516 RHS.
get()->getLocEnd()),
4530 Diag(Loc, diag::err_pointer_to_member_type) << isIndirect;
4549 switch (Proto->getRefQualifier()) {
4556 Diag(Loc, diag::err_pointer_to_member_oper_value_classify)
4557 << RHSType << 1 << LHS.
get()->getSourceRange();
4562 Diag(Loc, diag::err_pointer_to_member_oper_value_classify)
4563 << RHSType << 0 << LHS.
get()->getSourceRange();
4578 }
else if (isIndirect) {
4596 bool &HaveConversion,
4598 HaveConversion =
false;
4619 HaveConversion =
true;
4624 return InitSeq.
Diagnose(Self, Entity, Kind, From);
4634 bool FDerivedFromT = FRec && TRec && FRec != TRec &&
4637 (FRec == TRec || FDerivedFromT || Self.
IsDerivedFrom(TTy, FTy))) {
4641 if (FRec == TRec || FDerivedFromT) {
4646 HaveConversion =
true;
4651 return InitSeq.
Diagnose(Self, Entity, Kind, From);
4670 HaveConversion = !InitSeq.
Failed();
4673 return InitSeq.
Diagnose(Self, Entity, Kind, From);
4721 Self.
Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands)
4722 << LHS.
get()->getType() << RHS.
get()->getType()
4723 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
4727 Self.
Diag(QuestionLoc, diag::err_conditional_ambiguous_ovl)
4728 << LHS.
get()->getType() << RHS.
get()->getType()
4729 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
4735 llvm_unreachable(
"Conditional operator has only built-in overloads");
4790 if (LVoid || RVoid) {
4797 if (LThrow != RThrow) {
4798 Expr *NonThrow = LThrow ? RHS.
get() : LHS.
get();
4812 Diag(QuestionLoc, diag::err_conditional_void_nonvoid)
4813 << (LVoid ? RTy : LTy) << (LVoid ? 0 : 1)
4814 << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
4828 bool HaveL2R, HaveR2L;
4835 if (HaveL2R && HaveR2L) {
4836 Diag(QuestionLoc, diag::err_conditional_ambiguous)
4837 << LTy << RTy << LHS.
get()->getSourceRange() << RHS.
get()->getSourceRange();
4848 }
else if (HaveR2L) {
4869 if (RCVR.isStrictSupersetOf(LCVR)) {
4887 if (Same && LVK == RVK && LVK !=
VK_RValue &&
4900 if (!Same && (LTy->isRecordType() || RTy->
isRecordType())) {
4916 RTy = RHS.get()->getType();
4925 if (LTy->isRecordType()) {
4928 diag::err_allocation_of_abstract_type))
4983 bool NonStandardCompositeType =
false;
4986 : &NonStandardCompositeType);
4987 if (!Composite.
isNull()) {
4988 if (NonStandardCompositeType)
4990 diag::ext_typecheck_cond_incompatible_operands_nonstandard)
4991 << LTy << RTy << Composite
4992 << LHS.
get()->getSourceRange() << RHS.get()->getSourceRange();
5006 Diag(QuestionLoc, diag::err_typecheck_cond_incompatible_operands)
5007 << LHS.
get()->
getType() << RHS.get()->getType()
5008 << LHS.
get()->getSourceRange() << RHS.get()->getSourceRange();
5028 bool *NonStandardCompositeType) {
5029 if (NonStandardCompositeType)
5030 *NonStandardCompositeType =
false;
5042 !T2->isAnyPointerType() && !T2->isMemberPointerType()) {
5048 if (T2->isNullPtrType() &&
5057 if (T2->isMemberPointerType())
5073 (!T2->isPointerType() && !T2->isMemberPointerType()))
5088 QualifierVector QualifierUnion;
5090 ContainingClassVector;
5091 ContainingClassVector MemberOfClass;
5094 unsigned NeedConstBefore = 0;
5104 if (NonStandardCompositeType &&
5106 NeedConstBefore = QualifierUnion.size();
5108 QualifierUnion.push_back(
5110 MemberOfClass.push_back(std::make_pair(
nullptr,
nullptr));
5122 if (NonStandardCompositeType &&
5124 NeedConstBefore = QualifierUnion.size();
5126 QualifierUnion.push_back(
5128 MemberOfClass.push_back(std::make_pair(MemPtr1->
getClass(),
5139 if (NeedConstBefore && NonStandardCompositeType) {
5143 for (
unsigned I = 0; I != NeedConstBefore; ++I) {
5146 *NonStandardCompositeType =
true;
5152 ContainingClassVector::reverse_iterator MOC
5153 = MemberOfClass.rbegin();
5154 for (QualifierVector::reverse_iterator
5155 I = QualifierUnion.rbegin(),
5156 E = QualifierUnion.rend();
5157 I != E; (void)++I, ++MOC) {
5159 if (MOC->first && MOC->second) {
5184 if (E1ToC1 && E2ToC1) {
5193 if (E1ToC2 && E2ToC2) {
5202 = E1ToC1.
Perform(*
this, Entity1, Kind, E1);
5209 = E2ToC1.
Perform(*
this, Entity1, Kind, E2);
5210 if (E2Result.isInvalid())
5212 E2 = E2Result.getAs<
Expr>();
5222 if (!E1ToC2 || !E2ToC2)
5227 = E1ToC2.
Perform(*
this, Entity2, Kind, E1);
5234 = E2ToC2.
Perform(*
this, Entity2, Kind, E2);
5235 if (E2Result.isInvalid())
5237 E2 = E2Result.getAs<
Expr>();
5246 assert(!isa<CXXBindTemporaryExpr>(E) &&
"Double-bound temporary?");
5257 bool ReturnsRetained;
5261 if (
CallExpr *Call = dyn_cast<CallExpr>(E)) {
5268 T = BinOp->getRHS()->getType();
5269 else if (
MemberExpr *Mem = dyn_cast<MemberExpr>(Callee))
5270 T = Mem->getMemberDecl()->getType();
5281 assert(FTy &&
"call to value not of function type?");
5286 }
else if (isa<StmtExpr>(E)) {
5287 ReturnsRetained =
true;
5291 }
else if (isa<CastExpr>(E) &&
5292 isa<BlockExpr>(cast<CastExpr>(E)->getSubExpr())) {
5301 D = Send->getMethodDecl();
5302 }
else if (
ObjCBoxedExpr *BoxedExpr = dyn_cast<ObjCBoxedExpr>(E)) {
5303 D = BoxedExpr->getBoxingMethod();
5305 D = ArrayLit->getArrayWithObjectsMethod();
5307 = dyn_cast<ObjCDictionaryLiteral>(E)) {
5308 D = DictLit->getDictWithObjectsMethod();
5311 ReturnsRetained = (D && D->
hasAttr<NSReturnsRetainedAttr>());
5316 if (!ReturnsRetained &&
5343 RT = cast<RecordType>(T);
5345 case Type::ConstantArray:
5346 case Type::IncompleteArray:
5347 case Type::VariableArray:
5348 case Type::DependentSizedArray:
5368 PDiag(diag::err_access_dtor_temp)
5399 assert(SubExpr &&
"subexpression can't be null!");
5419 assert(SubStmt &&
"sub-statement can't be null!");
5443 assert(
ExprEvalContexts.back().IsDecltype &&
"not in a decltype expression");
5455 if (
ParenExpr *PE = dyn_cast<ParenExpr>(E)) {
5459 if (SubExpr.
get() == PE->getSubExpr())
5468 if (RHS.
get() == BO->getRHS())
5471 BO->getLHS(), RHS.
get(),
BO_Comma, BO->getType(), BO->getValueKind(),
5472 BO->getObjectKind(), BO->getOperatorLoc(), BO->isFPContractable());
5493 for (
unsigned I = 0, N =
ExprEvalContexts.back().DelayedDecltypeCalls.size();
5496 if (Call == TopCall)
5507 for (
unsigned I = 0, N =
ExprEvalContexts.back().DelayedDecltypeBinds.size();
5511 if (Bind == TopBind)
5523 PDiag(diag::err_access_dtor_temp)
5539 unsigned SkipStart = OperatorArrows.size(), SkipCount = 0;
5542 if (OperatorArrows.size() > Limit) {
5544 SkipStart = (Limit - 1) / 2 + (Limit - 1) % 2;
5545 SkipCount = OperatorArrows.size() - (Limit - 1);
5548 for (
unsigned I = 0; I < OperatorArrows.size(); ) {
5549 if (I == SkipStart) {
5550 S.
Diag(OperatorArrows[I]->getLocation(),
5551 diag::note_operator_arrows_suppressed)
5555 S.
Diag(OperatorArrows[I]->getLocation(), diag::note_operator_arrow_here)
5556 << OperatorArrows[I]->getCallResultType();
5566 bool &MayBePseudoDestructor) {
5570 Base = Result.
get();
5574 Base = Result.
get();
5577 MayBePseudoDestructor =
false;
5582 if (OpKind == tok::arrow)
5587 MayBePseudoDestructor =
true;
5594 if (OpKind == tok::arrow) {
5596 bool NoArrowOperatorFound =
false;
5597 bool FirstIteration =
true;
5600 llvm::SmallPtrSet<CanQualType,8> CTypes;
5605 if (OperatorArrows.size() >=
getLangOpts().ArrowDepth) {
5606 Diag(OpLoc, diag::err_operator_arrow_depth_exceeded)
5607 << StartingType <<
getLangOpts().ArrowDepth << Base->getSourceRange();
5609 Diag(OpLoc, diag::note_operator_arrow_depth)
5622 : &NoArrowOperatorFound);
5624 if (NoArrowOperatorFound) {
5625 if (FirstIteration) {
5626 Diag(OpLoc, diag::err_typecheck_member_reference_suggestion)
5627 << BaseType << 1 << Base->getSourceRange()
5629 OpKind = tok::period;
5632 Diag(OpLoc, diag::err_typecheck_member_reference_arrow)
5633 << BaseType << Base->getSourceRange();
5637 diag::note_member_reference_arrow_from_operator_arrow);
5642 Base = Result.
get();
5644 OperatorArrows.push_back(OpCall->getDirectCallee());
5647 if (!CTypes.insert(CBaseType).second) {
5648 Diag(OpLoc, diag::err_operator_arrow_circular) << StartingType;
5652 FirstIteration =
false;
5655 if (OpKind == tok::arrow &&
5674 MayBePseudoDestructor =
true;
5677 MayBePseudoDestructor =
true;
5705 Base = result.
get();
5715 if (OpKind == tok::arrow) {
5720 S.
Diag(OpLoc, diag::err_typecheck_member_reference_suggestion)
5721 << ObjectType <<
true
5726 OpKind = tok::period;
5744 if (
CheckArrow(*
this, ObjectType, Base, OpKind, OpLoc))
5750 Diag(OpLoc, diag::ext_pseudo_dtor_on_void) << Base->getSourceRange();
5752 Diag(OpLoc, diag::err_pseudo_dtor_base_not_scalar)
5753 << ObjectType << Base->getSourceRange();
5761 if (DestructedTypeInfo) {
5767 Diag(DestructedTypeStart, diag::err_pseudo_dtor_type_mismatch)
5768 << ObjectType << DestructedType << Base->getSourceRange()
5772 DestructedType = ObjectType;
5774 DestructedTypeStart);
5783 Diag(DestructedTypeStart, diag::err_arc_pseudo_dtor_inconstant_quals)
5784 << ObjectType << DestructedType << Base->getSourceRange()
5789 DestructedType = ObjectType;
5791 DestructedTypeStart);
5804 if (ScopeTypeInfo) {
5810 diag::err_pseudo_dtor_type_mismatch)
5811 << ObjectType << ScopeType << Base->getSourceRange()
5815 ScopeTypeInfo =
nullptr;
5821 OpKind == tok::arrow, OpLoc,
5841 "Invalid first type name in pseudo-destructor");
5844 "Invalid second type name in pseudo-destructor");
5847 if (
CheckArrow(*
this, ObjectType, Base, OpKind, OpLoc))
5868 S, &SS,
true,
false, ObjectTypePtrForLookup);
5880 diag::err_pseudo_dtor_destructor_non_type)
5886 DestructedType = ObjectType;
5901 if (T.isInvalid() || !T.get()) {
5903 DestructedType = ObjectType;
5910 if (!DestructedType.
isNull()) {
5911 if (!DestructedTypeInfo)
5925 S, &SS,
true,
false, ObjectTypePtrForLookup);
5928 diag::err_pseudo_dtor_destructor_non_type)
5950 if (T.isInvalid() || !T.get()) {
5958 if (!ScopeType.
isNull() && !ScopeTypeInfo)
5964 ScopeTypeInfo, CCLoc, TildeLoc,
5974 if (
CheckArrow(*
this, ObjectType, Base, OpKind, OpLoc))
5993 bool HadMultipleCandidates) {
6004 SubE = BE->getSubExpr();
6005 if (isa<LambdaExpr>(SubE)) {
6029 if (HadMultipleCandidates)
6039 Exp.
get()->getLocEnd());
6059 Diag(Operand->
getExprLoc(), diag::warn_side_effects_unevaluated_context);
6081 if (isa<DeclRefExpr>(E))
6085 if (isa<ArraySubscriptExpr>(E))
6089 if (isa<MemberExpr>(E))
6099 if (BO->isPtrMemOp())
6114 dyn_cast<BinaryConditionalOperator>(E)) {
6115 if (
OpaqueValueExpr *OVE = dyn_cast<OpaqueValueExpr>(BCO->getTrueExpr()))
6121 if (isa<PseudoObjectExpr>(E) || isa<ObjCIvarRefExpr>(E))
6169 if (!T->getDecl()->isComplete()) {
6183 diag::err_incomplete_type);
6201 if (isa<ParmVarDecl>(Var))
return true;
6202 const VarDecl *DefVD =
nullptr;
6207 if (DefVD->
isWeak())
return false;
6235 "The current call operator must be synchronized with Sema's CurContext");
6245 const unsigned NumPotentialCaptures =
6247 for (
unsigned I = 0; I != NumPotentialCaptures; ++I) {
6248 Expr *VarExpr =
nullptr;
6263 !IsFullExprInstantiationDependent)
6270 FunctionScopesArrayRef, Var, S)) {
6271 const unsigned FunctionScopeIndexOfCapturableLambda = Index.getValue();
6273 &FunctionScopeIndexOfCapturableLambda);
6275 const bool IsVarNeverAConstantExpression =
6277 if (!IsFullExprInstantiationDependent || IsVarNeverAConstantExpression) {
6289 DeclRefType,
nullptr)) {
6295 DeclRefType,
nullptr);
6306 FunctionScopesArrayRef,
nullptr, S)) {
6307 const unsigned FunctionScopeIndexOfCapturableLambda = Index.getValue();
6310 &FunctionScopeIndexOfCapturableLambda);
6333 R.setLookupName(ND->getDeclName());
6335 if (ND->isCXXClassMember()) {
6339 Record = NNS->getAsType()->getAsCXXRecordDecl();
6342 dyn_cast<
CXXRecordDecl>(ND->getDeclContext()->getRedeclContext());
6344 R.setNamingClass(Record);
6348 bool MightBeImplicitMember;
6350 MightBeImplicitMember =
true;
6352 MightBeImplicitMember =
false;
6353 else if (R.isOverloadedResult())
6354 MightBeImplicitMember =
false;
6355 else if (R.isUnresolvableResult())
6356 MightBeImplicitMember =
true;
6358 MightBeImplicitMember = isa<FieldDecl>(ND) ||
6359 isa<IndirectFieldDecl>(ND) ||
6360 isa<MSPropertyDecl>(ND);
6362 if (MightBeImplicitMember)
6366 }
else if (
auto *Ivar = dyn_cast<ObjCIvarDecl>(ND)) {
6368 Ivar->getIdentifier());
6382 : TypoExprs(TypoExprs) {}
6384 TypoExprs.insert(TE);
6389 class TransformTypos :
public TreeTransform<TransformTypos> {
6394 llvm::function_ref<ExprResult(Expr *)> ExprFilter;
6396 llvm::SmallDenseMap<TypoExpr *, ExprResult, 2> TransformCache;
6397 llvm::SmallDenseMap<OverloadExpr *, Expr *, 4> OverloadResolution;
6403 void EmitAllDiagnostics() {
6404 for (
auto E : TypoExprs) {
6406 auto &
State = SemaRef.getTypoExprState(TE);
6407 if (State.DiagHandler) {
6417 Replacement.
isInvalid() ?
nullptr : Replacement.
get()))
6420 State.DiagHandler(TC);
6422 SemaRef.clearDelayedTypo(TE);
6435 bool CheckAndAdvanceTypoExprCorrectionStreams() {
6436 for (
auto TE : TypoExprs) {
6437 auto &State = SemaRef.getTypoExprState(TE);
6438 TransformCache.erase(TE);
6439 if (!State.Consumer->finished())
6441 State.Consumer->resetCorrectionStream();
6447 if (
auto *OE = dyn_cast_or_null<OverloadExpr>(E))
6448 E = OverloadResolution[OE];
6452 if (
auto *DRE = dyn_cast<DeclRefExpr>(E))
6453 return DRE->getDecl();
6454 if (
auto *ME = dyn_cast<MemberExpr>(E))
6465 if (Trap.hasErrorOccurred() || Res.
isInvalid())
6468 return ExprFilter(Res.
get());
6473 : BaseTransform(SemaRef), InitDecl(InitDecl), ExprFilter(Filter) {}
6478 Expr *ExecConfig =
nullptr) {
6479 auto Result = BaseTransform::RebuildCallExpr(Callee, LParenLoc, Args,
6480 RParenLoc, ExecConfig);
6481 if (
auto *OE = dyn_cast<OverloadExpr>(Callee)) {
6484 if (
auto *BE = dyn_cast<CXXBindTemporaryExpr>(ResultCall))
6485 ResultCall = BE->getSubExpr();
6486 if (
auto *CE = dyn_cast<CallExpr>(ResultCall))
6487 OverloadResolution[OE] = CE->getCallee();
6498 Res = TryTransform(E);
6503 !CheckAndAdvanceTypoExprCorrectionStreams())
6516 while (!AmbiguousTypoExprs.empty()) {
6517 auto TE = AmbiguousTypoExprs.back();
6518 auto Cached = TransformCache[TE];
6520 State.Consumer->saveCurrentPosition();
6521 TransformCache.erase(TE);
6523 State.Consumer->resetCorrectionStream();
6524 TransformCache.erase(TE);
6528 AmbiguousTypoExprs.remove(TE);
6529 State.Consumer->restoreSavedPosition();
6530 TransformCache[TE] = Cached;
6536 FindTypoExprs(TypoExprs).TraverseStmt(E);
6538 EmitAllDiagnostics();
6547 auto &CacheEntry = TransformCache[E];
6548 if (!TypoExprs.insert(E) && !CacheEntry.isUnset()) {
6553 assert(State.Consumer &&
"Cannot transform a cleared TypoExpr");
6557 while (
TypoCorrection TC = State.Consumer->getNextCorrection()) {
6561 State.RecoveryHandler(SemaRef, E, TC) :
6568 if ((Next = State.Consumer->peekNextCorrection()) &&
6570 AmbiguousTypoExprs.insert(E);
6572 AmbiguousTypoExprs.remove(E);
6575 "Typo was transformed into a valid-but-null ExprResult");
6576 return CacheEntry = NE;
6594 assert(TyposInContext < ~0U &&
"Recursive call of CorrectDelayedTyposInExpr");
6596 auto TyposResolved = DelayedTypos.size();
6597 auto Result = TransformTypos(*
this, InitDecl, Filter).Transform(E);
6599 TyposResolved -= DelayedTypos.size();
6604 assert(TyposResolved == 0 &&
"Corrected typo but got same Expr back?");
6610 bool DiscardedValue,
6612 bool IsLambdaInitCaptureInitializer) {
6615 if (!FullExpr.
get())
6633 if (!IsLambdaInitCaptureInitializer &&
6638 if (DiscardedValue &&
getLangOpts().DebuggerCastResultToId &&
6645 if (DiscardedValue) {
6659 CheckCompletedExpr(FullExpr.
get(), CC, IsConstexpr);
6707 if (IsInLambdaDeclContext && CurrentLSI &&
6708 CurrentLSI->hasPotentialCaptures() && !FullExpr.
isInvalid())
6752 llvm_unreachable(
"Invalid LookupResult Kind!");
6765 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
A call to an overloaded operator written using operator syntax.
unsigned getAddressSpace() const
getAddressSpace - 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)
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
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)
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 isNullPtrType() const
static bool EvaluateExpressionTrait(ExpressionTrait ET, Expr *E)
ExprResult PerformContextuallyConvertToBool(Expr *From)
bool Diagnose(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, ArrayRef< Expr * > Args)
Diagnose an potentially-invalid initialization sequence.
bool isNonOverloadPlaceholderType() const
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.
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)
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
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...
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
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.
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
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
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...
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)
ExprResult ActOnNoexceptExpr(SourceLocation KeyLoc, SourceLocation LParen, Expr *Operand, SourceLocation RParen)
ExprResult CheckBooleanCondition(Expr *E, SourceLocation Loc)
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)
ExprResult PerformContextualImplicitConversion(SourceLocation Loc, Expr *FromE, ContextualImplicitConverter &Converter)
Perform a contextual implicit conversion.
bool isLiteralType(const ASTContext &Ctx) const
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
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...
bool hasErrorOccurred() const
Determine whether any SFINAE errors have been trapped.
QualType getPointeeType() const
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
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...
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)
An Embarcadero array type trait, as used in the implementation of __array_rank and __array_extent...
Ambiguous candidates found.
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)
[ARC] Consumes a retainable object pointer that has just been produced, e.g. as the return value of a...
Represents a C++ constructor within a class.
bool HasSideEffects(const ASTContext &Ctx, bool IncludePossibleEffects=true) const
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.
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.
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
ExprResult PerformObjectArgumentInitialization(Expr *From, NestedNameSpecifier *Qualifier, NamedDecl *FoundDecl, CXXMethodDecl *Method)
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.
ExtProtoInfo - 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...
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
A namespace, stored as a NamespaceDecl*.
bool HadMultipleCandidates
bool isTrivialType(ASTContext &Context) const
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)
ParmVarDecl - Represents a parameter to a function.
bool isObjCRetainableType() const
NullPointerConstantKind isNullPointerConstant(ASTContext &Ctx, NullPointerConstantValueDependence NPC) const
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.
Information about a template-id annotation token.
EvaluatedStmt * ensureEvaluatedStmt() const
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)
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)
QualType FindCompositeObjCPointerType(ExprResult &LHS, ExprResult &RHS, SourceLocation QuestionLoc)
SourceLocation getLocForEndOfToken(SourceLocation Loc, unsigned Offset=0)
Computes the source location just past the end of the token at this source location.
bool 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...
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
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. _Complex char -> _Complex long long _Complex unsig...
The results of name lookup within a DeclContext. This is either a single result (with no stable stora...
bool isObjCARCImplicitlyUnretainedType() const
bool hasNonTrivialCopyConstructor() const
Determine whether this class has a non-trivial copy constructor (C++ [class.copy]p6, C++11 [class.copy]p12)
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
bool isAnyPointerType() const
Identity conversion (no conversion)
void AddBuiltinOperatorCandidates(OverloadedOperatorKind Op, SourceLocation OpLoc, ArrayRef< Expr * > Args, OverloadCandidateSet &CandidateSet)
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)
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.
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)
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)
static bool hasNontrivialObjCLifetime(QualType T)
Determine whether T has a non-trivial Objective-C lifetime in ARC mode.
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.
bool isIntegralOrUnscopedEnumerationType() const
Determine whether this type is an integral or unscoped enumeration type.
This is a scope that corresponds to a block/closure object. Blocks serve as top-level scopes for some...
ExprResult ActOnCXXThrow(Scope *S, SourceLocation OpLoc, Expr *expr)
ActOnCXXThrow - Parse throw expressions.
Represents a C++ unqualified-id that has been parsed.
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()
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)
const LangOptions & getLangOpts() const
unsigned getNumTypeObjects() const
Return the number of types applied to this declarator.
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
bool isObjCLifetimeType() const
const ArrayType * getAsArrayType(QualType T) const
char * location_data() const
Retrieve the data associated with the source-location information.
SourceLocation getLocStart() const LLVM_READONLY
A builtin binary operation expression such as "x + y" or "x <= y".
bool isValueDependent() const
RecordDecl * getDecl() const
ImplicitConversionKind Second
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
FunctionDecl * ResolveAddressOfOverloadedFunction(Expr *AddressOfExpr, QualType TargetType, bool Complain, DeclAccessPair &Found, bool *pHadMultipleCandidates=nullptr)
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)
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.
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.
TypeSourceInfo * getTypeSourceInfo() const
TypeClass getTypeClass() const
bool isStructureType() const
bool isIncompleteType(NamedDecl **Def=nullptr) const
Def If non-NULL, and the type refers to some kind of declaration that can be completed (such as a C s...
Represents binding an expression to a temporary.
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'.
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)
ImplicitConversionKind Third
Third - The third conversion can be a qualification conversion.
ExprResult BuildDeclarationNameExpr(const CXXScopeSpec &SS, LookupResult &R, bool NeedsADL, bool AcceptInvalidDecl=false)
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)
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
SourceLocation TemplateKWLoc
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.
EnumDecl * getDecl() const
RAII class used to determine whether SFINAE has trapped any errors that occur during template argumen...
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
QualType getValueType() const
ExtInfo getExtInfo() const
Sema - This implements semantic analysis and AST building for C.
Represents a C++ pseudo-destructor (C++ [expr.pseudo]).
TST getTypeSpecType() const
const DeclarationNameInfo & getLookupNameInfo() const
Gets the name info to look up.
QualType getParamType(unsigned i) const
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
getObjCLifetime - 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 isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on a template...
SourceLocation PotentialThisCaptureLocation
QualType getPointeeType() const
Converts between different floating point complex types. _Complex float -> _Complex double...
ExprResult BuildTypeTrait(TypeTrait Kind, SourceLocation KWLoc, ArrayRef< TypeSourceInfo * > Args, SourceLocation RParenLoc)
bool isRealFloatingType() const
Floating point categories.
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...
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. the class which was looked into to find these result...
static unsigned getMaxSizeBits(ASTContext &Context)
Determine the maximum number of active bits that an array's size can require, which limits the maximu...
ExprResult BuildPossibleImplicitMemberExpr(const CXXScopeSpec &SS, SourceLocation TemplateKWLoc, LookupResult &R, const TemplateArgumentListInfo *TemplateArgs)
Builds an expression which might be an implicit member expression.
bool isDeclScope(Decl *D)
ExprResult BuildCXXTypeConstructExpr(TypeSourceInfo *Type, SourceLocation LParenLoc, MultiExprArg Exprs, SourceLocation RParenLoc)
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
This file defines the classes used to store parsed information about declaration-specifiers and decla...
Inits[]
Gets the list of initial values for linear variables.
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. Asserts that one was found.
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)
const ParmVarDecl * getParamDecl(unsigned i) const
CXXConstructorDecl * CopyConstructor
Overload resolution succeeded.
bool isFloatingType() const
ExprResult CheckPlaceholderExpr(Expr *E)
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())
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
SourceLocation Loc
Loc - The place where this type was defined.
StandardConversionSequence Standard
bool IsDerivedFrom(QualType Derived, QualType Base)
Determine whether the type Derived is a C++ class that is derived from the type Base.
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. _Complex unsigned -> _Complex float...
static uint64_t EvaluateArrayTypeTrait(Sema &Self, ArrayTypeTrait ATT, QualType T, Expr *DimExpr, SourceLocation KeyLoc)
SmallVector< ActiveTemplateInstantiation, 16 > ActiveTemplateInstantiations
List of active template instantiations.
ParsedType getInheritingConstructorName(CXXScopeSpec &SS, SourceLocation NameLoc, IdentifierInfo &Name)
Handle the result of the special case name lookup for inheriting constructor declarations. 'NS::X::X' and 'NS::X<...>::X' are treated as constructor names in member using declarations, even if 'X' is not the name of the corresponding type.
CXXRecordDecl * getStdBadAlloc() const
void CleanupVarDeclMarking()
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.
ExprResult DefaultFunctionArrayLvalueConversion(Expr *E)
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. If Normalized is true, scale the distance down by the CharDistanceWeight to return the edit distance in terms of single-character edits.
const Expr * getAnyInitializer() const
const TypoExprState & getTypoExprState(TypoExpr *TE) const
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. If this depends on t...
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)
DeclContext * getEntity() const
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
Integral conversions (C++ 4.7)
Complex promotions (Clang extension)
ExprResult MaybeBindToTemporary(Expr *E)
static CXXBindTemporaryExpr * Create(const ASTContext &C, CXXTemporary *Temp, Expr *SubExpr)
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)
Encodes a location in the source. The SourceManager can decode this to get at the full include stack...
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
unsigned getNumParams() const
const Type * getTypePtr() const
CastKind PrepareCastToObjCObjectPointer(ExprResult &E)
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
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...
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)
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)
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. This only happens in C++...
bool isIntegerConstantExpr(llvm::APSInt &Result, const ASTContext &Ctx, SourceLocation *Loc=nullptr, bool isEvaluated=true) const
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)
const Type * getBaseElementTypeUnsafe() const
Pointer conversions (C++ 4.10)
Converts from an integral real to an integral complex whose element type matches the source...
static Expr * captureThis(ASTContext &Context, RecordDecl *RD, QualType ThisTy, SourceLocation Loc)
static bool VariableCanNeverBeAConstantExpression(VarDecl *Var, ASTContext &Context)
SourceLocation getBegin() const
bool isTypeDependent() const
lookup_result lookup(DeclarationName Name) const
const SourceRange & getSourceRange() const LLVM_READONLY
Get the source range that spans this declarator.
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.
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
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
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
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)
ExprResult BuildCXXMemberCallExpr(Expr *Exp, NamedDecl *FoundDecl, CXXConversionDecl *Method, bool HadMultipleCandidates)
The scope of a struct/union/class definition.
QualType getCallReturnType(const ASTContext &Ctx) const
bool CheckPointerConversion(Expr *From, QualType ToType, CastKind &Kind, CXXCastPath &BasePath, bool IgnoreBaseAccess)
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. Just discards the imaginary component. _Complex long double -> long double.
ExprResult PerformCopyInitialization(const InitializedEntity &Entity, SourceLocation EqualLoc, ExprResult Init, bool TopLevelOfInitList=false, bool AllowExplicit=false)
void DiagnoseAmbiguousConversion(Sema &S, SourceLocation CaretLoc, const PartialDiagnostic &PDiag) const
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)
ExprResult BuildExpressionTrait(ExpressionTrait OET, SourceLocation KWLoc, Expr *Queried, SourceLocation RParen)
Represents a delete expression for memory deallocation and destructor calls, e.g. "delete[] pArray"...
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)
void addCopyConstructorForExceptionObject(CXXRecordDecl *RD, CXXConstructorDecl *CD)
CXXScopeSpec SS
The nested-name-specifier that precedes the template name.
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.
Array-to-pointer conversion (C++ 4.2)
bool isStandardLayoutType() const
Test if this type is a standard-layout type. (C++0x [basic.type]p9)
QualType getExceptionObjectType(QualType T) const
bool GlobalNewDeleteDeclared
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).
StandardConversionSequence Before
Represents the standard conversion that occurs before the actual user-defined conversion.
bool isThisDeclarationADefinition() const
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.
ExprResult BuildCXXFunctionalCastExpr(TypeSourceInfo *TInfo, SourceLocation LParenLoc, Expr *CastExpr, SourceLocation RParenLoc)
IdentifierResolver IdResolver
bool isSingleResult() const
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)
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
ExprResult DefaultFunctionArrayConversion(Expr *E)
DefaultFunctionArrayConversion (C99 6.3.2.1p3, C99 6.3.2.1p4).
FieldDecl * getMember() const
If this is a member initializer, returns the declaration of the non-static data member being initiali...
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.
enum clang::DeclaratorChunk::@184 Kind
[ARC] Reclaim a retainable object pointer object that may have been produced and autoreleased as part...
Expr * IgnoreParenImpCasts() LLVM_READONLY
bool isRValueReferenceType() const
llvm::MapVector< FieldDecl *, DeleteLocs > DeleteExprs
QualType getNonReferenceType() const
FunctionDecl * ConversionFunction
ExprResult IgnoredValueConversions(Expr *E)
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. getFoundDecl() will return this declara...
bool empty() const
Return true if no decls were found.
static void DiagnoseMismatchedNewDelete(Sema &SemaRef, SourceLocation DeleteLoc, const MismatchingNewDeleteDetector &Detector)
StmtResult ActOnFinishFullStmt(Stmt *Stmt)
NamedDecl * getCorrectionDecl() const
Gets the pointer to the declaration of the typo correction.
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)
bool isTriviallyCopyableType(ASTContext &Context) const
SourceManager & getSourceManager() const
The lookup is a reference to this name that is not for the purpose of redeclaring the name...
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)
SourceLocation getLocStart() const LLVM_READONLY
bool isFunctionType() const
QualType BuildDecltypeType(Expr *E, SourceLocation Loc, bool AsUnevaluated=true)
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)
Converts from a floating complex to an integral complex. _Complex float -> _Complex int...
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
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
ExprResult BuildCXXConstructExpr(SourceLocation ConstructLoc, QualType DeclInitType, CXXConstructorDecl *Constructor, MultiExprArg Exprs, bool HadMultipleCandidates, bool IsListInitialization, bool IsStdInitListInitialization, bool RequiresZeroInit, unsigned ConstructKind, SourceRange ParenRange)
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)
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
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
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)
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.
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)
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
Optional< sema::TemplateDeductionInfo * > isSFINAEContext() const
Determines whether we are currently in a context where template argument substitution failures are no...
static CXXTemporary * Create(const ASTContext &C, const CXXDestructorDecl *Destructor)
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)
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...
ARCConversionResult CheckObjCARCConversion(SourceRange castRange, QualType castType, Expr *&op, CheckedConversionKind CCK, bool DiagnoseCFAudited=false, BinaryOperatorKind Opc=BO_PtrMemD)
Checks for invalid conversions and casts between retainable pointers and other pointer kinds...
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.
Defines the clang::TargetInfo interface.
QualType CheckVectorOperands(ExprResult &LHS, ExprResult &RHS, SourceLocation Loc, bool IsCompAssign, bool AllowBothBool, bool AllowBoolConversion)
type checking for vector binary operators.
static bool hasAnyTypeDependentArguments(ArrayRef< Expr * > Exprs)
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)
bool isValid() const
A scope specifier is present, and it refers to a real scope.
A reference to a declared variable, function, enum, etc. [C99 6.5.1p2].
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
Represents a type template specialization; the template must be a class template, a type alias templa...
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
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()
const DeclaratorChunk & getTypeObject(unsigned i) const
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 ...
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)
bool isArithmeticType() const
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...
No keyword precedes the qualified type name.
bool isSignedIntegerType() const
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
isNull - Return true if this QualType doesn't point to a type yet.
bool isPolymorphic() const
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.
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.
This scope corresponds to an Objective-C method body. It always has FnScope and DeclScope set as well...
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)
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)
TypeSourceInfo * GetTypeForDeclarator(Declarator &D, Scope *S)
bool isIntegerType() const
ParsedTemplateTy Template
const RecordDecl * getParent() const
Helper class that creates diagnostics with optional template instantiation stacks.
const DeclSpec & getDeclSpec() const
Expr * IgnoreParens() LLVM_READONLY
bool hasInClassInitializer() const
bool isPointerType() const
Structure used to store a statement, the constant value to which it was evaluated (if any)...
OverloadedOperatorKind getOverloadedOperator() const