46 #include "llvm/ADT/SmallString.h"
47 #include "llvm/ADT/Triple.h"
51 using namespace clang;
56 Decl *Group[2] = { OwnedType, Ptr };
67 TypeNameValidatorCCC(
bool AllowInvalid,
bool WantClass=
false,
68 bool AllowTemplates=
false)
69 : AllowInvalidDecl(AllowInvalid), WantClassName(WantClass),
70 AllowClassTemplates(AllowTemplates) {
71 WantExpressionKeywords =
false;
72 WantCXXNamedCasts =
false;
73 WantRemainingKeywords =
false;
78 bool IsType = isa<TypeDecl>(ND) || isa<ObjCInterfaceDecl>(ND);
79 bool AllowedTemplate = AllowClassTemplates && isa<ClassTemplateDecl>(ND);
80 return (IsType || AllowedTemplate) &&
81 (AllowInvalidDecl || !ND->isInvalidDecl());
83 return !WantClassName && candidate.
isKeyword();
87 bool AllowInvalidDecl;
89 bool AllowClassTemplates;
101 case tok::kw___int64:
102 case tok::kw___int128:
104 case tok::kw_unsigned:
111 case tok::kw_wchar_t:
113 case tok::kw___underlying_type:
116 case tok::annot_typename:
117 case tok::kw_char16_t:
118 case tok::kw_char32_t:
120 case tok::annot_decltype:
121 case tok::kw_decltype:
122 return getLangOpts().CPlusPlus;
148 return UnqualifiedTypeNameLookupResult::NotFound;
151 UnqualifiedTypeNameLookupResult::NotFound;
154 if (
auto *BaseTT =
Base.getType()->getAs<
TagType>())
155 BaseRD = BaseTT->getAsCXXRecordDecl();
159 if (!TST || !TST->isDependentType())
161 auto *TD = TST->getTemplateName().getAsTemplateDecl();
164 auto *BasePrimaryTemplate =
165 dyn_cast_or_null<CXXRecordDecl>(TD->getTemplatedDecl());
166 if (!BasePrimaryTemplate)
168 BaseRD = BasePrimaryTemplate;
172 if (!isa<TypeDecl>(ND))
173 return UnqualifiedTypeNameLookupResult::FoundNonType;
174 FoundTypeDecl = UnqualifiedTypeNameLookupResult::FoundType;
176 if (FoundTypeDecl == UnqualifiedTypeNameLookupResult::NotFound) {
178 case UnqualifiedTypeNameLookupResult::FoundNonType:
179 return UnqualifiedTypeNameLookupResult::FoundNonType;
180 case UnqualifiedTypeNameLookupResult::FoundType:
181 FoundTypeDecl = UnqualifiedTypeNameLookupResult::FoundType;
183 case UnqualifiedTypeNameLookupResult::NotFound:
190 return FoundTypeDecl;
199 UnqualifiedTypeNameLookupResult::NotFound;
201 DC && FoundTypeDecl == UnqualifiedTypeNameLookupResult::NotFound;
202 DC = DC->getParent()) {
209 if (FoundTypeDecl != UnqualifiedTypeNameLookupResult::FoundType)
215 S.
Diag(NameLoc, diag::ext_found_via_dependent_bases_lookup) << &II;
243 bool isClassName,
bool HasTrailingDot,
245 bool IsCtorOrDtorName,
246 bool WantNontrivialTypeSourceInfo,
253 LookupCtx = computeDeclContext(ObjectType);
255 LookupCtx = computeDeclContext(*SS,
false);
258 if (isDependentScopeSpecifier(*SS)) {
268 if (!isClassName && !IsCtorOrDtorName)
273 if (WantNontrivialTypeSourceInfo)
274 return ActOnTypenameType(S,
SourceLocation(), *SS, II, NameLoc).get();
286 RequireCompleteDeclContext(*SS, LookupCtx))
300 LookupQualifiedName(Result, LookupCtx);
302 if (ObjectTypePtr && Result.
empty()) {
309 LookupName(Result, S);
313 LookupName(Result, S);
317 if (Result.
empty() && getLangOpts().MSVCCompat && (!SS || SS->
isEmpty())) {
331 llvm::make_unique<TypeNameValidatorCCC>(
true, isClassName),
335 bool MemberOfUnknownSpecialization;
344 if (Correction && (NNS || NewII != &II) &&
349 isTemplateName(S, *NewSSPtr,
false, TemplateName,
ParsedType(),
350 false, Template, MemberOfUnknownSpecialization))) {
352 isClassName, HasTrailingDot, ObjectTypePtr,
354 WantNontrivialTypeSourceInfo);
356 diagnoseTypo(Correction,
357 PDiag(diag::err_unknown_type_or_class_name_suggest)
361 *CorrectedII = NewII;
385 Res != ResEnd; ++Res) {
386 if (isa<TypeDecl>(*Res) || isa<ObjCInterfaceDecl>(*Res)) {
416 assert(IIDecl &&
"Didn't find decl");
419 if (
TypeDecl *TD = dyn_cast<TypeDecl>(IIDecl)) {
420 DiagnoseUseOfDecl(IIDecl, NameLoc);
423 MarkAnyDeclReferenced(TD->getLocation(), TD,
false);
428 if (SS && SS->
isNotEmpty() && !IsCtorOrDtorName) {
429 if (WantNontrivialTypeSourceInfo) {
434 T = getElaboratedType(
ETK_None, *SS, T);
440 T = getElaboratedType(
ETK_None, *SS, T);
444 (void)DiagnoseUseOfDecl(IDecl, NameLoc);
463 if (ND && !ND->isInline() && !ND->isAnonymousNamespace())
465 else if (
auto *RD = dyn_cast<CXXRecordDecl>(DC))
467 RD->getTypeForDecl());
468 else if (isa<TranslationUnitDecl>(DC))
471 llvm_unreachable(
"something isn't in TU scope?");
478 Diag(NameLoc, diag::ext_ms_delayed_template_argument) << &II;
509 LookupName(R, S,
false);
513 switch (TD->getTagKind()) {
540 if (CurContext->isRecord()) {
560 bool AllowClassTemplates) {
568 llvm::make_unique<TypeNameValidatorCCC>(
569 false,
false, AllowClassTemplates),
570 CTK_ErrorRecovery)) {
571 if (Corrected.isKeyword()) {
573 diagnoseTypo(Corrected, PDiag(diag::err_unknown_typename_suggest) << II);
574 II = Corrected.getCorrectionAsIdentifierInfo();
577 if (!SS || !SS->
isSet()) {
578 diagnoseTypo(Corrected,
579 PDiag(diag::err_unknown_typename_suggest) << II);
580 }
else if (
DeclContext *DC = computeDeclContext(*SS,
false)) {
581 std::string CorrectedStr(Corrected.getAsString(getLangOpts()));
582 bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
583 II->
getName().equals(CorrectedStr);
584 diagnoseTypo(Corrected,
585 PDiag(diag::err_unknown_nested_typename_suggest)
586 << II << DC << DroppedSpecifier << SS->
getRange());
588 llvm_unreachable(
"could not have corrected a typo here");
592 if (Corrected.getCorrectionSpecifier())
595 SuggestedType =
getTypeName(*Corrected.getCorrectionAsIdentifierInfo(),
596 IILoc,
S, tmpSS.
isSet() ? &tmpSS : SS,
false,
604 if (getLangOpts().CPlusPlus) {
610 bool MemberOfUnknownSpecialization;
611 if (isTemplateName(S, SS ? *SS : EmptySS,
false,
615 Diag(IILoc, diag::err_template_missing_args) << TplName;
617 Diag(TplDecl->getLocation(), diag::note_template_decl_here)
618 << TplDecl->getTemplateParameters()->getSourceRange();
628 Diag(IILoc, diag::err_unknown_typename) << II;
629 else if (
DeclContext *DC = computeDeclContext(*SS,
false))
630 Diag(IILoc, diag::err_typename_nested_not_found)
632 else if (isDependentScopeSpecifier(*SS)) {
633 unsigned DiagID = diag::err_typename_missing;
634 if (getLangOpts().MSVCCompat && isMicrosoftMissingTypename(SS, S))
635 DiagID = diag::ext_typename_missing;
642 *SS, *II, IILoc).
get();
645 "Invalid scope specifier has already been diagnosed");
653 NextToken.
is(tok::less);
656 if (isa<TypeDecl>(*I) || isa<ObjCInterfaceDecl>(*I))
659 if (CheckTemplate && isa<TemplateDecl>(*I))
673 StringRef FixItTagName;
674 switch (Tag->getTagKind()) {
676 FixItTagName =
"class ";
680 FixItTagName =
"enum ";
684 FixItTagName =
"struct ";
688 FixItTagName =
"__interface ";
692 FixItTagName =
"union ";
696 StringRef TagName = FixItTagName.drop_back();
697 SemaRef.
Diag(NameLoc, diag::err_use_of_tag_name_without_tag)
698 << Name << TagName << SemaRef.
getLangOpts().CPlusPlus
703 SemaRef.
Diag((*I)->getLocation(), diag::note_decl_hiding_tag_type)
733 bool IsAddressOfOperand,
734 std::unique_ptr<CorrectionCandidateCallback> CCC) {
738 if (NextToken.
is(tok::coloncolon)) {
739 BuildCXXNestedNameSpecifier(S, *Name, NameLoc, NextToken.
getLocation(),
740 QualType(),
false, SS,
nullptr,
false);
744 LookupParsedName(Result, S, &SS, !CurMethod);
748 if (Result.
empty() && SS.
isEmpty() && getLangOpts().MSVCCompat) {
759 ExprResult E = LookupInObjCMethod(Result, S, Name,
true);
764 bool SecondTry =
false;
765 bool IsFilteredTemplateName =
false;
772 if (!SS.
isSet() && NextToken.
is(tok::l_paren)) {
775 if (getLangOpts().CPlusPlus)
776 return BuildDeclarationNameExpr(SS, Result,
true);
790 if (
NamedDecl *D = ImplicitlyDefineFunction(NameLoc, *Name, S)) {
793 return BuildDeclarationNameExpr(SS, Result,
false);
800 if (!getLangOpts().
CPlusPlus && !SecondTry &&
807 if (!SecondTry && CCC) {
812 CTK_ErrorRecovery)) {
813 unsigned UnqualifiedDiag = diag::err_undeclared_var_use_suggest;
814 unsigned QualifiedDiag = diag::err_no_member_suggest;
816 NamedDecl *FirstDecl = Corrected.getCorrectionDecl();
819 if (getLangOpts().
CPlusPlus && NextToken.
is(tok::less) &&
820 UnderlyingFirstDecl && isa<TemplateDecl>(UnderlyingFirstDecl)) {
821 UnqualifiedDiag = diag::err_no_template_suggest;
822 QualifiedDiag = diag::err_no_member_template_suggest;
823 }
else if (UnderlyingFirstDecl &&
824 (isa<TypeDecl>(UnderlyingFirstDecl) ||
825 isa<ObjCInterfaceDecl>(UnderlyingFirstDecl) ||
826 isa<ObjCCompatibleAliasDecl>(UnderlyingFirstDecl))) {
827 UnqualifiedDiag = diag::err_unknown_typename_suggest;
828 QualifiedDiag = diag::err_unknown_nested_typename_suggest;
832 diagnoseTypo(Corrected, PDiag(UnqualifiedDiag) << Name);
834 std::string CorrectedStr(Corrected.getAsString(getLangOpts()));
835 bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
836 Name->
getName().equals(CorrectedStr);
837 diagnoseTypo(Corrected, PDiag(QualifiedDiag)
838 << Name << computeDeclContext(SS,
false)
839 << DroppedSpecifier << SS.getRange());
843 Name = Corrected.getCorrectionAsIdentifierInfo();
846 if (Corrected.isKeyword())
862 ExprResult E(LookupInObjCMethod(Result, S, Ivar->getIdentifier()));
890 NameInfo, IsAddressOfOperand,
900 if (getLangOpts().
CPlusPlus && NextToken.
is(tok::less) &&
901 hasAnyAcceptableTemplateNames(Result)) {
913 FilterAcceptableTemplateNames(Result);
915 IsFilteredTemplateName =
true;
924 if (getLangOpts().
CPlusPlus && NextToken.
is(tok::less) &&
925 (IsFilteredTemplateName || hasAnyAcceptableTemplateNames(Result))) {
932 if (!IsFilteredTemplateName)
933 FilterAcceptableTemplateNames(Result);
935 if (!Result.
empty()) {
936 bool IsFunctionTemplate;
939 if (Result.
end() - Result.
begin() > 1) {
940 IsFunctionTemplate =
true;
945 = cast<TemplateDecl>((*Result.
begin())->getUnderlyingDecl());
946 IsFunctionTemplate = isa<FunctionTemplateDecl>(TD);
947 IsVarTemplate = isa<VarTemplateDecl>(TD);
957 if (IsFunctionTemplate) {
963 return NameClassification::FunctionTemplate(Template);
966 return IsVarTemplate ? NameClassification::VarTemplate(Template)
967 : NameClassification::TypeTemplate(Template);
973 DiagnoseUseOfDecl(
Type, NameLoc);
974 MarkAnyDeclReferenced(
Type->getLocation(),
Type,
false);
985 dyn_cast<ObjCCompatibleAliasDecl>(FirstDecl))
986 Class = Alias->getClassInterface();
990 DiagnoseUseOfDecl(Class, NameLoc);
992 if (NextToken.
is(tok::period)) {
1004 if (isa<TemplateDecl>(FirstDecl) && !isa<FunctionTemplateDecl>(FirstDecl))
1005 return NameClassification::TypeTemplate(
1010 bool NextIsOp = NextToken.
isOneOf(tok::amp, tok::star);
1011 if ((NextToken.
is(tok::identifier) ||
1016 DiagnoseUseOfDecl(Type, NameLoc);
1024 return BuildPossibleImplicitMemberExpr(SS,
SourceLocation(), Result,
1027 bool ADL = UseArgumentDependentLookup(SS, Result, NextToken.
is(tok::l_paren));
1028 return BuildDeclarationNameExpr(SS, Result, ADL);
1053 if (!isa<CXXRecordDecl>(DC))
1071 assert(getContainingDC(DC) == CurContext &&
1072 "The next DeclContext should be lexically contained in the current one.");
1078 assert(CurContext &&
"DeclContext imbalance!");
1080 CurContext = getContainingDC(CurContext);
1081 assert(CurContext &&
"Popped translation unit!");
1091 assert(CurContext &&
"skipping definition of undefined tag");
1097 CurContext =
static_cast<decltype(CurContext)
>(
Context);
1120 assert(!S->
getEntity() &&
"scope already has entity");
1124 while (!Ancestor->getEntity()) Ancestor = Ancestor->
getParent();
1125 assert(Ancestor->getEntity() == CurContext &&
"ancestor context mismatch");
1133 assert(S->
getEntity() == CurContext &&
"Context imbalance!");
1138 while (!Ancestor->getEntity()) Ancestor = Ancestor->
getParent();
1156 "The next DeclContext should be lexically contained in the current one.");
1160 for (
unsigned P = 0, NumParams = FD->
getNumParams();
P < NumParams; ++
P) {
1165 IdResolver.AddDecl(Param);
1174 assert(CurContext &&
"DeclContext imbalance!");
1175 CurContext = CurContext->getLexicalParent();
1176 assert(CurContext &&
"Popped translation unit!");
1213 CurContext->addDecl(D);
1224 if (isa<FunctionDecl>(D) &&
1225 cast<FunctionDecl>(D)->isFunctionTemplateSpecialization())
1230 IEnd = IdResolver.end();
1231 for (; I != IEnd; ++I) {
1234 IdResolver.RemoveDecl(*I);
1243 if (isa<LabelDecl>(D) && !cast<LabelDecl>(D)->isGnuLocal()) {
1247 for (I = IdResolver.begin(D->
getDeclName()); I != IEnd; ++I) {
1249 if (IDC == CurContext) {
1252 }
else if (IDC->
Encloses(CurContext))
1256 IdResolver.InsertDeclAfter(I, D);
1258 IdResolver.AddDecl(D);
1263 if (IdResolver.tryAddTopLevelDecl(D, Name) && TUScope)
1264 TUScope->AddDecl(D);
1268 bool AllowInlineNamespace) {
1269 return IdResolver.isDeclInScope(D, Ctx, S, AllowInlineNamespace);
1276 if (ScopeDC->getPrimaryContext() == TargetDC)
1290 bool ConsiderLinkage,
1291 bool AllowInlineNamespace) {
1296 if (isDeclInScope(D, Ctx, S, AllowInlineNamespace))
1309 return isa<UsingShadowDecl>(D) ||
1310 isa<UnresolvedUsingTypenameDecl>(D) ||
1311 isa<UnresolvedUsingValueDecl>(D);
1338 return CD->isCopyConstructor();
1339 if (
const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(D))
1340 return Method->isCopyAssignmentOperator();
1356 bool Sema::mightHaveNonExternalLinkage(
const DeclaratorDecl *D) {
1359 if (
const RecordDecl *RD = dyn_cast<RecordDecl>(DC)){
1360 if (!RD->hasNameForLinkage())
1389 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
1393 if (
const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD)) {
1398 if (FD->isInlined() && !
isMainFileLoc(*
this, FD->getLocation()))
1402 if (FD->doesThisDeclarationHaveABody() &&
1405 }
else if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
1415 if (VD->isStaticDataMember() &&
1425 return mightHaveNonExternalLinkage(D);
1432 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
1434 if (FD != First && ShouldWarnIfUnusedFileScopedDecl(First))
1438 if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
1440 if (VD != First && ShouldWarnIfUnusedFileScopedDecl(First))
1444 if (ShouldWarnIfUnusedFileScopedDecl(D))
1445 UnusedFileScopedDecls.push_back(D);
1453 D->
hasAttr<ObjCPreciseLifetimeAttr>())
1456 if (isa<LabelDecl>(D))
1462 if (
const auto *R = dyn_cast<CXXRecordDecl>(D->
getDeclContext()))
1465 WithinFunction || (R->isLocalClass() && !R->isDependentType());
1466 if (!WithinFunction)
1469 if (isa<TypedefNameDecl>(D))
1473 if (!isa<VarDecl>(D) || isa<ParmVarDecl>(D) || isa<ImplicitParamDecl>(D))
1477 if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
1484 if (TT->getDecl()->hasAttr<UnusedAttr>())
1494 const TagDecl *Tag = TT->getDecl();
1495 if (Tag->
hasAttr<UnusedAttr>())
1498 if (
const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(Tag)) {
1499 if (!RD->hasTrivialDestructor() && !RD->hasAttr<WarnUnusedAttr>())
1502 if (
const Expr *Init = VD->getInit()) {
1504 dyn_cast<ExprWithCleanups>(Init))
1505 Init = Cleanups->getSubExpr();
1510 if (!CD->
isTrivial() && !RD->hasAttr<WarnUnusedAttr>())
1525 if (isa<LabelDecl>(D)) {
1540 for (
auto *TmpD : D->
decls()) {
1541 if (
const auto *T = dyn_cast<TypedefNameDecl>(TmpD))
1542 DiagnoseUnusedDecl(T);
1543 else if(
const auto *R = dyn_cast<RecordDecl>(TmpD))
1544 DiagnoseUnusedNestedTypedefs(R);
1554 if (
auto *TD = dyn_cast<TypedefNameDecl>(D)) {
1557 UnusedLocalTypedefNameCandidates.insert(TD);
1565 if (isa<VarDecl>(D) && cast<VarDecl>(D)->isExceptionVariable())
1566 DiagID = diag::warn_unused_exception_param;
1567 else if (isa<LabelDecl>(D))
1568 DiagID = diag::warn_unused_label;
1570 DiagID = diag::warn_unused_variable;
1580 bool Diagnose =
false;
1584 Diagnose = L->
getStmt() ==
nullptr;
1594 "Scope shouldn't contain decls!");
1596 for (
auto *TmpD : S->
decls()) {
1597 assert(TmpD &&
"This decl didn't get pushed??");
1599 assert(isa<NamedDecl>(TmpD) &&
"Decl isn't NamedDecl?");
1606 DiagnoseUnusedDecl(D);
1607 if (
const auto *RD = dyn_cast<RecordDecl>(D))
1608 DiagnoseUnusedNestedTypedefs(RD);
1612 if (
LabelDecl *LD = dyn_cast<LabelDecl>(D))
1616 IdResolver.RemoveDecl(D);
1635 bool DoTypoCorrection) {
1638 NamedDecl *IDecl = LookupSingleName(TUScope, Id, IdLoc, LookupOrdinaryName);
1640 if (!IDecl && DoTypoCorrection) {
1646 CTK_ErrorRecovery)) {
1647 diagnoseTypo(
C, PDiag(diag::err_undef_interface_suggest) << Id);
1696 if (!II->
isStr(
"objc_msgSendSuper"))
1717 return "ucontext.h";
1719 llvm_unreachable(
"unhandled error kind");
1727 Scope *
S,
bool ForRedeclaration,
1734 if (ForRedeclaration)
1735 Diag(Loc, diag::warn_implicit_decl_requires_sysheader)
1742 Diag(Loc, diag::ext_implicit_lib_function_decl)
1746 !Diags.isIgnored(diag::ext_implicit_lib_function_decl, Loc))
1747 Diag(Loc, diag::note_include_header_or_declare)
1758 Parent->
addDecl(CLinkageDecl);
1759 Parent = CLinkageDecl;
1764 Loc, Loc, II, R,
nullptr,
1774 for (
unsigned i = 0, e = FT->getNumParams(); i != e; ++i) {
1777 nullptr, FT->getParamType(i),
nullptr,
1780 Params.push_back(parm);
1782 New->setParams(Params);
1785 AddKnownFunctionAttributes(New);
1786 RegisterLocallyScopedExternCDecl(New, S);
1793 CurContext = Parent;
1794 PushOnScopeChains(New, TUScope);
1795 CurContext = SavedContext;
1812 if (previous.
empty())
1842 if (Previous.
empty())
1855 if (
auto *OldTD = dyn_cast<TypedefNameDecl>(Old)) {
1862 if (OldTD->getAnonDeclWithTypedefName(
true) &&
1877 OldType = OldTypedef->getUnderlyingType();
1884 int Kind = isa<TypeAliasDecl>(Old) ? 1 : 0;
1885 Diag(New->
getLocation(), diag::err_redefinition_variably_modified_typedef)
1893 if (OldType != NewType &&
1897 int Kind = isa<TypeAliasDecl>(Old) ? 1 : 0;
1899 << Kind << NewType << OldType;
1920 if (getLangOpts().ObjC1) {
1926 if (!TypeID->
isStr(
"id"))
1942 if (!TypeID->
isStr(
"Class"))
1949 if (!TypeID->
isStr(
"SEL"))
1976 if (
auto *OldTD = dyn_cast<TypedefNameDecl>(Old)) {
1977 auto *OldTag = OldTD->getAnonDeclWithTypedefName(
true);
1980 if (getLangOpts().
CPlusPlus && OldTag && NewTag &&
1981 OldTag->getCanonicalDecl() != NewTag->getCanonicalDecl() &&
1982 !hasVisibleDefinition(OldTag, &Hidden)) {
1986 if (OldTD->isModed())
1988 OldTD->getUnderlyingType());
1993 makeMergedDefinitionVisible(Hidden, NewTag->
getLocation());
1999 if (isIncompatibleTypedef(Old, New))
2006 mergeDeclAttributes(New, Old);
2009 if (getLangOpts().MicrosoftExt)
2017 if (!isa<CXXRecordDecl>(CurContext))
2041 if (!isa<TypedefNameDecl>(Old))
2051 if (getLangOpts().Modules || getLangOpts().
C11)
2058 if (getDiagnostics().getSuppressSystemWarnings() &&
2071 const OwnershipAttr *OA = dyn_cast<OwnershipAttr>(A);
2072 const AnnotateAttr *Ann = dyn_cast<AnnotateAttr>(A);
2073 for (
const auto *i : D->
attrs())
2074 if (i->getKind() == A->
getKind()) {
2076 if (Ann->getAnnotation() == cast<AnnotateAttr>(i)->getAnnotation())
2081 if (OA && isa<OwnershipAttr>(i))
2082 return OA->getOwnKind() == cast<OwnershipAttr>(i)->getOwnKind();
2090 if (
VarDecl *VD = dyn_cast<VarDecl>(D))
2091 return VD->isThisDeclarationADefinition();
2092 if (
TagDecl *TD = dyn_cast<TagDecl>(D))
2093 return TD->isCompleteDefinition() || TD->isBeingDefined();
2104 AlignedAttr *OldAlignasAttr =
nullptr;
2105 AlignedAttr *OldStrictestAlignAttr =
nullptr;
2106 unsigned OldAlign = 0;
2114 if (I->isAlignmentDependent())
2120 unsigned Align = I->getAlignment(S.
Context);
2121 if (Align > OldAlign) {
2123 OldStrictestAlignAttr = I;
2128 AlignedAttr *NewAlignasAttr =
nullptr;
2129 unsigned NewAlign = 0;
2131 if (I->isAlignmentDependent())
2137 unsigned Align = I->getAlignment(S.
Context);
2138 if (Align > NewAlign)
2142 if (OldAlignasAttr && NewAlignasAttr && OldAlign != NewAlign) {
2150 if (OldAlign == 0 || NewAlign == 0) {
2152 if (
ValueDecl *VD = dyn_cast<ValueDecl>(New))
2163 if (OldAlign != NewAlign) {
2164 S.
Diag(NewAlignasAttr->getLocation(), diag::err_alignas_mismatch)
2167 S.
Diag(OldAlignasAttr->getLocation(), diag::note_previous_declaration);
2182 S.
Diag(OldAlignasAttr->getLocation(), diag::note_alignas_on_declaration)
2186 bool AnyAdded =
false;
2189 if (OldAlign > NewAlign) {
2190 AlignedAttr *Clone = OldStrictestAlignAttr->clone(S.
Context);
2191 Clone->setInherited(
true);
2197 if (OldAlignasAttr && !NewAlignasAttr &&
2198 !(AnyAdded && OldStrictestAlignAttr->isAlignas())) {
2199 AlignedAttr *Clone = OldAlignasAttr->clone(S.
Context);
2200 Clone->setInherited(
true);
2212 if (
const auto *AA = dyn_cast<AvailabilityAttr>(Attr))
2214 AA->getIntroduced(), AA->getDeprecated(),
2215 AA->getObsoleted(), AA->getUnavailable(),
2216 AA->getMessage(), Override,
2217 AttrSpellingListIndex);
2218 else if (
const auto *VA = dyn_cast<VisibilityAttr>(Attr))
2220 AttrSpellingListIndex);
2221 else if (
const auto *VA = dyn_cast<TypeVisibilityAttr>(Attr))
2223 AttrSpellingListIndex);
2224 else if (
const auto *ImportA = dyn_cast<DLLImportAttr>(Attr))
2226 AttrSpellingListIndex);
2227 else if (
const auto *ExportA = dyn_cast<DLLExportAttr>(Attr))
2229 AttrSpellingListIndex);
2230 else if (
const auto *FA = dyn_cast<FormatAttr>(Attr))
2232 FA->getFormatIdx(), FA->getFirstArg(),
2233 AttrSpellingListIndex);
2234 else if (
const auto *SA = dyn_cast<SectionAttr>(Attr))
2236 AttrSpellingListIndex);
2237 else if (
const auto *IA = dyn_cast<MSInheritanceAttr>(Attr))
2239 AttrSpellingListIndex,
2240 IA->getSemanticSpelling());
2241 else if (
const auto *AA = dyn_cast<AlwaysInlineAttr>(Attr))
2244 AttrSpellingListIndex);
2245 else if (
const auto *MA = dyn_cast<MinSizeAttr>(Attr))
2247 else if (
const auto *OA = dyn_cast<OptimizeNoneAttr>(Attr))
2249 else if (isa<AlignedAttr>(Attr))
2253 else if (isa<DeprecatedAttr>(Attr) && Override)
2256 NewAttr = cast<InheritableAttr>(Attr->
clone(S.
Context));
2268 if (
const TagDecl *TD = dyn_cast<TagDecl>(D))
2269 return TD->getDefinition();
2270 if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
2276 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
2278 if (FD->isDefined(Def))
2285 for (
const auto *Attribute : D->
attrs())
2286 if (Attribute->getKind() ==
Kind)
2298 if (!Def || Def == New)
2302 for (
unsigned I = 0, E = NewAttributes.size(); I != E;) {
2303 const Attr *NewAttribute = NewAttributes[I];
2305 if (isa<AliasAttr>(NewAttribute)) {
2309 VarDecl *VD = cast<VarDecl>(New);
2310 unsigned Diag = cast<VarDecl>(Def)->isThisDeclarationADefinition() ==
2312 ? diag::err_alias_after_tentative
2313 : diag::err_redefinition;
2322 if (
const VarDecl *VD = dyn_cast<VarDecl>(Def)) {
2335 if (isa<C11NoReturnAttr>(NewAttribute)) {
2339 }
else if (
const AlignedAttr *AA = dyn_cast<AlignedAttr>(NewAttribute)) {
2340 if (AA->isAlignas()) {
2351 S.
Diag(NewAttribute->
getLocation(), diag::note_alignas_on_declaration)
2353 NewAttributes.erase(NewAttributes.begin() + I);
2360 diag::warn_attribute_precede_definition);
2362 NewAttributes.erase(NewAttributes.begin() + I);
2371 UsedAttr *NewAttr = OldAttr->clone(
Context);
2372 NewAttr->setInherited(
true);
2392 bool Override =
false;
2394 if (isa<DeprecatedAttr>(I) ||
2395 isa<UnavailableAttr>(I) ||
2396 isa<AvailabilityAttr>(I)) {
2401 case AMK_Redeclaration:
2411 if (isa<UsedAttr>(I))
2433 const CarriesDependencyAttr *CDA = newDecl->
getAttr<CarriesDependencyAttr>();
2434 if (CDA && !oldDecl->
hasAttr<CarriesDependencyAttr>()) {
2435 S.
Diag(CDA->getLocation(),
2436 diag::err_carries_dependency_missing_on_first_decl) << 1;
2444 diag::note_carries_dependency_missing_first_decl) << 1;
2450 bool foundAny = newDecl->
hasAttrs();
2459 cast<InheritableParamAttr>(I->clone(S.
Context));
2474 if (*Oldnullability != *Newnullability) {
2475 S.
Diag(NewParam->
getLocation(), diag::warn_mismatched_nullability_attr)
2500 struct GNUCompatibleParamWarning {
2511 if (Ctor->isDefaultConstructor())
2514 if (Ctor->isCopyConstructor())
2517 if (Ctor->isMoveConstructor())
2519 }
else if (isa<CXXDestructorDecl>(MD)) {
2532 template <
typename T>
2533 static std::pair<diag::kind, SourceLocation>
2537 if (Old->isThisDeclarationADefinition())
2538 PrevDiag = diag::note_previous_definition;
2539 else if (Old->isImplicit()) {
2540 PrevDiag = diag::note_previous_implicit_declaration;
2542 OldLocation = New->getLocation();
2544 PrevDiag = diag::note_previous_declaration;
2545 return std::make_pair(PrevDiag, OldLocation);
2553 return ((FD->
hasAttr<GNUInlineAttr>() || LangOpts.GNUInline) &&
2554 !LangOpts.CPlusPlus &&
2566 template <
typename T>
2580 template<
typename T>
static bool isExternC(T *D) {
return D->isExternC(); }
2586 template<
typename ExpectedDecl>
2588 ExpectedDecl *New) {
2608 !Old->getDeclContext()->getRedeclContext()->Equals(
2609 New->getDeclContext()->getRedeclContext()) &&
2614 S.
Diag(New->getLocation(), diag::err_using_decl_conflict_reverse);
2634 Scope *
S,
bool MergeTypeWithOld) {
2641 Diag(Shadow->getTargetDecl()->getLocation(),
2642 diag::note_using_decl_target);
2643 Diag(Shadow->getUsingDecl()->getLocation(),
2644 diag::note_using_decl) << 0;
2649 if (checkUsingShadowRedecl<FunctionDecl>(*
this, Shadow, New))
2651 OldD = Old = cast<FunctionDecl>(Shadow->getTargetDecl());
2666 std::tie(PrevDiag, OldLocation) =
2673 if (!isa<CXXMethodDecl>(New) && !isa<CXXMethodDecl>(Old) &&
2678 if (getLangOpts().MicrosoftExt) {
2680 Diag(OldLocation, PrevDiag);
2683 Diag(OldLocation, PrevDiag);
2704 const FunctionType *OldType = cast<FunctionType>(OldQType);
2705 const FunctionType *NewType = cast<FunctionType>(NewQType);
2708 bool RequiresAdjustment =
false;
2710 if (OldTypeInfo.getCC() != NewTypeInfo.
getCC()) {
2715 bool NewCCExplicit = getCallingConvAttributedType(New->
getType());
2716 if (!NewCCExplicit) {
2720 RequiresAdjustment =
true;
2723 bool FirstCCExplicit = getCallingConvAttributedType(First->
getType());
2727 << (!FirstCCExplicit ?
"" :
2737 if (OldTypeInfo.getNoReturn() && !NewTypeInfo.
getNoReturn()) {
2739 RequiresAdjustment =
true;
2743 if (OldTypeInfo.getHasRegParm() != NewTypeInfo.
getHasRegParm() ||
2744 OldTypeInfo.getRegParm() != NewTypeInfo.
getRegParm()) {
2747 << NewType->getRegParmType()
2749 Diag(OldLocation, diag::note_previous_declaration);
2753 NewTypeInfo = NewTypeInfo.
withRegParm(OldTypeInfo.getRegParm());
2754 RequiresAdjustment =
true;
2761 Diag(OldLocation, diag::note_previous_declaration);
2766 RequiresAdjustment =
true;
2769 if (RequiresAdjustment) {
2774 NewType = cast<FunctionType>(NewQType);
2780 !New->
hasAttr<GNUInlineAttr>() &&
2781 !getLangOpts().GNUInline &&
2789 if (New->
hasAttr<GNUInlineAttr>() &&
2794 if (getLangOpts().CPlusPlus) {
2808 : OldType)->getReturnType();
2812 : NewType)->getReturnType();
2822 Diag(New->
getLocation(), diag::err_member_def_does_not_match_ret_type)
2827 Diag(OldLocation, PrevDiag) << Old << Old->
getType()
2836 QualType NewReturnType = cast<FunctionType>(NewQType)->getReturnType();
2837 if (OldReturnType != NewReturnType) {
2847 SubstAutoType(NewQType,
2855 if (OldMethod && NewMethod) {
2862 bool IsClassScopeExplicitSpecialization =
2864 NewMethod->isFunctionTemplateSpecialization();
2865 bool isFriend = NewMethod->getFriendObjectKind();
2867 if (!isFriend && NewMethod->getLexicalDeclContext()->isRecord() &&
2868 !IsClassScopeExplicitSpecialization) {
2872 if (OldMethod->
isStatic() != NewMethod->isStatic()) {
2874 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
2882 if (ActiveTemplateInstantiations.empty()) {
2884 if (isa<CXXConstructorDecl>(OldMethod))
2885 NewDiag = diag::err_constructor_redeclared;
2886 else if (isa<CXXDestructorDecl>(NewMethod))
2887 NewDiag = diag::err_destructor_redeclared;
2888 else if (isa<CXXConversionDecl>(NewMethod))
2889 NewDiag = diag::err_conv_function_redeclared;
2891 NewDiag = diag::err_member_redeclared;
2895 Diag(New->
getLocation(), diag::err_member_redeclared_in_instantiation)
2898 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
2908 NewMethod->setImplicit();
2910 Diag(NewMethod->getLocation(),
2911 diag::err_definition_of_implicitly_declared_member)
2912 << New << getSpecialMember(OldMethod);
2916 Diag(NewMethod->getLocation(),
2917 diag::err_definition_of_explicitly_defaulted_member)
2918 << getSpecialMember(OldMethod);
2927 const CXX11NoReturnAttr *NRA = New->
getAttr<CXX11NoReturnAttr>();
2928 if (NRA && !Old->
hasAttr<CXX11NoReturnAttr>()) {
2929 Diag(NRA->getLocation(), diag::err_noreturn_missing_on_first_decl);
2931 diag::note_noreturn_missing_first_decl);
2938 const CarriesDependencyAttr *CDA = New->
getAttr<CarriesDependencyAttr>();
2939 if (CDA && !Old->
hasAttr<CarriesDependencyAttr>()) {
2940 Diag(CDA->getLocation(),
2941 diag::err_carries_dependency_missing_on_first_decl) << 0;
2943 diag::note_carries_dependency_missing_first_decl) << 0;
2952 QualType OldQTypeForComparison = OldQType;
2953 if (!OldTypeInfo.getNoReturn() && NewTypeInfo.
getNoReturn()) {
2954 assert(OldQType ==
QualType(OldType, 0));
2957 OldQTypeForComparison =
QualType(OldTypeForComparison, 0);
2972 Diag(OldLocation, PrevDiag);
2974 Diag(New->
getLocation(), diag::err_different_language_linkage) << New;
2975 Diag(OldLocation, PrevDiag);
2980 if (OldQTypeForComparison == NewQType)
2981 return MergeCompatibleFunctionDecls(New, Old, S, MergeTypeWithOld);
2996 if (!getLangOpts().CPlusPlus &&
3001 if (MergeTypeWithOld && isa<FunctionNoProtoType>(NewFuncType) &&
3005 assert(!OldProto->hasExceptionSpec() &&
"Exception spec in C");
3009 OldProto->getExtProtoInfo());
3015 for (
const auto &ParamType : OldProto->param_types()) {
3022 Params.push_back(Param);
3025 New->setParams(Params);
3028 return MergeCompatibleFunctionDecls(New, Old, S, MergeTypeWithOld);
3055 NewProto->getReturnType());
3056 bool LooseCompatible = !MergedReturn.
isNull();
3058 LooseCompatible && Idx !=
End; ++Idx) {
3062 NewProto->getParamType(Idx))) {
3063 ArgTypes.push_back(NewParm->
getType());
3067 GNUCompatibleParamWarning Warn = { OldParm, NewParm,
3068 NewProto->getParamType(Idx) };
3069 Warnings.push_back(Warn);
3070 ArgTypes.push_back(NewParm->
getType());
3072 LooseCompatible =
false;
3075 if (LooseCompatible) {
3076 for (
unsigned Warn = 0; Warn < Warnings.size(); ++Warn) {
3077 Diag(Warnings[Warn].NewParm->getLocation(),
3078 diag::ext_param_promoted_not_compatible_with_prototype)
3079 << Warnings[Warn].PromotedType
3080 << Warnings[Warn].OldParm->getType();
3081 if (Warnings[Warn].OldParm->getLocation().isValid())
3082 Diag(Warnings[Warn].OldParm->getLocation(),
3083 diag::note_previous_declaration);
3086 if (MergeTypeWithOld)
3089 return MergeCompatibleFunctionDecls(New, Old, S, MergeTypeWithOld);
3106 Diag(OldLocation, diag::note_previous_builtin_declaration)
3123 PrevDiag = diag::note_previous_builtin_declaration;
3127 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
3141 Scope *
S,
bool MergeTypeWithOld) {
3143 mergeDeclAttributes(New, Old);
3156 for (
unsigned i = 0, e = New->
getNumParams(); i != e; ++i) {
3164 return MergeCXXFunctionDecl(New, Old, S);
3170 if (!Merged.
isNull() && MergeTypeWithOld)
3182 isa<ObjCImplDecl>(newMethod->
getDeclContext()) ? AMK_Redeclaration
3184 mergeDeclAttributes(newMethod, oldMethod, MergeKind);
3191 ni != ne && oi != oe; ++ni, ++oi)
3194 CheckObjCMethodOverride(newMethod, oldMethod);
3205 bool MergeTypeWithOld) {
3210 if (getLangOpts().CPlusPlus) {
3216 return MergeVarDeclExceptionSpecs(New, Old);
3274 ? diag::err_redefinition_different_type
3275 : diag::err_redeclaration_different_type)
3280 std::tie(PrevDiag, OldLocation) =
3282 Diag(OldLocation, PrevDiag);
3288 if (MergeTypeWithOld)
3346 if (checkUsingShadowRedecl<VarTemplateDecl>(*
this, Shadow, NewTemplate))
3353 if (checkUsingShadowRedecl<VarDecl>(*
this, Shadow, New))
3361 diag::note_previous_definition);
3365 if (!shouldLinkPossiblyHiddenDecl(Old, New))
3372 true, TPL_TemplateMatch))
3386 mergeDeclAttributes(New, Old);
3389 if (New->
hasAttr<WeakImportAttr>() &&
3391 !Old->
hasAttr<WeakImportAttr>()) {
3400 if (MostRecent != Old) {
3401 MergeVarDeclTypes(New, MostRecent,
3413 std::tie(PrevDiag, OldLocation) =
3420 if (getLangOpts().MicrosoftExt) {
3423 Diag(OldLocation, PrevDiag);
3427 Diag(OldLocation, PrevDiag);
3446 Diag(OldLocation, PrevDiag);
3454 Diag(OldLocation, PrevDiag);
3460 Diag(OldLocation, PrevDiag);
3473 Diag(OldLocation, PrevDiag);
3480 Diag(OldLocation, PrevDiag);
3483 Diag(OldLocation, PrevDiag);
3491 Diag(OldLocation, PrevDiag);
3501 if (!hasVisibleDefinition(Def, &Hidden) &&
3510 Diag(Def->getLocation(), diag::note_previous_definition);
3517 Diag(New->
getLocation(), diag::err_different_language_linkage) << New;
3518 Diag(OldLocation, PrevDiag);
3561 if (isa<CXXRecordDecl>(Tag->
getParent())) {
3575 Decl *ManglingContextDecl;
3579 Tag, MCtx->getManglingNumber(
3611 tagLoc = getLocForEndOfToken(tagLoc);
3614 textToInsert +=
' ';
3616 Diag(tagLoc, diag::note_typedef_changes_linkage)
3638 llvm_unreachable(
"unexpected type specifier");
3648 bool IsExplicitInstantiation) {
3649 Decl *TagD =
nullptr;
3664 if (isa<TagDecl>(TagD))
3665 Tag = cast<TagDecl>(TagD);
3667 Tag = CTD->getTemplatedDecl();
3671 handleTagNumbering(Tag, S);
3682 diag::err_typecheck_invalid_restrict_not_pointer_noarg)
3698 DiagnoseFunctionSpecifiers(DS);
3705 return ActOnFriendTypeDecl(S, DS, TemplateParams);
3709 bool IsExplicitSpecialization =
3710 !TemplateParams.empty() && TemplateParams.back()->size() == 0;
3712 !IsExplicitInstantiation && !IsExplicitSpecialization) {
3717 Diag(SS.
getBeginLoc(), diag::err_standalone_class_nested_name_specifier)
3723 bool DeclaresAnything =
true;
3726 if (
RecordDecl *Record = dyn_cast_or_null<RecordDecl>(Tag)) {
3727 if (!Record->getDeclName() && Record->isCompleteDefinition() &&
3729 if (getLangOpts().CPlusPlus ||
3730 Record->getDeclContext()->isRecord())
3731 return BuildAnonymousStructOrUnion(S, DS, AS, Record,
3734 DeclaresAnything =
false;
3744 if (!getLangOpts().CPlusPlus && CurContext->isRecord() &&
3760 Record = RT->getDecl();
3762 Record = UT->getDecl();
3764 if (Record && getLangOpts().MicrosoftExt) {
3767 return BuildMicrosoftCAnonymousStruct(S, DS, Record);
3770 DeclaresAnything =
false;
3779 if (getLangOpts().CPlusPlus &&
3781 if (
EnumDecl *Enum = dyn_cast_or_null<EnumDecl>(Tag))
3782 if (Enum->enumerator_begin() == Enum->enumerator_end() &&
3783 !Enum->getIdentifier() && !Enum->isInvalidDecl())
3784 DeclaresAnything =
false;
3792 DeclaresAnything =
false;
3801 ActOnDocumentableDecl(TagD);
3811 if (!DeclaresAnything) {
3826 unsigned DiagID = diag::warn_standalone_specifier;
3828 DiagID = diag::ext_standalone_specifier;
3868 Diag(attrs->getLoc(), diag::warn_declspec_attribute_ignored)
3885 unsigned diagnostic) {
3895 assert(PrevDecl &&
"Expected a non-null Decl");
3900 SemaRef.
Diag(NameLoc, diagnostic) << Name;
3901 SemaRef.
Diag(PrevDecl->
getLocation(), diag::note_previous_declaration);
3927 bool MSAnonStruct) {
3929 = AnonRecord->
isUnion() ? diag::err_anonymous_union_member_redecl
3930 : diag::err_anonymous_struct_member_redecl;
3932 bool Invalid =
false;
3935 for (
auto *D : AnonRecord->
decls()) {
3936 if ((isa<FieldDecl>(D) || isa<IndirectFieldDecl>(D)) &&
3937 cast<NamedDecl>(D)->getDeclName()) {
3952 unsigned OldChainingSize = Chaining.size();
3954 Chaining.append(IF->chain_begin(), IF->chain_end());
3956 Chaining.push_back(VD);
3958 assert(Chaining.size() >= 2);
3961 for (
unsigned i = 0; i < Chaining.size(); i++)
3962 NamedChain[i] = Chaining[i];
3966 VD->
getType(), NamedChain, Chaining.size());
3978 Chaining.resize(OldChainingSize);
3993 "Parser allowed 'typedef' as storage class VarDecl.");
3994 switch (StorageClassSpec) {
4008 llvm_unreachable(
"unknown storage class specifier");
4014 for (
const auto *I : Record->
decls()) {
4015 const auto *FD = dyn_cast<
FieldDecl>(I);
4016 if (
const auto *IFD = dyn_cast<IndirectFieldDecl>(I))
4017 FD = IFD->getAnonField();
4018 if (FD && FD->hasInClassInitializer())
4022 llvm_unreachable(
"couldn't find in-class initializer");
4030 S.
Diag(DefaultInitLoc, diag::err_multiple_mem_union_initialization);
4053 if (Record->
isUnion() && !getLangOpts().CPlusPlus && !getLangOpts().C11)
4055 else if (!Record->
isUnion() && getLangOpts().CPlusPlus)
4057 else if (!Record->
isUnion() && !getLangOpts().C11)
4062 bool Invalid =
false;
4063 if (getLangOpts().CPlusPlus) {
4064 const char *PrevSpec =
nullptr;
4071 (isa<TranslationUnitDecl>(Owner) ||
4072 (isa<NamespaceDecl>(Owner) &&
4073 cast<NamespaceDecl>(Owner)->getDeclName()))) {
4079 PrevSpec, DiagID, Policy);
4085 isa<RecordDecl>(Owner)) {
4087 diag::err_anonymous_union_with_storage_spec)
4101 << Record->
isUnion() <<
"const"
4105 diag::ext_anonymous_struct_union_qualified)
4106 << Record->
isUnion() <<
"volatile"
4110 diag::ext_anonymous_struct_union_qualified)
4111 << Record->
isUnion() <<
"restrict"
4115 diag::ext_anonymous_struct_union_qualified)
4116 << Record->
isUnion() <<
"_Atomic"
4126 for (
auto *Mem : Record->
decls()) {
4127 if (
auto *FD = dyn_cast<FieldDecl>(Mem)) {
4131 assert(FD->getAccess() !=
AS_none);
4133 Diag(FD->getLocation(), diag::err_anonymous_record_nonpublic_member)
4143 if (CheckNontrivialField(FD))
4145 }
else if (Mem->isImplicit()) {
4147 }
else if (isa<TagDecl>(Mem) && Mem->getDeclContext() != Record) {
4152 }
else if (
auto *MemRecord = dyn_cast<RecordDecl>(Mem)) {
4153 if (!MemRecord->isAnonymousStructOrUnion() &&
4154 MemRecord->getDeclName()) {
4156 if (getLangOpts().MicrosoftExt)
4157 Diag(MemRecord->getLocation(), diag::ext_anonymous_record_with_type)
4161 Diag(MemRecord->getLocation(), diag::err_anonymous_record_with_type)
4169 Diag(MemRecord->getLocation(),
4170 diag::ext_anonymous_record_with_anonymous_type)
4173 }
else if (isa<AccessSpecDecl>(Mem)) {
4175 }
else if (isa<StaticAssertDecl>(Mem)) {
4180 unsigned DK = diag::err_anonymous_record_bad_member;
4181 if (isa<TypeDecl>(Mem))
4182 DK = diag::err_anonymous_record_with_type;
4183 else if (isa<FunctionDecl>(Mem))
4184 DK = diag::err_anonymous_record_with_function;
4185 else if (isa<VarDecl>(Mem))
4186 DK = diag::err_anonymous_record_with_static;
4189 if (getLangOpts().MicrosoftExt &&
4190 DK == diag::err_anonymous_record_with_type)
4191 Diag(Mem->getLocation(), diag::ext_anonymous_record_with_type)
4194 Diag(Mem->getLocation(), DK)
4204 if (cast<CXXRecordDecl>(Record)->hasInClassInitializer() &&
4207 cast<CXXRecordDecl>(Record));
4212 << (
int)getLangOpts().CPlusPlus;
4219 assert(TInfo &&
"couldn't build declarator info for anonymous struct/union");
4223 if (
RecordDecl *OwningClass = dyn_cast<RecordDecl>(Owner)) {
4234 FieldCollector->Add(cast<FieldDecl>(Anon));
4256 ActOnUninitializedDecl(Anon,
false);
4272 Chain.push_back(Anon);
4278 if (
VarDecl *NewVD = dyn_cast<VarDecl>(Anon)) {
4279 if (getLangOpts().
CPlusPlus && NewVD->isStaticLocal()) {
4280 Decl *ManglingContextDecl;
4282 NewVD->getDeclContext(), ManglingContextDecl)) {
4284 NewVD, MCtx->getManglingNumber(
4312 assert(Record &&
"expected a record!");
4317 assert(TInfo &&
"couldn't build declarator info for anonymous struct");
4319 auto *ParentDecl = cast<RecordDecl>(CurContext);
4335 CurContext->addDecl(Anon);
4341 Chain.push_back(Anon);
4344 if (RequireCompleteType(Anon->
getLocation(), RecTy,
4345 diag::err_field_incomplete) ||
4349 ParentDecl->setInvalidDecl();
4358 return GetNameFromUnqualifiedId(D.
getName());
4459 llvm_unreachable(
"Unknown name kind");
4487 for (
unsigned Idx = 0; Idx < Declaration->
param_size(); ++Idx) {
4501 (DeclTyName && DeclTyName == DefTyName))
4502 Params.push_back(Idx);
4543 if (!TSI)
return true;
4588 if (OriginalLexicalContext && OriginalLexicalContext->isObjCContainer() &&
4607 if (Record->getIdentifier() && Record->getDeclName() == Name) {
4608 Diag(NameInfo.
getLoc(), diag::err_member_name_of_class) << Name;
4632 while (isa<LinkageSpecDecl>(Cur) || isa<CapturedDecl>(Cur))
4646 Diag(Loc, LangOpts.MicrosoftExt ? diag::warn_member_extra_qualification
4647 : diag::err_member_extra_qualification)
4651 Diag(Loc, diag::warn_namespace_member_extra_qualification) << Name;
4660 Diag(Loc, diag::err_member_qualification)
4662 else if (isa<TranslationUnitDecl>(DC))
4663 Diag(Loc, diag::err_invalid_declarator_global_scope)
4665 else if (isa<FunctionDecl>(Cur))
4666 Diag(Loc, diag::err_invalid_declarator_in_function)
4668 else if (isa<BlockDecl>(Cur))
4669 Diag(Loc, diag::err_invalid_declarator_in_block)
4672 Diag(Loc, diag::err_invalid_declarator_scope)
4673 << Name << cast<NamedDecl>(Cur) << cast<NamedDecl>(DC) << SS.
getRange();
4680 Diag(Loc, diag::err_member_qualification)
4700 while (SpecLoc.getPrefix())
4702 if (dyn_cast_or_null<DecltypeType>(
4703 SpecLoc.getNestedNameSpecifier()->getAsType()))
4704 Diag(Loc, diag::err_decltype_in_declarator)
4705 << SpecLoc.getTypeLoc().getSourceRange();
4721 diag::err_declarator_need_ident)
4724 }
else if (DiagnoseUnexpandedParameterPack(NameInfo, UPPC_DeclarationType))
4738 UPPC_DeclarationQualifier))
4743 if (!DC || isa<EnumDecl>(DC)) {
4749 diag::err_template_qualified_declarator_no_match)
4756 if (!IsDependentContext &&
4761 if (isa<CXXRecordDecl>(DC) && !cast<CXXRecordDecl>(DC)->hasDefinition()) {
4763 diag::err_member_def_undefined_record)
4779 if (EnteringContext && IsDependentContext &&
4780 TemplateParamLists.size() != 0) {
4790 if (!R->
isFunctionType() && DiagnoseClassNameShadow(DC, NameInfo))
4798 UPPC_DeclarationType))
4806 bool IsLinkageLookup =
false;
4807 bool CreateBuiltins =
false;
4818 else if (CurContext->isFunctionOrMethod() &&
4821 IsLinkageLookup =
true;
4823 CurContext->getEnclosingNamespaceContext()->isTranslationUnit();
4824 }
else if (CurContext->getRedeclContext()->isTranslationUnit() &&
4826 CreateBuiltins =
true;
4828 if (IsLinkageLookup)
4829 Previous.
clear(LookupRedeclarationWithLinkage);
4831 LookupName(Previous, S, CreateBuiltins);
4833 LookupQualifiedName(Previous, DC);
4886 CheckExtraCXXDefaultArguments(D);
4890 bool AddToScope =
true;
4892 if (TemplateParamLists.size()) {
4897 New = ActOnTypedefDeclarator(S, D, DC, TInfo, Previous);
4899 New = ActOnFunctionDeclarator(S, D, DC, TInfo, Previous,
4903 New = ActOnVariableDeclarator(S, D, DC, TInfo, Previous, TemplateParamLists,
4918 PushOnScopeChains(New, S, AddToContext);
4920 CurContext->addHiddenDecl(New);
4931 bool &SizeIsNegative,
4932 llvm::APSInt &Oversized) {
4937 SizeIsNegative =
false;
4946 if (
const PointerType* PTy = dyn_cast<PointerType>(Ty)) {
4951 if (FixedType.
isNull())
return FixedType;
4953 return Qs.
apply(Context, FixedType);
4955 if (
const ParenType* PTy = dyn_cast<ParenType>(Ty)) {
4956 QualType Inner = PTy->getInnerType();
4960 if (FixedType.
isNull())
return FixedType;
4962 return Qs.
apply(Context, FixedType);
4978 if (Res.isSigned() && Res.isNegative()) {
4979 SizeIsNegative =
true;
4984 unsigned ActiveSizeBits
5018 TypeLoc DstElemTL = DstATL.getElementLoc();
5031 bool &SizeIsNegative,
5032 llvm::APSInt &Oversized) {
5035 SizeIsNegative, Oversized);
5072 diag::err_inline_non_function);
5076 diag::err_virtual_non_function);
5080 diag::err_explicit_non_function);
5084 diag::err_noreturn_non_function);
5113 if (!NewTD)
return nullptr;
5116 ProcessDeclAttributes(S, NewTD, D);
5118 CheckTypedefForVariablyModifiedType(S, NewTD);
5121 NamedDecl *ND = ActOnTypedefNameDecl(S, DC, NewTD, Previous, Redeclaration);
5135 getCurFunction()->setHasBranchProtectedScope();
5138 bool SizeIsNegative;
5139 llvm::APSInt Oversized;
5152 else if (Oversized.getBoolValue())
5154 << Oversized.toString(10);
5172 FilterLookupForScope(Previous, DC, S,
false,
5175 if (!Previous.
empty()) {
5176 Redeclaration =
true;
5177 MergeTypedefNameDecl(NewTD, Previous);
5184 if (II->isStr(
"FILE"))
5186 else if (II->isStr(
"jmp_buf"))
5188 else if (II->isStr(
"sigjmp_buf"))
5190 else if (II->isStr(
"ucontext_t"))
5248 if (!OuterContext->
Equals(PrevOuterContext))
5257 if (!SS.
isSet())
return;
5266 unsigned kind = -1U;
5267 if (
VarDecl *var = dyn_cast<VarDecl>(decl)) {
5268 if (var->hasAttr<BlocksAttr>())
5270 else if (!var->hasLocalStorage())
5272 }
else if (isa<ObjCIvarDecl>(decl)) {
5274 }
else if (isa<FieldDecl>(decl)) {
5292 if (
VarDecl *var = dyn_cast<VarDecl>(decl)) {
5295 var->getTLSKind()) {
5296 Diag(var->getLocation(), diag::err_arc_thread_ownership)
5317 if (WeakRefAttr *
Attr = ND.
getAttr<WeakRefAttr>()) {
5325 if (
auto *VD = dyn_cast<VarDecl>(&ND)) {
5326 if (VD->hasInit()) {
5327 if (
const auto *
Attr = VD->getAttr<AliasAttr>()) {
5328 assert(VD->isThisDeclarationADefinition() &&
5329 !VD->isExternallyVisible() &&
"Broken AliasAttr handled late!");
5331 VD->dropAttr<AliasAttr>();
5338 if (SelectAnyAttr *
Attr = ND.
getAttr<SelectAnyAttr>()) {
5341 diag::err_attribute_selectany_non_extern_data);
5358 bool IsSpecialization) {
5359 if (
TemplateDecl *OldTD = dyn_cast<TemplateDecl>(OldDecl))
5360 OldDecl = OldTD->getTemplatedDecl();
5361 if (
TemplateDecl *NewTD = dyn_cast<TemplateDecl>(NewDecl))
5362 NewDecl = NewTD->getTemplatedDecl();
5364 if (!OldDecl || !NewDecl)
5367 const DLLImportAttr *OldImportAttr = OldDecl->
getAttr<DLLImportAttr>();
5368 const DLLExportAttr *OldExportAttr = OldDecl->
getAttr<DLLExportAttr>();
5369 const DLLImportAttr *NewImportAttr = NewDecl->
getAttr<DLLImportAttr>();
5370 const DLLExportAttr *NewExportAttr = NewDecl->
getAttr<DLLExportAttr>();
5374 bool HasNewAttr = (NewImportAttr && !NewImportAttr->isInherited()) ||
5375 (NewExportAttr && !NewExportAttr->isInherited());
5381 bool AddsAttr = !(OldImportAttr || OldExportAttr) && HasNewAttr;
5383 if (AddsAttr && !IsSpecialization && !OldDecl->
isImplicit()) {
5385 bool JustWarn =
false;
5387 auto *VD = dyn_cast<
VarDecl>(OldDecl);
5388 if (VD && !VD->getDescribedVarTemplate())
5399 if (!isa<FunctionDecl>(OldDecl) || !NewImportAttr)
5402 unsigned DiagID = JustWarn ? diag::warn_attribute_dll_redeclaration
5403 : diag::err_attribute_dll_redeclaration;
5406 << (NewImportAttr ? (
const Attr *)NewImportAttr : NewExportAttr);
5418 bool IsInline =
false, IsStaticDataMember =
false, IsQualifiedFriend =
false;
5419 if (
const auto *VD = dyn_cast<VarDecl>(NewDecl))
5422 IsStaticDataMember = VD->isStaticDataMember();
5423 else if (
const auto *FD = dyn_cast<FunctionDecl>(NewDecl)) {
5424 IsInline = FD->isInlined();
5425 IsQualifiedFriend = FD->getQualifier() &&
5429 if (OldImportAttr && !HasNewAttr && !IsInline && !IsStaticDataMember &&
5432 diag::warn_redeclaration_without_attribute_prev_attribute_ignored)
5433 << NewDecl << OldImportAttr;
5435 S.
Diag(OldImportAttr->getLocation(), diag::note_previous_attribute);
5436 OldDecl->
dropAttr<DLLImportAttr>();
5437 NewDecl->
dropAttr<DLLImportAttr>();
5438 }
else if (IsInline && OldImportAttr &&
5441 OldDecl->
dropAttr<DLLImportAttr>();
5442 NewDecl->
dropAttr<DLLImportAttr>();
5444 diag::warn_dllimport_dropped_from_inline_function)
5445 << NewDecl << OldImportAttr;
5498 template<
typename T>
5502 if (!D->isInExternCContext() || D->template hasAttr<OverloadableAttr>())
5505 return D->isExternC();
5516 llvm_unreachable(
"Unexpected context");
5525 llvm_unreachable(
"Unexpected context");
5531 if (L->getKind() ==
Kind)
5580 if (
auto *FD = dyn_cast<FunctionDecl>(D))
5581 return (FD->getDeclContext()->isTranslationUnit() || FD->isExternC()) &&
5582 FD->hasExternalFormalLinkage();
5583 else if (
auto *VD = dyn_cast<VarDecl>(D))
5584 return (VD->getDeclContext()->isTranslationUnit() || VD->isExternC()) &&
5585 VD->hasExternalFormalLinkage();
5587 llvm_unreachable(
"Unknown type of decl!");
5609 bool IsLocalExternDecl = SC ==
SC_Extern &&
5610 adjustContextForLocalExternDecl(DC);
5612 if (getLangOpts().OpenCL) {
5624 if (!getOpenCLOptions().cl_khr_fp16) {
5643 !D.
getAsmLabel() && !getSourceManager().isInSystemMacro(
5649 diag::warn_deprecated_register)
5672 if (getLangOpts().OpenCL) {
5704 bool IsExplicitSpecialization =
false;
5705 bool IsVariableTemplateSpecialization =
false;
5706 bool IsPartialSpecialization =
false;
5707 bool IsVariableTemplate =
false;
5719 bool Invalid =
false;
5721 if (DC->
isRecord() && !CurContext->isRecord()) {
5728 diag::err_static_out_of_line)
5740 diag::err_storage_class_for_static_member)
5744 llvm_unreachable(
"C storage class in c++!");
5746 llvm_unreachable(
"OpenCL storage class in c++!");
5750 if (SC ==
SC_Static && CurContext->isRecord()) {
5751 if (
const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(DC)) {
5752 if (RD->isLocalClass())
5754 diag::err_static_data_member_not_allowed_in_local_class)
5755 << Name << RD->getDeclName();
5761 getLangOpts().CPlusPlus11
5762 ? diag::warn_cxx98_compat_static_data_member_in_union
5763 : diag::ext_static_data_member_in_union) << Name;
5765 else if (!RD->getDeclName())
5767 diag::err_static_data_member_not_allowed_in_anon_struct)
5768 << Name << RD->isUnion();
5774 TemplateParams = MatchTemplateParametersToScopeSpecifier(
5781 false, IsExplicitSpecialization, Invalid);
5783 if (TemplateParams) {
5784 if (!TemplateParams->
size() &&
5789 diag::err_template_variable_noparams)
5793 TemplateParams =
nullptr;
5798 IsVariableTemplateSpecialization =
true;
5799 IsPartialSpecialization = TemplateParams->
size() > 0;
5802 IsVariableTemplate =
true;
5805 if (CheckTemplateDeclScope(S, TemplateParams))
5810 getLangOpts().CPlusPlus14
5811 ? diag::warn_cxx11_compat_variable_template
5812 : diag::ext_variable_template);
5818 "should have a 'template<>' for this decl");
5821 if (IsVariableTemplateSpecialization) {
5823 TemplateParamLists.size() > 0
5824 ? TemplateParamLists[0]->getTemplateLoc()
5826 DeclResult Res = ActOnVarTemplateSpecialization(
5827 S, D, TInfo, TemplateKWLoc, TemplateParams, SC,
5828 IsPartialSpecialization);
5831 NewVD = cast<VarDecl>(Res.
get());
5838 if (IsVariableTemplate) {
5841 TemplateParams, NewVD);
5848 ParsingInitForAutoVars.insert(NewVD);
5860 unsigned VDTemplateParamLists = TemplateParams ? 1 : 0;
5861 if (TemplateParamLists.size() > VDTemplateParamLists)
5863 Context, TemplateParamLists.size() - VDTemplateParamLists,
5864 TemplateParamLists.data());
5876 if (IsLocalExternDecl)
5879 bool EmitTLSUnsupportedError =
false;
5892 diag::err_thread_non_global)
5895 if (getLangOpts().CUDA) {
5899 EmitTLSUnsupportedError =
true;
5906 diag::err_thread_unsupported);
5925 diag::warn_static_local_in_extern_inline);
5926 MaybeSuggestAddingStaticToDecl(CurFD);
5931 if (IsVariableTemplateSpecialization)
5933 << (IsPartialSpecialization ? 1 : 0)
5936 else if (IsExplicitSpecialization)
5953 ProcessDeclAttributes(S, NewVD, D);
5955 if (getLangOpts().CUDA) {
5958 diag::err_thread_unsupported);
5962 (NewVD->
hasAttr<CUDASharedAttr>() ||
5963 NewVD->
hasAttr<CUDAConstantAttr>())) {
5971 assert(!NewVD->
hasAttr<DLLImportAttr>() ||
5972 NewVD->
getAttr<DLLImportAttr>()->isInherited() ||
5977 if (getLangOpts().ObjCAutoRefCount && inferObjCARCLifetime(NewVD))
5989 Diag(E->getExprLoc(), diag::warn_asm_label_on_auto_decl) << Label;
5994 Diag(E->getExprLoc(), diag::err_asm_unknown_register_name) << Label;
6005 Diag(E->getExprLoc(), diag::err_asm_unknown_register_name) << Label;
6014 }
else if (!ExtnameUndeclaredIdentifiers.empty() &&
6016 llvm::DenseMap<IdentifierInfo*,AsmLabelAttr*>::iterator I =
6018 if (I != ExtnameUndeclaredIdentifiers.end()) {
6020 ExtnameUndeclaredIdentifiers.erase(I);
6026 CheckShadow(S, NewVD, Previous);
6033 IsExplicitSpecialization ||
6034 IsVariableTemplateSpecialization);
6038 if (getLangOpts().CPlusPlus &&
6042 isDeclInScope(Previous.
getFoundDecl(), OriginalDC,
S,
false));
6044 if (!getLangOpts().CPlusPlus) {
6049 CheckMemberSpecialization(NewVD, Previous))
6053 if (!Previous.
empty()) {
6072 if (!IsVariableTemplateSpecialization)
6084 if (CheckTemplateParameterList(
6090 ? TPC_ClassTemplateMember
6096 if (PrevVarTemplate &&
6102 ProcessPragmaWeak(S, NewVD);
6108 RegisterLocallyScopedExternCDecl(NewVD, S);
6111 Decl *ManglingContextDecl;
6115 NewVD, MCtx->getManglingNumber(
6124 IsExplicitSpecialization);
6130 ActOnDocumentableDecl(NewTemplate);
6148 if (Diags.isIgnored(diag::warn_decl_shadow, R.
getNameLoc()))
6162 if (!isa<VarDecl>(ShadowedDecl) && !isa<FieldDecl>(ShadowedDecl))
6166 if (isa<FieldDecl>(ShadowedDecl))
6171 if (
VarDecl *shadowedVar = dyn_cast<VarDecl>(ShadowedDecl))
6172 if (shadowedVar->isExternC()) {
6175 for (
auto I : shadowedVar->redecls())
6176 if (I->isFileVarDecl()) {
6200 if (isa<RecordDecl>(OldDC)) {
6201 if (isa<FieldDecl>(ShadowedDecl))
6213 if (getSourceManager().isInSystemMacro(R.
getNameLoc()))
6215 Diag(R.
getNameLoc(), diag::warn_decl_shadow) << Name << Kind << OldDC;
6221 if (Diags.isIgnored(diag::warn_decl_shadow, D->
getLocation()))
6227 CheckShadow(S, D, R);
6232 template<
typename T>
6235 assert(S.
getLangOpts().CPlusPlus &&
"only C++ has extern \"C\"");
6256 if (!isa<VarDecl>(ND))
6266 if (isa<VarDecl>(*I)) {
6276 if (isa<VarDecl>(*I)) {
6294 assert(Prev &&
"should have found a previous declaration to diagnose");
6296 Prev = FD->getFirstDecl();
6298 Prev = cast<VarDecl>(Prev)->getFirstDecl();
6300 S.
Diag(ND->getLocation(), diag::err_extern_c_global_conflict)
6302 S.
Diag(Prev->getLocation(), diag::note_extern_c_global_conflict)
6315 template<
typename T>
6322 if (ND->getDeclContext()->getRedeclContext()->isTranslationUnit()) {
6334 if (ND->getDeclContext()->getRedeclContext()->isTranslationUnit())
6360 CheckAlignasUnderalignment(NewVD);
6384 Diag(NewVD->
getLocation(), diag::err_opencl_global_invalid_addr_space);
6391 if ((getLangOpts().OpenCLVersion >= 120)
6399 && !NewVD->
hasAttr<BlocksAttr>()) {
6403 assert(!getLangOpts().ObjCAutoRefCount);
6409 if (isVM || NewVD->
hasAttr<CleanupAttr>() ||
6411 getCurFunction()->setHasBranchProtectedScope();
6415 bool SizeIsNegative;
6416 llvm::APSInt Oversized;
6419 SizeIsNegative, Oversized);
6470 if (isVM && NewVD->
hasAttr<BlocksAttr>()) {
6478 diag::err_constexpr_var_non_literal)) {
6497 CheckVariableDeclarationType(NewVD);
6505 if (Previous.
empty() &&
6512 if (!Previous.
empty()) {
6513 MergeVarDecl(NewVD, Previous);
6578 if ((OEK == OEK_All) ||
6579 (OEK == OEK_NonDeleted && !(*I)->isDeleted()) ||
6580 (OEK == OEK_Deleted && (*I)->isDeleted()))
6581 S.
Diag((*I)->getLocation(), diag::note_overridden_virtual_function);
6593 bool hasDeletedOverridenMethods =
false;
6594 bool hasNonDeletedOverridenMethods =
false;
6595 bool AddedAny =
false;
6600 if (!CheckOverridingFunctionReturnType(MD, OldMD) &&
6601 !CheckOverridingFunctionAttributes(MD, OldMD) &&
6602 !CheckOverridingFunctionExceptionSpec(MD, OldMD) &&
6603 !CheckIfOverriddenFunctionIsMarkedFinal(MD, OldMD)) {
6604 hasDeletedOverridenMethods |= OldMD->isDeleted();
6605 hasNonDeletedOverridenMethods |= !OldMD->isDeleted();
6612 if (hasDeletedOverridenMethods && !MD->
isDeleted()) {
6613 ReportOverrides(*
this, diag::err_non_deleted_override, MD, OEK_Deleted);
6615 if (hasNonDeletedOverridenMethods && MD->
isDeleted()) {
6616 ReportOverrides(*
this, diag::err_deleted_override, MD, OEK_NonDeleted);
6625 struct ActOnFDArgs {
6641 : Context(Context), OriginalFD(TypoFD),
6642 ExpectedParent(Parent ? Parent->getCanonicalDecl() : nullptr) {}
6644 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
6650 CDeclEnd = candidate.
end();
6651 CDecl != CDeclEnd; ++CDecl) {
6660 }
else if (!ExpectedParent) {
6688 ActOnFDArgs &ExtraArgs,
bool IsLocalFriend,
Scope *
S) {
6694 bool IsDefinition = ExtraArgs.D.isFunctionDefinition();
6695 unsigned DiagMsg = IsLocalFriend ? diag::err_no_matching_local_friend
6696 : diag::err_member_decl_does_not_match;
6707 assert(!Prev.isAmbiguous() &&
6708 "Cannot have an ambiguity in previous-declaration lookup");
6710 if (!Prev.empty()) {
6712 Func != FuncEnd; ++Func) {
6719 MismatchedParams.empty() ? 0 : MismatchedParams.front() + 1;
6720 NearMatches.push_back(std::make_pair(FD, ParamNum));
6725 Prev.getLookupNameInfo(), Prev.getLookupKind(),
S,
6726 &ExtraArgs.D.getCXXScopeSpec(),
6727 llvm::make_unique<DifferentNameValidatorCCC>(
6732 ExtraArgs.D.getIdentifierLoc());
6736 CDeclEnd = Correction.
end();
6737 CDecl != CDeclEnd; ++CDecl) {
6744 bool wasRedeclaration = ExtraArgs.D.isRedeclaration();
6757 ExtraArgs.S, ExtraArgs.D,
6760 ExtraArgs.AddToScope);
6771 if ((*I)->getCanonicalDecl() == Canonical)
6776 SemaRef.
PDiag(IsLocalFriend
6777 ? diag::err_no_matching_local_friend_suggest
6778 : diag::err_member_decl_does_not_match_suggest)
6779 << Name << NewDC << IsDefinition);
6785 ExtraArgs.D.getIdentifierLoc());
6786 ExtraArgs.D.setRedeclaration(wasRedeclaration);
6792 << Name << NewDC << IsDefinition << NewFD->
getLocation();
6794 bool NewFDisConst =
false;
6796 NewFDisConst = NewMD->isConst();
6799 NearMatch = NearMatches.begin(), NearMatchEnd = NearMatches.end();
6800 NearMatch != NearMatchEnd; ++NearMatch) {
6803 bool FDisConst = MD && MD->
isConst();
6804 bool IsMember = MD || !IsLocalFriend;
6807 if (
unsigned Idx = NearMatch->second) {
6811 SemaRef.
Diag(Loc, IsMember ? diag::note_member_def_close_param_match
6812 : diag::note_local_decl_close_param_match)
6815 }
else if (FDisConst != NewFDisConst) {
6816 SemaRef.
Diag(FD->
getLocation(), diag::note_member_def_close_const_match)
6820 IsMember ? diag::note_member_def_close_match
6821 : diag::note_local_decl_close_match);
6828 default: llvm_unreachable(
"Unknown storage class!");
6833 diag::err_typecheck_sclass_func);
6849 diag::err_static_block_func);
6865 bool &IsVirtualOkay) {
6884 TInfo, SC, isInline,
6885 HasPrototype,
false);
6907 "Constructors can only be declared in a member context");
6912 R, TInfo, isExplicit, isInline,
6924 NameInfo, R, TInfo, isInline,
6936 IsVirtualOkay =
true;
6955 diag::err_conv_function_not_member);
6960 IsVirtualOkay =
true;
6963 R, TInfo, isInline, isExplicit,
6981 cast<CXXRecordDecl>(DC),
6983 TInfo, SC, isInline,
6998 NameInfo, R, TInfo, SC, isInline,
7046 llvm::SmallPtrSetImpl<const Type *> &ValidTypes) {
7067 S.
Diag(Param->
getLocation(), diag::err_opencl_private_ptr_kernel_param);
7100 HistoryStack.push_back(
nullptr);
7103 VisitStack.push_back(PD);
7105 assert(VisitStack.back() &&
"First decl null?");
7108 const Decl *
Next = VisitStack.pop_back_val();
7110 assert(!HistoryStack.empty());
7112 if (
const FieldDecl *Hist = HistoryStack.pop_back_val())
7113 ValidTypes.insert(Hist->getType().getTypePtr());
7121 if (
const FieldDecl *Field = dyn_cast<FieldDecl>(Next)) {
7122 HistoryStack.push_back(Field);
7123 RD = Field->getType()->castAs<
RecordType>()->getDecl();
7125 RD = cast<RecordDecl>(
Next);
7129 VisitStack.push_back(
nullptr);
7131 for (
const auto *FD : RD->
fields()) {
7142 VisitStack.push_back(FD);
7153 diag::err_record_with_pointers_kernel_param)
7166 I = HistoryStack.begin() + 1,
7167 E = HistoryStack.end();
7180 }
while (!VisitStack.empty());
7199 diag::err_invalid_thread)
7205 bool isFriend =
false;
7207 bool isExplicitSpecialization =
false;
7208 bool isFunctionTemplateSpecialization =
false;
7210 bool isDependentClassScopeExplicitSpecialization =
false;
7211 bool HasExplicitTemplateArgs =
false;
7214 bool isVirtualOkay =
false;
7217 bool IsLocalExternDecl = adjustContextForLocalExternDecl(DC);
7221 if (!NewFD)
return nullptr;
7223 if (OriginalLexicalContext && OriginalLexicalContext->isObjCContainer())
7231 if (IsLocalExternDecl)
7252 if (Parent->isInterface() && cast<CXXMethodDecl>(NewFD)->isUserProvided())
7257 if (isVirtual && Parent->isUnion())
7262 isExplicitSpecialization =
false;
7263 isFunctionTemplateSpecialization =
false;
7269 bool Invalid =
false;
7271 MatchTemplateParametersToScopeSpecifier(
7277 TemplateParamLists, isFriend, isExplicitSpecialization,
7279 if (TemplateParams->size() > 0) {
7283 if (CheckTemplateDeclScope(S, TemplateParams))
7297 if (RebuildTemplateParamsInCurrentInstantiation(TemplateParams))
7304 Name, TemplateParams,
7310 if (TemplateParamLists.size() > 1) {
7312 TemplateParamLists.size() - 1,
7313 TemplateParamLists.data());
7317 isFunctionTemplateSpecialization =
true;
7319 if (TemplateParamLists.size() > 0)
7321 TemplateParamLists.size(),
7322 TemplateParamLists.data());
7327 SourceRange RemoveRange = TemplateParams->getSourceRange();
7337 InsertLoc = getLocForEndOfToken(InsertLoc);
7341 << Name << RemoveRange
7350 if (TemplateParamLists.size() > 0)
7353 TemplateParamLists.size(),
7354 TemplateParamLists.data());
7359 if (FunctionTemplate)
7369 if (!isVirtualOkay) {
7371 diag::err_virtual_non_function);
7372 }
else if (!CurContext->isRecord()) {
7375 diag::err_virtual_out_of_class)
7381 diag::err_virtual_member_function_template)
7393 if (getLangOpts().CPlusPlus14 &&
7395 (isFriend && CurContext->isDependentContext())) &&
7415 if (CurContext->isFunctionOrMethod()) {
7418 diag::err_inline_declaration_block_scope) << Name
7428 if (!CurContext->isRecord()) {
7431 diag::err_explicit_out_of_class)
7433 }
else if (!isa<CXXConstructorDecl>(NewFD) &&
7434 !isa<CXXConversionDecl>(NewFD)) {
7438 diag::err_explicit_non_ctor_or_conv_function)
7451 if (isa<CXXDestructorDecl>(NewFD))
7457 if (isFunctionTemplateSpecialization) {
7460 Diag(ModulePrivateLoc, diag::err_module_private_specialization)
7465 if (FunctionTemplate)
7471 if (FunctionTemplate) {
7496 if (isa<CXXMethodDecl>(NewFD) && DC == CurContext &&
7504 if (SC ==
SC_Static && isa<CXXMethodDecl>(NewFD) &&
7505 !CurContext->isRecord()) {
7514 diag::err_static_out_of_line)
7533 isExplicitSpecialization ||
7534 isFunctionTemplateSpecialization);
7542 }
else if (!ExtnameUndeclaredIdentifiers.empty() &&
7544 llvm::DenseMap<IdentifierInfo*,AsmLabelAttr*>::iterator I =
7546 if (I != ExtnameUndeclaredIdentifiers.end()) {
7548 ExtnameUndeclaredIdentifiers.erase(I);
7564 for (
unsigned i = 0, e = FTI.
NumParams; i != e; ++i) {
7568 Params.push_back(Param);
7586 for (
const auto &AI : FT->param_types()) {
7590 Params.push_back(Param);
7594 "Should not need args for typedef of non-prototype fn");
7598 NewFD->setParams(Params);
7607 DeclsInPrototypeScope.clear();
7624 !NewFD->
hasAttr<SectionAttr>()) {
7626 SectionAttr::CreateImplicit(
Context, SectionAttr::Declspec_allocate,
7627 CodeSegStack.CurrentValue->getString(),
7628 CodeSegStack.CurrentPragmaLocation));
7629 if (UnifySection(CodeSegStack.CurrentValue->getString(),
7637 ProcessDeclAttributes(S, NewFD, D);
7639 if (getLangOpts().OpenCL) {
7647 diag::err_opencl_return_value_with_address_space);
7654 bool isExplicitSpecialization=
false;
7659 CheckMSVCRTEntryPoint(NewFD);
7663 isExplicitSpecialization));
7664 else if (!Previous.
empty())
7669 "previous declaration set still overloaded");
7681 CC ==
CC_X86StdCall ? diag::warn_cconv_knr : diag::err_cconv_knr;
7698 diag::ext_operator_new_delete_declared_inline)
7709 translateTemplateArguments(TemplateArgsPtr,
7712 HasExplicitTemplateArgs =
true;
7715 HasExplicitTemplateArgs =
false;
7716 }
else if (FunctionTemplate) {
7721 HasExplicitTemplateArgs =
false;
7723 assert((isFunctionTemplateSpecialization ||
7725 "should have a 'template<>' for this decl");
7727 isFunctionTemplateSpecialization =
true;
7729 }
else if (isFriend && isFunctionTemplateSpecialization) {
7736 HasExplicitTemplateArgs =
true;
7745 bool InstantiationDependent =
false;
7746 if (isFunctionTemplateSpecialization && isFriend &&
7750 InstantiationDependent))) {
7751 assert(HasExplicitTemplateArgs &&
7752 "friend function specialization without template args");
7753 if (CheckDependentFunctionTemplateSpecialization(NewFD, TemplateArgs,
7756 }
else if (isFunctionTemplateSpecialization) {
7757 if (CurContext->isDependentContext() && CurContext->isRecord()
7759 isDependentClassScopeExplicitSpecialization =
true;
7761 diag::ext_function_specialization_in_class :
7762 diag::err_function_specialization_in_class)
7764 }
else if (CheckFunctionTemplateSpecialization(NewFD,
7765 (HasExplicitTemplateArgs ? &TemplateArgs
7778 diag::err_explicit_specialization_inconsistent_storage_class)
7785 diag::ext_explicit_specialization_storage_class)
7790 }
else if (isExplicitSpecialization && isa<CXXMethodDecl>(NewFD)) {
7791 if (CheckMemberSpecialization(NewFD, Previous))
7796 if (!isDependentClassScopeExplicitSpecialization) {
7801 CheckMSVCRTEntryPoint(NewFD);
7805 isExplicitSpecialization));
7806 else if (!Previous.
empty())
7813 "previous declaration set still overloaded");
7815 NamedDecl *PrincipalDecl = (FunctionTemplate
7816 ? cast<NamedDecl>(FunctionTemplate)
7825 if (FunctionTemplate) FunctionTemplate->
setAccess(Access);
7834 if (FunctionTemplate) {
7842 ? TPC_FriendFunctionTemplateDefinition
7843 : TPC_FriendFunctionTemplate)
7847 ? TPC_ClassTemplateMember
7848 : TPC_FunctionTemplate);
7854 struct ActOnFDArgs ExtraArgs = {
S, D, TemplateParamLists,
7872 (TemplateParamLists.size() ||
7874 CurContext->isDependentContext())) {
7893 *
this, Previous, NewFD, ExtraArgs,
false,
nullptr)) {
7894 AddToScope = ExtraArgs.AddToScope;
7901 }
else if (isFriend && cast<CXXRecordDecl>(CurContext)->isLocalClass()) {
7903 *
this, Previous, NewFD, ExtraArgs,
true, S)) {
7904 AddToScope = ExtraArgs.AddToScope;
7910 isa<CXXMethodDecl>(NewFD) && NewFD->
isOutOfLine() &&
7911 !isFriend && !isFunctionTemplateSpecialization &&
7912 !isExplicitSpecialization) {
7925 ProcessPragmaWeak(S, NewFD);
7928 AddKnownFunctionAttributes(NewFD);
7930 if (NewFD->
hasAttr<OverloadableAttr>() &&
7933 diag::err_attribute_overloadable_no_prototype)
7941 EPI.ExtInfo = FT->getExtInfo();
7950 AddPushedVisibilityAttribute(NewFD);
7954 AddCFAuditedAttribute(NewFD);
7959 AddRangeBasedOptnone(NewFD);
7965 RegisterLocallyScopedExternCDecl(NewFD, S);
7973 isExplicitSpecialization || isFunctionTemplateSpecialization);
7977 if (FunctionTemplate) {
7980 return FunctionTemplate;
7984 if (NewFD->
hasAttr<OpenCLKernelAttr>()) {
7986 if ((getLangOpts().OpenCLVersion >= 120)
8001 llvm::SmallPtrSet<const Type *, 16> ValidTypes;
8002 for (
auto Param : NewFD->
params())
8006 MarkUnusedFileScopedDecl(NewFD);
8008 if (getLangOpts().CUDA)
8012 if (II->isStr(
"cudaConfigureCall")) {
8023 if (isDependentClassScopeExplicitSpecialization) {
8027 cast<CXXMethodDecl>(NewFD),
8028 HasExplicitTemplateArgs, TemplateArgs);
8029 CurContext->addDecl(NewSpec);
8054 bool IsExplicitSpecialization) {
8056 "Variably modified return types are not handled here");
8061 bool MergeTypeWithPrevious = !getLangOpts().CPlusPlus &&
8067 bool Redeclaration =
false;
8072 if (!Previous.
empty()) {
8079 if (shouldLinkPossiblyHiddenDecl(Candidate, NewFD)) {
8080 Redeclaration =
true;
8081 OldDecl = Candidate;
8084 switch (CheckOverload(S, NewFD, Previous, OldDecl,
8087 Redeclaration =
true;
8090 case Ovl_NonFunction:
8091 Redeclaration =
true;
8095 Redeclaration =
false;
8103 << Redeclaration << NewFD;
8106 OverloadedDecl = OldDecl;
8107 else if (!Previous.
empty())
8110 Diag(OverloadedDecl->getLocation(),
8111 diag::note_attribute_overloadable_prev_overload);
8118 if (!Redeclaration &&
8121 if (!Previous.
empty()) {
8124 Redeclaration =
true;
8126 MergeTypeWithPrevious =
false;
8129 if (OldDecl->
hasAttr<OverloadableAttr>()) {
8132 << Redeclaration << NewFD;
8134 diag::note_attribute_overloadable_prev_overload);
8137 if (IsOverload(NewFD, cast<FunctionDecl>(OldDecl),
false)) {
8138 Redeclaration =
false;
8155 if (!getLangOpts().CPlusPlus14 && MD && MD->
isConstexpr() &&
8156 !MD->
isStatic() && !isa<CXXConstructorDecl>(MD) &&
8160 OldMD = dyn_cast_or_null<CXXMethodDecl>(OldDecl->
getAsFunction());
8161 if (!OldMD || !OldMD->
isStatic()) {
8171 if (ActiveTemplateInstantiations.empty()) {
8175 AddConstLoc = getLocForEndOfToken(FTL.getRParenLoc());
8183 if (Redeclaration) {
8186 if (MergeFunctionDecl(NewFD, OldDecl, S, MergeTypeWithPrevious)) {
8188 return Redeclaration;
8195 = dyn_cast<FunctionTemplateDecl>(OldDecl)) {
8199 assert(NewTemplateDecl &&
"Template/non-template mismatch");
8202 Method->setAccess(OldTemplateDecl->getAccess());
8203 NewTemplateDecl->
setAccess(OldTemplateDecl->getAccess());
8208 if (IsExplicitSpecialization &&
8211 assert(OldTemplateDecl->isMemberSpecialization());
8218 if (isa<CXXMethodDecl>(NewFD))
8225 if (getLangOpts().CPlusPlus) {
8228 CheckConstructor(Constructor);
8230 dyn_cast<CXXDestructorDecl>(NewFD)) {
8243 return Redeclaration;
8247 = dyn_cast<CXXConversionDecl>(NewFD)) {
8248 ActOnConversionDeclarator(Conversion);
8252 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(NewFD)) {
8253 if (!Method->isFunctionTemplateSpecialization() &&
8254 !Method->getDescribedFunctionTemplate() &&
8255 Method->isCanonicalDecl()) {
8256 if (AddOverriddenMethods(Method->getParent(), Method)) {
8264 if (Method->isStatic())
8265 checkThisInStaticMemberFunctionType(Method);
8270 CheckOverloadedOperatorDeclaration(NewFD)) {
8272 return Redeclaration;
8277 CheckLiteralOperatorDeclaration(NewFD)) {
8279 return Redeclaration;
8285 if (!CurContext->isRecord())
8286 CheckCXXDefaultArguments(NewFD);
8312 Diag(NewFD->
getLocation(), diag::warn_return_value_udt) << NewFD << R;
8315 return Redeclaration;
8328 ? diag::err_static_main : diag::warn_static_main)
8335 SourceRange NoreturnRange(NoreturnLoc, getLocForEndOfToken(NoreturnLoc));
8336 Diag(NoreturnLoc, diag::ext_noreturn_main);
8337 Diag(NoreturnLoc, diag::note_main_remove_noreturn)
8346 if (getLangOpts().OpenCL) {
8348 << FD->
hasAttr<OpenCLKernelAttr>();
8354 assert(T->
isFunctionType() &&
"function decl is not of function type");
8357 if (getLangOpts().GNUMode && !getLangOpts().CPlusPlus) {
8368 if (RTRange.isValid())
8369 Diag(RTRange.getBegin(), diag::note_main_change_return_type)
8391 if (isa<FunctionNoProtoType>(FT))
return;
8397 bool HasExtraParameters = (nparams > 3);
8409 HasExtraParameters =
false;
8411 if (HasExtraParameters) {
8424 for (
unsigned i = 0; i < nparams; ++i) {
8427 bool mismatch =
true;
8431 else if (Expected[i] == CharPP) {
8444 mismatch = !qs.
empty();
8449 Diag(FD->
getLocation(), diag::err_main_arg_wrong) << i << Expected[i];
8467 assert(T->
isFunctionType() &&
"function decl is not of function type");
8472 if (FT->getReturnType()->isIntegralOrEnumerationType() ||
8473 FT->getReturnType()->isAnyPointerType() ||
8474 FT->getReturnType()->isNullPtrType())
8476 if (FD->
getName() !=
"DllMain")
8494 const Expr *Culprit;
8498 << Culprit->getSourceRange();
8505 class SelfReferenceChecker
8511 bool isReferenceType;
8519 S(S), OrigDecl(OrigDecl) {
8522 isReferenceType =
false;
8524 if (
ValueDecl *VD = dyn_cast<ValueDecl>(OrigDecl)) {
8525 isPODType = VD->getType().isPODType(S.
Context);
8527 isReferenceType = VD->getType()->isReferenceType();
8534 void CheckExpr(
Expr *E) {
8543 InitFieldIndex.push_back(0);
8544 for (
auto Child : InitList->
children()) {
8545 CheckExpr(cast<Expr>(Child));
8546 ++InitFieldIndex.back();
8548 InitFieldIndex.pop_back();
8553 bool CheckInitListMemberExpr(
MemberExpr *E,
bool CheckReference) {
8556 bool ReferenceField =
false;
8559 while (
MemberExpr *ME = dyn_cast<MemberExpr>(Base)) {
8563 Fields.push_back(FD);
8565 ReferenceField =
true;
8571 if (!DRE || DRE->
getDecl() != OrigDecl)
8575 if (CheckReference && !ReferenceField)
8580 for (
auto I = Fields.rbegin(), E = Fields.rend(); I != E; ++I) {
8581 UsedFieldIndex.push_back((*I)->getFieldIndex());
8587 for (
auto UsedIter = UsedFieldIndex.begin(),
8588 UsedEnd = UsedFieldIndex.end(),
8589 OrigIter = InitFieldIndex.begin(),
8590 OrigEnd = InitFieldIndex.end();
8591 UsedIter != UsedEnd && OrigIter != OrigEnd; ++UsedIter, ++OrigIter) {
8592 if (*UsedIter < *OrigIter)
8594 if (*UsedIter > *OrigIter)
8599 HandleDeclRefExpr(DRE);
8606 void HandleValue(
Expr *E) {
8608 if (
DeclRefExpr* DRE = dyn_cast<DeclRefExpr>(E)) {
8609 HandleDeclRefExpr(DRE);
8614 Visit(CO->getCond());
8615 HandleValue(CO->getTrueExpr());
8616 HandleValue(CO->getFalseExpr());
8621 dyn_cast<BinaryConditionalOperator>(E)) {
8622 Visit(BCO->getCond());
8623 HandleValue(BCO->getFalseExpr());
8628 HandleValue(OVE->getSourceExpr());
8634 Visit(BO->getLHS());
8635 HandleValue(BO->getRHS());
8640 if (isa<MemberExpr>(E)) {
8642 if (CheckInitListMemberExpr(cast<MemberExpr>(E),
8648 while (
MemberExpr *ME = dyn_cast<MemberExpr>(Base)) {
8650 if (!isa<FieldDecl>(ME->getMemberDecl()))
8654 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Base))
8655 HandleDeclRefExpr(DRE);
8665 if (isReferenceType)
8666 HandleDeclRefExpr(E);
8675 Inherited::VisitImplicitCastExpr(E);
8680 if (CheckInitListMemberExpr(E,
true ))
8690 bool Warn = (MD && !MD->
isStatic());
8692 while (
MemberExpr *ME = dyn_cast<MemberExpr>(Base)) {
8693 if (!isa<FieldDecl>(ME->getMemberDecl()))
8698 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Base)) {
8700 HandleDeclRefExpr(DRE);
8712 if (isa<UnresolvedLookupExpr>(Callee))
8713 return Inherited::VisitCXXOperatorCallExpr(E);
8717 HandleValue(Arg->IgnoreParenImpCasts());
8734 Inherited::VisitUnaryOperator(E);
8742 if (
InitListExpr *ILE = dyn_cast<InitListExpr>(ArgExpr))
8743 if (ILE->getNumInits() == 1)
8744 ArgExpr = ILE->getInit(0);
8746 if (ICE->getCastKind() ==
CK_NoOp)
8747 ArgExpr = ICE->getSubExpr();
8748 HandleValue(ArgExpr);
8751 Inherited::VisitCXXConstructExpr(E);
8760 HandleValue(E->
getArg(0));
8766 Inherited::VisitCallExpr(E);
8771 HandleValue(E->
getLHS());
8776 Inherited::VisitBinaryOperator(E);
8789 if (OrigDecl != ReferenceDecl)
return;
8791 if (isReferenceType) {
8792 diag = diag::warn_uninit_self_reference_in_reference_init;
8793 }
else if (cast<VarDecl>(OrigDecl)->isStaticLocal()) {
8794 diag = diag::warn_static_self_reference_in_init;
8795 }
else if (isa<TranslationUnitDecl>(OrigDecl->
getDeclContext()) ||
8798 diag = diag::warn_uninit_self_reference_in_init;
8808 << DRE->getSourceRange());
8813 static void CheckSelfReference(
Sema &S,
Decl* OrigDecl,
Expr *E,
8817 if (isa<ParmVarDecl>(OrigDecl))
8824 if (!DirectInit && !cast<VarDecl>(OrigDecl)->getType()->
isRecordType())
8827 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(ICE->getSubExpr()))
8828 if (DRE->
getDecl() == OrigDecl)
8831 SelfReferenceChecker(S, OrigDecl).CheckExpr(E);
8839 bool DirectInit,
bool TypeMayContainAuto) {
8843 CorrectDelayedTyposInExpr(Init, dyn_cast_or_null<VarDecl>(RealDecl));
8847 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(RealDecl)) {
8849 Diag(Method->getLocation(), diag::err_member_function_initialization)
8850 << Method->getDeclName() << Init->getSourceRange();
8851 Method->setInvalidDecl();
8857 assert(!isa<FieldDecl>(RealDecl) &&
"field init shouldn't get here");
8869 ExprResult Res = CorrectDelayedTyposInExpr(Init, VDecl);
8875 if (Res.
get() != Init) {
8881 Expr *DeduceInit = Init;
8884 if (CXXDirectInit) {
8889 VDecl->
isInitCapture() ? diag::err_init_capture_no_expression
8890 : diag::err_auto_var_init_no_expression)
8898 ? diag::err_init_capture_multiple_expressions
8899 : diag::err_auto_var_init_multiple_expressions)
8905 DeduceInit = CXXDirectInit->
getExpr(0);
8906 if (isa<InitListExpr>(DeduceInit))
8908 diag::err_auto_var_init_paren_braces)
8915 bool DefaultedToAuto =
false;
8916 if (getLangOpts().DebuggerCastResultToId &&
8923 Init = Result.
get();
8924 DefaultedToAuto =
true;
8930 DiagnoseAutoDeductionFailure(VDecl, DeduceInit);
8931 if (DeducedType.
isNull()) {
8939 if (getLangOpts().ObjCAutoRefCount && inferObjCARCLifetime(VDecl))
8946 if (ActiveTemplateInstantiations.empty() && !DefaultedToAuto &&
8950 Diag(Loc, diag::warn_auto_var_is_id)
8951 << VDecl->
getDeclName() << DeduceInit->getSourceRange();
8959 MergeVarDeclTypes(VDecl, Old,
false);
8963 CheckVariableDeclarationType(VDecl);
8969 if (DirectInit && !CXXDirectInit && isa<InitListExpr>(Init)) {
8970 Diag(Init->getLocStart(),
8971 diag::warn_auto_var_direct_list_init)
8978 Diag(VDecl->
getLocation(), diag::err_attribute_dllimport_data_definition);
8996 BaseDeclType = Array->getElementType();
8997 if (RequireCompleteType(VDecl->
getLocation(), BaseDeclType,
8998 diag::err_typecheck_decl_incomplete_type)) {
9005 diag::err_abstract_type_in_decl,
9006 AbstractVariableType))
9013 if (!hasVisibleDefinition(Def, &Hidden) &&
9043 Diag(Init->
getExprLoc(), diag::err_static_data_member_reinitialization)
9046 diag::note_previous_initializer)
9052 getCurFunction()->setHasBranchProtectedScope();
9054 if (DiagnoseUnexpandedParameterPack(Init, UPPC_Initializer)) {
9081 Init = Result.
get();
9090 Init->getLocStart(),
9095 Init->getLocStart());
9103 for (
size_t Idx = 0; Idx < Args.size(); ++Idx) {
9105 Args[Idx], VDecl, [
this, Entity, Kind](
Expr *E) {
9111 }
else if (Res.
get() != Args[Idx]) {
9112 Args[Idx] = Res.
get();
9133 CheckSelfReference(*
this, RealDecl, Init, DirectInit);
9146 if (VDecl->
hasAttr<BlocksAttr>())
9147 checkRetainCycles(VDecl, Init);
9157 !Diags.isIgnored(diag::warn_arc_repeated_use_of_weak,
9158 Init->getLocStart()))
9159 getCurFunction()->markSafeWeakUse(Init);
9180 Init = Result.
get();
9190 const Expr *Culprit;
9192 CheckForConstantInitializer(Init, DclT);
9198 isa<InitListExpr>(Init) &&
9201 diag::ext_aggregate_init_not_constant)
9202 << Culprit->getSourceRange();
9238 << Init->getSourceRange();
9256 Diag(Loc, diag::ext_in_class_initializer_non_constant)
9257 << Init->getSourceRange();
9261 Diag(Loc, diag::err_in_class_initializer_non_constant)
9262 << Init->getSourceRange();
9270 if (getLangOpts().CPlusPlus11) {
9272 diag::ext_in_class_initializer_float_type_cxx11)
9273 << DclT << Init->getSourceRange();
9275 diag::note_in_class_initializer_float_type_cxx11)
9279 << DclT << Init->getSourceRange();
9282 Diag(Init->
getExprLoc(), diag::err_in_class_initializer_non_constant)
9283 << Init->getSourceRange();
9290 Diag(VDecl->
getLocation(), diag::err_in_class_initializer_literal_type)
9291 << DclT << Init->getSourceRange()
9297 << DclT << Init->getSourceRange();
9302 (!getLangOpts().CPlusPlus ||
9310 CheckForConstantInitializer(Init, DclT);
9327 if (CXXDirectInit) {
9328 assert(DirectInit &&
"Call-style initializer must be direct init.");
9330 }
else if (DirectInit) {
9335 CheckCompleteVariableDeclaration(VDecl);
9350 if (ParsingInitForAutoVars.count(D)) {
9361 diag::err_typecheck_decl_incomplete_type)) {
9368 diag::err_abstract_type_in_decl,
9369 AbstractVariableType)) {
9379 bool TypeMayContainAuto) {
9384 if (
VarDecl *Var = dyn_cast<VarDecl>(RealDecl)) {
9389 Diag(Var->getLocation(), diag::err_auto_var_requires_init)
9390 << Var->getDeclName() << Type;
9391 Var->setInvalidDecl();
9401 if (Var->isConstexpr() && !Var->isThisDeclarationADefinition()) {
9402 if (Var->isStaticDataMember())
9403 Diag(Var->getLocation(),
9404 diag::err_constexpr_static_mem_var_requires_init)
9405 << Var->getDeclName();
9407 Diag(Var->getLocation(), diag::err_invalid_constexpr_var_decl);
9408 Var->setInvalidDecl();
9414 if (!Var->isInvalidDecl() &&
9416 Var->getStorageClass() !=
SC_Extern && !Var->getInit()) {
9417 Diag(Var->getLocation(), diag::err_opencl_constant_no_init);
9418 Var->setInvalidDecl();
9422 switch (Var->isThisDeclarationADefinition()) {
9424 if (!Var->isStaticDataMember() || !Var->getAnyInitializer())
9440 !Var->hasLinkage() && !Var->isInvalidDecl() &&
9441 RequireCompleteType(Var->getLocation(), Type,
9442 diag::err_typecheck_decl_incomplete_type))
9443 Var->setInvalidDecl();
9447 RequireNonAbstractType(Var->getLocation(), Type,
9448 diag::err_abstract_type_in_decl,
9449 AbstractVariableType))
9450 Var->setInvalidDecl();
9453 Diag(Var->getLocation(), diag::warn_private_extern);
9454 Diag(Var->getLocation(), diag::note_private_extern);
9465 if (!Var->isInvalidDecl()) {
9468 if (RequireCompleteType(Var->getLocation(),
9469 ArrayT->getElementType(),
9470 diag::err_illegal_decl_array_incomplete_type))
9471 Var->setInvalidDecl();
9472 }
else if (Var->getStorageClass() ==
SC_Static) {
9482 if (Var->isFirstDecl())
9483 RequireCompleteType(Var->getLocation(), Type,
9484 diag::ext_typecheck_decl_incomplete_type);
9489 if (!Var->isInvalidDecl())
9490 TentativeDefinitions.push_back(Var);
9497 Diag(Var->getLocation(),
9498 diag::err_typecheck_incomplete_array_needs_initializer);
9499 Var->setInvalidDecl();
9506 Diag(Var->getLocation(), diag::err_reference_var_requires_init)
9507 << Var->getDeclName()
9508 <<
SourceRange(Var->getLocation(), Var->getLocation());
9509 Var->setInvalidDecl();
9518 if (Var->isInvalidDecl())
9521 if (!Var->hasAttr<AliasAttr>()) {
9522 if (RequireCompleteType(Var->getLocation(),
9524 diag::err_typecheck_decl_incomplete_type)) {
9525 Var->setInvalidDecl();
9533 if (RequireNonAbstractType(Var->getLocation(), Type,
9534 diag::err_abstract_type_in_decl,
9535 AbstractVariableType)) {
9536 Var->setInvalidDecl();
9550 if (getLangOpts().
CPlusPlus && Var->hasLocalStorage()) {
9553 CXXRecordDecl *CXXRecord = cast<CXXRecordDecl>(Record->getDecl());
9557 if (!CXXRecord->
isPOD())
9558 getCurFunction()->setHasBranchProtectedScope();
9583 Var->setInvalidDecl();
9584 else if (Init.
get()) {
9585 Var->setInit(MaybeCreateExprWithCleanups(Init.
get()));
9590 CheckCompleteVariableDeclaration(Var);
9625 llvm_unreachable(
"Unexpected storage class");
9646 const char *PrevSpec;
9649 getPrintingPolicy());
9657 EmptyAttrs, IdentLoc);
9658 Decl *Var = ActOnDeclarator(S, D);
9659 cast<VarDecl>(Var)->setCXXForRangeDecl(
true);
9660 FinalizeDeclaration(Var);
9661 return ActOnDeclStmt(FinalizeDeclaratorGroup(S, DS, Var), IdentLoc,
9662 AttrEnd.
isValid() ? AttrEnd : IdentLoc);
9670 if (getLangOpts().ObjCAutoRefCount &&
9680 getCurFunction()->setHasBranchProtectedScope();
9693 !getDiagnostics().isIgnored(diag::warn_missing_variable_declarations,
9701 Diag(var->
getLocation(), diag::warn_missing_variable_declarations) << var;
9705 const Expr *Culprit;
9711 if (getLangOpts().CPlusPlus11)
9713 }
else if (getLangOpts().CPlusPlus && var->
hasInit() &&
9721 << Culprit->getSourceRange();
9731 ActiveTemplateInstantiations.empty()) {
9735 Stack = &ConstSegStack;
9737 Stack = &BSSSegStack;
9740 Stack = &DataSegStack;
9744 var->
addAttr(SectionAttr::CreateImplicit(
9745 Context, SectionAttr::Declspec_allocate,
9748 if (
const SectionAttr *SA = var->
getAttr<SectionAttr>())
9749 if (UnifySection(SA->getName(), SectionFlags, var))
9755 if (CurInitSeg && var->
getInit())
9756 var->
addAttr(InitSegAttr::CreateImplicit(
Context, CurInitSeg->getString(),
9761 if (!getLangOpts().CPlusPlus)
return;
9767 if (var->
hasAttr<BlocksAttr>()) {
9778 = PerformMoveOrCopyInitialization(
9780 var, var->
getType(), varRef,
true);
9782 result = MaybeCreateExprWithCleanups(result);
9796 !getDiagnostics().isIgnored(diag::warn_global_constructor,
9805 << Init->getSourceRange();
9814 if (Notes.size() == 1 && Notes[0].second.getDiagID() ==
9815 diag::note_invalid_subexpr_in_const_expr) {
9816 DiagLoc = Notes[0].first;
9819 Diag(DiagLoc, diag::err_constexpr_var_requires_const_init)
9820 << var << Init->getSourceRange();
9821 for (
unsigned I = 0, N = Notes.size(); I != N; ++I)
9822 Diag(Notes[I].first, Notes[I].second);
9834 FinalizeVarWithDestructor(var, recordType);
9842 if (I->isAlignmentDependent())
9852 ParsingInitForAutoVars.erase(ThisDecl);
9854 VarDecl *VD = dyn_cast_or_null<VarDecl>(ThisDecl);
9881 auto *NewAttr = cast<InheritableAttr>(A->clone(getASTContext()));
9882 NewAttr->setInherited(
true);
9892 if (
const auto *IA = dyn_cast_or_null<DLLImportAttr>(DLLAttr)) {
9899 bool IsClassTemplateMember =
9900 isa<ClassTemplatePartialSpecializationDecl>(
Context) ||
9904 IsClassTemplateMember
9905 ? diag::warn_attribute_dllimport_static_field_definition
9906 : diag::err_attribute_dllimport_static_field_definition);
9907 Diag(IA->getLocation(), diag::note_attribute);
9908 if (!IsClassTemplateMember)
9932 AddPushedVisibilityAttribute(VD);
9936 !isa<VarTemplatePartialSpecializationDecl>(VD))
9937 MarkUnusedFileScopedDecl(VD);
9941 if (!VD->
hasAttr<TypeTagForDatatypeAttr>() ||
9945 for (
const auto *I : ThisDecl->
specific_attrs<TypeTagForDatatypeAttr>()) {
9947 if (!MagicValueExpr) {
9950 llvm::APSInt MagicValueInt;
9952 Diag(I->getRange().getBegin(),
9953 diag::err_type_tag_for_datatype_not_ice)
9954 << LangOpts.CPlusPlus << MagicValueExpr->getSourceRange();
9957 if (MagicValueInt.getActiveBits() > 64) {
9958 Diag(I->getRange().getBegin(),
9959 diag::err_type_tag_for_datatype_too_large)
9960 << LangOpts.CPlusPlus << MagicValueExpr->getSourceRange();
9963 uint64_t MagicValue = MagicValueInt.getZExtValue();
9964 RegisterTypeTagForDatatype(I->getArgumentKind(),
9966 I->getMatchingCType(),
9967 I->getLayoutCompatible(),
9968 I->getMustBeNull());
9980 for (
unsigned i = 0, e = Group.size(); i != e; ++i)
9981 if (
Decl *D = Group[i]) {
9983 if (!FirstDeclaratorInGroup)
9984 FirstDeclaratorInGroup = DD;
9990 handleTagNumbering(Tag, S);
9991 if (!Tag->hasNameForLinkage() && !Tag->hasDeclaratorForAnonDecl())
9992 Tag->setDeclaratorForAnonDecl(FirstDeclaratorInGroup);
10003 bool TypeMayContainAuto) {
10011 if (TypeMayContainAuto && Group.size() > 1) {
10014 VarDecl *DeducedDecl =
nullptr;
10015 for (
unsigned i = 0, e = Group.size(); i != e; ++i) {
10016 if (
VarDecl *D = dyn_cast<VarDecl>(Group[i])) {
10026 DeducedCanon = UCanon;
10028 }
else if (DeducedCanon != UCanon) {
10030 diag::err_auto_different_deductions)
10034 << DeducedDecl->
getInit()->getSourceRange()
10044 ActOnDocumentableDecls(Group);
10046 return DeclGroupPtrTy::make(
10051 ActOnDocumentableDecls(D);
10056 if (Group.empty() || !Group[0])
10059 if (Diags.isIgnored(diag::warn_doc_param_not_found,
10060 Group[0]->getLocation()) &&
10061 Diags.isIgnored(diag::warn_unknown_comment_command_name,
10062 Group[0]->getLocation()))
10065 if (Group.size() >= 2) {
10073 Decl *MaybeTagDecl = Group[0];
10074 if (MaybeTagDecl && isa<TagDecl>(MaybeTagDecl)) {
10075 Group = Group.slice(1);
10081 if (!Comments.empty() &&
10082 !Comments.back()->isAttached()) {
10090 for (
unsigned i = 0, e = Group.size(); i != e; ++i)
10106 }
else if (getLangOpts().CPlusPlus &&
10111 diag::err_invalid_storage_class_in_func_decl);
10122 DiagnoseFunctionSpecifiers(DS);
10130 CheckExtraCXXDefaultArguments(D);
10146 << GetNameForDeclarator(D).getName();
10156 if (R.isSingleResult()) {
10157 NamedDecl *PrevDecl = R.getFoundDecl();
10162 PrevDecl =
nullptr;
10181 parmDeclType, TInfo,
10195 IdResolver.AddDecl(New);
10197 ProcessDeclAttributes(S, New, D);
10205 if (New->
hasAttr<BlocksAttr>()) {
10230 if (!ActiveTemplateInstantiations.empty())
10233 for (; Param != ParamEnd; ++Param) {
10234 if (!(*Param)->isReferenced() && (*Param)->getDeclName() &&
10235 !(*Param)->hasAttr<UnusedAttr>()) {
10236 Diag((*Param)->getLocation(), diag::warn_unused_parameter)
10237 << (*Param)->getDeclName();
10246 if (LangOpts.NumLargeByValueCopy == 0)
10253 if (Size > LangOpts.NumLargeByValueCopy)
10260 for (; Param != ParamEnd; ++Param) {
10265 if (Size > LangOpts.NumLargeByValueCopy)
10266 Diag((*Param)->getLocation(), diag::warn_parameter_size)
10267 << (*Param)->getDeclName() << Size;
10276 if (getLangOpts().ObjCAutoRefCount &&
10289 NameLoc, diag::err_arc_array_param_no_ownership, T,
false));
10300 TSInfo, SC,
nullptr);
10305 if (!CurContext->isRecord() &&
10306 RequireNonAbstractType(NameLoc, T, diag::err_abstract_type_in_decl,
10307 AbstractParamType))
10315 diag::err_object_cannot_be_passed_returned_by_value) << 1 << T
10328 if (!(getLangOpts().OpenCL && T->
isArrayType())) {
10329 Diag(NameLoc, diag::err_arg_with_address_space);
10344 for (
int i = FTI.
NumParams; i != 0; ) {
10348 llvm::raw_svector_ostream(Code)
10358 const char* PrevSpec;
10367 FTI.
Params[i].
Param = ActOnParamDeclarator(S, ParamD);
10374 assert(getCurFunctionDecl() ==
nullptr &&
"Function parsing confused");
10380 return ActOnStartOfFunctionDef(FnBodyScope, DP);
10384 Consumer.HandleInlineMethodDefinition(D);
10398 if (isa<CXXMethodDecl>(FD))
10418 if (FD->
hasAttr<OpenCLKernelAttr>())
10425 bool MissingPrototype =
true;
10430 if (Prev->getLexicalDeclContext()->isFunctionOrMethod())
10433 MissingPrototype = !Prev->getType()->isFunctionProtoType();
10435 PossibleZeroParamPrototype = Prev;
10439 return MissingPrototype;
10461 if (!hasVisibleDefinition(Definition) &&
10486 LSI->
Lambda = LambdaClass;
10504 for (
const auto &
C : LambdaClass->
captures()) {
10505 if (
C.capturesVariable()) {
10510 const bool ByRef =
C.getCaptureKind() ==
LCK_ByRef;
10512 true,
C.getLocation(),
10513 C.isPackExpansion()
10515 CaptureType,
nullptr);
10517 }
else if (
C.capturesThis()) {
10536 FD = FunTmpl->getTemplatedDecl();
10538 FD = cast<FunctionDecl>(D);
10549 assert(ActiveTemplateInstantiations.size() &&
10550 "There should be an active template instantiation on the stack "
10551 "when instantiating a generic lambda!");
10556 PushFunctionScope();
10560 CheckForFunctionRedefinition(FD);
10576 RequireCompleteType(FD->
getLocation(), ResultType,
10577 diag::err_func_def_incomplete_result))
10581 PushDeclContext(FnBodyScope, FD);
10588 for (
auto Param : FD->
params()) {
10589 Param->setOwningFunction(FD);
10592 if (Param->getIdentifier() && FnBodyScope) {
10593 CheckShadow(FnBodyScope, Param);
10595 PushOnScopeChains(Param, FnBodyScope);
10625 PushOnScopeChains(D, FnBodyScope,
false);
10629 if (
auto *ED = dyn_cast<EnumDecl>(D)) {
10630 for (
auto *EI : ED->enumerators())
10631 PushOnScopeChains(EI, FnBodyScope,
false);
10643 assert(!FD->
hasAttr<DLLExportAttr>());
10644 Diag(FD->
getLocation(), diag::err_attribute_dllimport_function_definition);
10650 ActOnDocumentableDecl(D);
10651 if (getCurLexicalContext()->isObjCContainer() &&
10652 getCurLexicalContext()->getDeclKind() != Decl::ObjCCategoryImpl &&
10653 getCurLexicalContext()->getDeclKind() != Decl::ObjCImplementation)
10674 for (
unsigned I = 0, E = Scope->
Returns.size(); I != E; ++I) {
10675 if (
const VarDecl *NRVOCandidate = Returns[I]->getNRVOCandidate()) {
10676 if (!NRVOCandidate->isNRVOVariable())
10677 Returns[I]->setNRVOCandidate(
nullptr);
10695 Outer.Fun.hasTrailingReturnType()) {
10696 QualType Ty = GetTypeFromParser(Outer.Fun.getTrailingReturnType());
10713 if (FD->isConstexpr() || FD->getReturnType()->isUndeducedType())
10715 return Consumer.shouldSkipFunctionBody(D);
10719 if (
FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(Decl))
10720 FD->setHasSkippedBody();
10721 else if (
ObjCMethodDecl *MD = dyn_cast_or_null<ObjCMethodDecl>(Decl))
10723 return ActOnFinishFunctionBody(Decl,
nullptr);
10727 return ActOnFinishFunctionBody(D, BodyArg,
false);
10731 bool IsInstantiation) {
10751 TypeLoc ResultType = getReturnTypeLoc(FD);
10756 auto *LSI = getCurLambda();
10757 if (LSI->HasImplicitReturnType) {
10758 deduceClosureReturnType(*LSI);
10764 LSI->ReturnType.isNull() ?
Context.
VoidTy : LSI->ReturnType;
10779 UndefinedButUsed.erase(FD);
10781 !LangOpts.GNUInline &&
10783 UndefinedButUsed.erase(FD);
10805 MarkVTableUsed(FD->
getLocation(), Constructor->getParent());
10807 MarkVTableUsed(FD->
getLocation(), Destructor->getParent());
10814 computeNRVO(Body, getCurFunction());
10822 const FunctionDecl *PossibleZeroParamPrototype =
nullptr;
10826 if (PossibleZeroParamPrototype) {
10831 TypeLoc TL = TI->getTypeLoc();
10834 diag::note_declaration_not_a_prototype)
10835 << PossibleZeroParamPrototype
10841 if (
auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
10856 if (KeyFunction && KeyFunction->
isDefined(Definition))
10865 assert((FD == getCurFunctionDecl() || getCurLambda()->CallOperator == FD) &&
10866 "Function parsing confused");
10867 }
else if (
ObjCMethodDecl *MD = dyn_cast_or_null<ObjCMethodDecl>(dcl)) {
10868 assert(MD == getCurMethodDecl() &&
"Method parsing confused");
10876 computeNRVO(Body, getCurFunction());
10878 if (getCurFunction()->ObjCShouldCallSuper) {
10880 << MD->getSelector().getAsString();
10881 getCurFunction()->ObjCShouldCallSuper =
false;
10883 if (getCurFunction()->ObjCWarnForNoDesignatedInitChain) {
10885 bool isDesignated =
10886 MD->isDesignatedInitializerForTheInterface(&InitMethod);
10887 assert(isDesignated && InitMethod);
10888 (void)isDesignated;
10891 auto IFace = MD->getClassInterface();
10894 auto SuperD = IFace->getSuperClass();
10904 diag::warn_objc_designated_init_missing_super_call);
10906 diag::note_objc_designated_init_marked_here);
10908 getCurFunction()->ObjCWarnForNoDesignatedInitChain =
false;
10910 if (getCurFunction()->ObjCWarnForNoInitDelegation) {
10914 diag::warn_objc_secondary_init_missing_init_call);
10915 getCurFunction()->ObjCWarnForNoInitDelegation =
false;
10921 assert(!getCurFunction()->ObjCShouldCallSuper &&
10922 "This should only be set for ObjC methods, which should have been "
10923 "handled in the block above.");
10930 if (FD && isa<CXXConstructorDecl>(FD) && isa<CXXTryStmt>(Body))
10931 DiagnoseReturnInConstructorExceptionHandler(cast<CXXTryStmt>(Body));
10934 if (getCurFunction()->NeedsScopeChecking() &&
10935 !PP.isCodeCompletionEnabled())
10936 DiagnoseInvalidJumps(Body);
10939 if (!Destructor->getParent()->isDependentType())
10940 CheckDestructor(Destructor);
10942 MarkBaseAndMemberDestructorsReferenced(Destructor->getLocation(),
10943 Destructor->getParent());
10949 if (getDiagnostics().hasErrorOccurred() ||
10950 getDiagnostics().getSuppressAllDiagnostics()) {
10951 DiscardCleanupsInEvaluationContext();
10953 if (!getDiagnostics().hasUncompilableErrorOccurred() &&
10954 !isa<FunctionTemplateDecl>(dcl)) {
10957 ActivePolicy = &WP;
10961 (!CheckConstexprFunctionDecl(FD) ||
10962 !CheckConstexprFunctionBody(FD, Body)))
10965 if (FD && FD->
hasAttr<NakedAttr>()) {
10966 for (
const Stmt *S : Body->children()) {
10967 if (!isa<AsmStmt>(S) && !isa<NullStmt>(
S)) {
10968 Diag(S->getLocStart(), diag::err_non_asm_stmt_in_naked_function);
10969 Diag(FD->
getAttr<NakedAttr>()->getLocation(), diag::note_attribute);
10976 assert(ExprCleanupObjects.size() ==
10977 ExprEvalContexts.back().NumCleanupObjects &&
10978 "Leftover temporaries in function");
10979 assert(!ExprNeedsCleanups &&
"Unaccounted cleanups in function");
10980 assert(MaybeODRUseExprs.empty() &&
10981 "Leftover expressions for odr-use checking");
10984 if (!IsInstantiation)
10987 PopFunctionScopeInfo(ActivePolicy, dcl);
10991 if (getDiagnostics().hasErrorOccurred()) {
10992 DiscardCleanupsInEvaluationContext();
11005 D = TD->getTemplatedDecl();
11006 ProcessDeclAttributeList(S, D, Attrs.
getList());
11008 if (
CXXMethodDecl *Method = dyn_cast_or_null<CXXMethodDecl>(D))
11009 if (Method->isStatic())
11010 checkThisInStaticMemberFunctionAttributes(Method);
11022 if (
NamedDecl *ExternCPrev = findLocallyScopedExternCDecl(&II)) {
11023 Diag(Loc, diag::warn_use_out_of_scope_declaration) << ExternCPrev;
11024 Diag(ExternCPrev->getLocation(), diag::note_previous_declaration);
11025 return ExternCPrev;
11030 if (II.
getName().startswith(
"__builtin_"))
11031 diag_id = diag::warn_builtin_unknown;
11032 else if (getLangOpts().C99)
11033 diag_id = diag::ext_implicit_function_decl;
11035 diag_id = diag::warn_implicit_function_decl;
11036 Diag(Loc, diag_id) << &II;
11043 (Corrected = CorrectTypo(
11046 diagnoseTypo(Corrected, PDiag(diag::note_function_suggestion),
11058 assert(!Error &&
"Error setting up implicit decl!");
11092 FunctionDecl *FD = cast<FunctionDecl>(ActOnDeclarator(TUScope, D));
11095 CurContext = PrevDC;
11097 AddKnownFunctionAttributes(FD);
11119 unsigned FormatIdx;
11122 if (!FD->
hasAttr<FormatAttr>()) {
11123 const char *fmt =
"printf";
11125 if (FormatIdx < NumParams &&
11131 HasVAListArg ? 0 : FormatIdx+2,
11137 if (!FD->
hasAttr<FormatAttr>())
11141 HasVAListArg ? 0 : FormatIdx+2,
11148 if (!getLangOpts().MathErrno &&
11150 if (!FD->
hasAttr<ConstAttr>())
11155 !FD->
hasAttr<ReturnsTwiceAttr>())
11177 if (Name->
isStr(
"asprintf") || Name->
isStr(
"vasprintf")) {
11180 if (!FD->
hasAttr<FormatAttr>())
11183 Name->
isStr(
"vasprintf") ? 0 : 3,
11187 if (Name->
isStr(
"__CFStringMakeConstantString")) {
11190 if (!FD->
hasAttr<FormatArgAttr>())
11198 assert(D.
getIdentifier() &&
"Wrong callback for declspec without declarator");
11199 assert(!T.
isNull() &&
"GetTypeForDeclarator() returned null type");
11202 assert(D.
isInvalidType() &&
"no declarator info for valid type");
11220 if (CurContext->isFunctionOrMethod())
11242 setTagNameForLinkagePurposes(tagFromDeclSpec, NewTD);
11263 if (BT->isInteger())
11266 Diag(UnderlyingLoc, diag::err_enum_invalid_underlying) << T;
11275 bool IsFixed = !EnumUnderlyingTy.
isNull();
11277 if (IsScoped != Prev->
isScoped()) {
11278 Diag(EnumLoc, diag::err_enum_redeclare_scoped_mismatch)
11284 if (IsFixed && Prev->
isFixed()) {
11290 Diag(EnumLoc, diag::err_enum_redeclare_type_mismatch)
11296 }
else if (IsFixed != Prev->
isFixed()) {
11297 Diag(EnumLoc, diag::err_enum_redeclare_fixed_mismatch)
11316 default: llvm_unreachable(
"Invalid tag kind for redecl diagnostic!");
11352 if (OldTag == NewTag)
11358 if (
const CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(Previous))
11359 isTemplate = Record->getDescribedClassTemplate();
11361 if (!ActiveTemplateInstantiations.empty()) {
11364 Diag(NewTagLoc, diag::warn_struct_class_tag_mismatch)
11370 if (isDefinition) {
11378 bool previousMismatch =
false;
11379 for (
auto I : Previous->
redecls()) {
11380 if (I->getTagKind() != NewTag) {
11381 if (!previousMismatch) {
11382 previousMismatch =
true;
11383 Diag(NewTagLoc, diag::warn_struct_class_previous_tag_mismatch)
11387 Diag(I->getInnerLocStart(), diag::note_struct_class_suggestion)
11405 Diag(NewTagLoc, diag::warn_struct_class_tag_mismatch)
11412 Diag(NewTagLoc, diag::note_struct_class_suggestion)
11446 Namespaces.push_back(II);
11449 if (Lookup == Namespace)
11456 llvm::raw_svector_ostream OS(Insertion);
11459 std::reverse(Namespaces.begin(), Namespaces.end());
11460 for (
auto *II : Namespaces)
11461 OS << II->getName() <<
"::";
11475 if (OldDC->
Equals(NewDC))
11503 bool &OwnedDecl,
bool &IsDependent,
11505 bool ScopedEnumUsesClassTag,
11510 assert((Name !=
nullptr || TUK == TUK_Definition) &&
11511 "Nameless record must be a definition!");
11512 assert(TemplateParameterLists.size() == 0 || TUK != TUK_Reference);
11516 bool ScopedEnum = ScopedEnumKWLoc.
isValid();
11519 bool isExplicitSpecialization =
false;
11520 bool Invalid =
false;
11525 if (TemplateParameterLists.size() > 0 ||
11526 (SS.
isNotEmpty() && TUK != TUK_Reference)) {
11528 MatchTemplateParametersToScopeSpecifier(
11529 KWLoc, NameLoc, SS,
nullptr, TemplateParameterLists,
11530 TUK == TUK_Friend, isExplicitSpecialization, Invalid)) {
11532 Diag(KWLoc, diag::err_enum_template);
11536 if (TemplateParams->size() > 0) {
11545 SS, Name, NameLoc, Attr,
11546 TemplateParams, AS,
11549 TemplateParameterLists.size()-1,
11550 TemplateParameterLists.data(),
11552 return Result.
get();
11555 Diag(TemplateParams->getTemplateLoc(), diag::err_template_tag_noparams)
11557 isExplicitSpecialization =
true;
11565 llvm::PointerUnion<const Type*, TypeSourceInfo*> EnumUnderlying;
11568 if (UnderlyingType.
isInvalid() || (!UnderlyingType.
get() && ScopedEnum))
11572 else if (UnderlyingType.
get()) {
11576 GetTypeFromParser(UnderlyingType.
get(), &TI);
11577 EnumUnderlying = TI;
11579 if (CheckEnumUnderlyingType(TI))
11584 UPPC_FixedUnderlyingType))
11587 }
else if (getLangOpts().MSVCCompat)
11594 bool isStdBadAlloc =
false;
11597 if (TUK == TUK_Friend || TUK == TUK_Reference)
11598 Redecl = NotForRedeclaration;
11607 goto CreateNewDecl;
11612 if (TUK == TUK_Friend || TUK == TUK_Reference) {
11613 DC = computeDeclContext(SS,
false);
11615 IsDependent =
true;
11619 DC = computeDeclContext(SS,
true);
11627 if (RequireCompleteDeclContext(SS, DC))
11632 LookupQualifiedName(Previous, DC);
11637 if (Previous.
empty()) {
11645 (TUK == TUK_Reference || TUK == TUK_Friend)) {
11646 IsDependent =
true;
11651 Diag(NameLoc, diag::err_not_tag_in_scope)
11652 << Kind << Name << DC << SS.
getRange();
11655 goto CreateNewDecl;
11662 if (TUK != TUK_Reference && TUK != TUK_Friend &&
11671 LookupName(Previous, S);
11676 (TUK == TUK_Definition || TUK == TUK_Declaration)) {
11699 if (!Previous.
empty() && TUK == TUK_Friend) {
11702 bool FriendSawTagOutsideEnclosingNamespace =
false;
11708 if (getLangOpts().MSVCCompat)
11709 FriendSawTagOutsideEnclosingNamespace =
true;
11718 if (Previous.
isSingleResult() && FriendSawTagOutsideEnclosingNamespace) {
11720 Diag(NameLoc, diag::ext_friend_tag_redecl_outside_namespace)
11729 if (!getLangOpts().CPlusPlus && TUK != TUK_Reference) {
11734 while (isa<RecordDecl>(SearchDC) || isa<EnumDecl>(SearchDC))
11742 DiagnoseTemplateParameterShadow(NameLoc, Previous.
getFoundDecl());
11747 if (getLangOpts().
CPlusPlus && Name && DC && StdNamespace &&
11748 DC->
Equals(getStdNamespace()) && Name->
isStr(
"bad_alloc")) {
11750 isStdBadAlloc =
true;
11752 if (Previous.
empty() && StdBadAlloc) {
11756 Previous.
addDecl(getStdBadAlloc());
11764 if (Name && Previous.
empty() &&
11765 (TUK == TUK_Reference || TUK == TUK_Friend)) {
11766 if (Invalid)
goto CreateNewDecl;
11769 if (TUK == TUK_Reference) {
11803 (getLangOpts().CPlusPlus &&
11809 assert(TUK == TUK_Friend);
11821 LookupQualifiedName(Previous, SearchDC);
11829 if (!Previous.
empty()) {
11845 TagDecl *Tag = TT->getDecl();
11848 ->
Equals(TD->getDeclContext()->getRedeclContext())) {
11861 if (
auto *Shadow = dyn_cast<UsingShadowDecl>(DirectPrevDecl)) {
11862 auto *OldTag = dyn_cast<
TagDecl>(PrevDecl);
11863 if (SS.
isEmpty() && TUK != TUK_Reference && TUK != TUK_Friend &&
11864 isDeclInScope(Shadow, SearchDC, S, isExplicitSpecialization) &&
11866 *
this, OldTag->getDeclContext(), SearchDC))) {
11867 Diag(KWLoc, diag::err_using_decl_conflict_reverse);
11868 Diag(Shadow->getTargetDecl()->getLocation(),
11869 diag::note_using_decl_target);
11870 Diag(Shadow->getUsingDecl()->getLocation(), diag::note_using_decl)
11874 goto CreateNewDecl;
11878 if (
TagDecl *PrevTagDecl = dyn_cast<TagDecl>(PrevDecl)) {
11882 if (TUK == TUK_Reference || TUK == TUK_Friend ||
11883 isDeclInScope(DirectPrevDecl, SearchDC, S,
11884 SS.
isNotEmpty() || isExplicitSpecialization)) {
11887 if (!isAcceptableTagRedeclaration(PrevTagDecl, Kind,
11888 TUK == TUK_Definition, KWLoc,
11890 bool SafeToContinue
11891 = (PrevTagDecl->getTagKind() !=
TTK_Enum &&
11893 if (SafeToContinue)
11894 Diag(KWLoc, diag::err_use_with_wrong_tag)
11897 PrevTagDecl->getKindName());
11899 Diag(KWLoc, diag::err_use_with_wrong_tag) << Name;
11900 Diag(PrevTagDecl->getLocation(), diag::note_previous_use);
11902 if (SafeToContinue)
11903 Kind = PrevTagDecl->getTagKind();
11913 const EnumDecl *PrevEnum = cast<EnumDecl>(PrevTagDecl);
11917 if (TUK == TUK_Reference || TUK == TUK_Friend) {
11919 Diag(ScopedEnumKWLoc, diag::err_enum_class_reference)
11922 return PrevTagDecl;
11927 EnumUnderlyingTy = TI->getType().getUnqualifiedType();
11928 else if (
const Type *T = EnumUnderlying.dyn_cast<
const Type*>())
11929 EnumUnderlyingTy =
QualType(T, 0);
11934 if (CheckEnumRedeclaration(NameLoc.
isValid() ? NameLoc : KWLoc,
11935 ScopedEnum, EnumUnderlyingTy, PrevEnum))
11936 return TUK == TUK_Declaration ? PrevTagDecl :
nullptr;
11945 Diag(NameLoc, diag::ext_member_redeclared);
11946 Diag(PrevTagDecl->getLocation(), diag::note_previous_declaration);
11958 ((TUK == TUK_Reference &&
11959 (!PrevTagDecl->getFriendObjectKind() || getLangOpts().MicrosoftExt))
11960 || TUK == TUK_Friend))
11961 return PrevTagDecl;
11964 if (TUK == TUK_Definition) {
11965 if (
NamedDecl *Def = PrevTagDecl->getDefinition()) {
11969 bool IsExplicitSpecializationAfterInstantiation =
false;
11970 if (isExplicitSpecialization) {
11972 IsExplicitSpecializationAfterInstantiation =
11973 RD->getTemplateSpecializationKind() !=
11975 else if (
EnumDecl *ED = dyn_cast<EnumDecl>(Def))
11976 IsExplicitSpecializationAfterInstantiation =
11977 ED->getTemplateSpecializationKind() !=
11982 if (SkipBody && getLangOpts().
CPlusPlus &&
11983 !hasVisibleDefinition(Def, &Hidden)) {
11990 makeMergedDefinitionVisible(Hidden, KWLoc);
11992 }
else if (!IsExplicitSpecializationAfterInstantiation) {
11996 Diag(NameLoc, diag::warn_redefinition_in_param_list) << Name;
11998 Diag(NameLoc, diag::err_redefinition) << Name;
11999 Diag(Def->getLocation(), diag::note_previous_definition);
12011 if (TD->isBeingDefined()) {
12012 Diag(NameLoc, diag::err_nested_redefinition) << Name;
12013 Diag(PrevTagDecl->getLocation(),
12014 diag::note_previous_definition);
12028 if (TUK == TUK_Friend || TUK == TUK_Reference) {
12029 SearchDC = PrevTagDecl->getDeclContext();
12055 if ((TUK == TUK_Reference || TUK == TUK_Friend) &&
12058 if (isa<TypedefDecl>(PrevDecl)) Kind = 1;
12059 else if (isa<TypeAliasDecl>(PrevDecl)) Kind = 2;
12060 else if (isa<ClassTemplateDecl>(PrevDecl)) Kind = 3;
12061 Diag(NameLoc, diag::err_tag_reference_non_tag) <<
Kind;
12066 }
else if (!isDeclInScope(DirectPrevDecl, SearchDC, S,
12067 SS.
isNotEmpty() || isExplicitSpecialization)) {
12071 }
else if (TUK == TUK_Reference || TUK == TUK_Friend) {
12073 if (isa<TypedefDecl>(PrevDecl)) Kind = 1;
12074 else if (isa<TypeAliasDecl>(PrevDecl)) Kind = 2;
12075 else if (isa<ClassTemplateDecl>(PrevDecl)) Kind = 3;
12076 Diag(NameLoc, diag::err_tag_reference_conflict) <<
Kind;
12082 }
else if (
TypedefNameDecl *TND = dyn_cast<TypedefNameDecl>(PrevDecl)) {
12084 if (isa<TypeAliasDecl>(PrevDecl)) Kind = 1;
12085 Diag(NameLoc, diag::err_tag_definition_of_typedef)
12086 << Name << Kind << TND->getUnderlyingType();
12094 Diag(NameLoc, diag::err_redefinition_different_kind) << Name;
12122 bool IsForwardReference =
false;
12127 cast_or_null<EnumDecl>(PrevDecl), ScopedEnum,
12128 ScopedEnumUsesClassTag, !EnumUnderlying.isNull());
12130 if (TUK != TUK_Definition && !Invalid) {
12132 if ((getLangOpts().
CPlusPlus11 || getLangOpts().ObjC2) &&
12133 cast<EnumDecl>(New)->isFixed()) {
12137 else if (PrevDecl && (Def = cast<EnumDecl>(PrevDecl)->
getDefinition())) {
12138 Diag(Loc, diag::ext_forward_ref_enum_def)
12142 unsigned DiagID = diag::ext_forward_ref_enum;
12143 if (getLangOpts().MSVCCompat)
12144 DiagID = diag::ext_ms_forward_ref_enum;
12145 else if (getLangOpts().CPlusPlus)
12146 DiagID = diag::err_forward_ref_enum;
12152 if (TUK == TUK_Reference)
12153 IsForwardReference =
true;
12157 if (EnumUnderlying) {
12158 EnumDecl *ED = cast<EnumDecl>(New);
12171 if (getLangOpts().CPlusPlus) {
12174 cast_or_null<CXXRecordDecl>(PrevDecl));
12176 if (isStdBadAlloc && (!StdBadAlloc || getStdBadAlloc()->isImplicit()))
12177 StdBadAlloc = cast<CXXRecordDecl>(New);
12180 cast_or_null<RecordDecl>(PrevDecl));
12185 if (getLangOpts().
CPlusPlus && IsTypeSpecifier && TUK == TUK_Definition) {
12199 if (!isExplicitSpecialization &&
12200 (TUK == TUK_Definition || TUK == TUK_Declaration) &&
12201 diagnoseQualifiedDeclaration(SS, DC, OrigName, Loc))
12205 if (TemplateParameterLists.size() > 0) {
12207 TemplateParameterLists.size(),
12208 TemplateParameterLists.data());
12215 if (
RecordDecl *RD = dyn_cast<RecordDecl>(New)) {
12225 if (TUK == TUK_Definition) {
12226 AddAlignmentAttributesForRecord(RD);
12227 AddMsStructLayoutForRecord(RD);
12231 if (ModulePrivateLoc.
isValid()) {
12232 if (isExplicitSpecialization)
12245 if (isExplicitSpecialization && CheckMemberSpecialization(New, Previous))
12252 getNonFieldDeclScope(S)->isFunctionPrototypeScope()) {
12256 if (TUK == TUK_Definition && !IsTypeSpecifier) {
12257 Diag(Loc, diag::err_type_defined_in_param_type)
12264 DeclsInPrototypeScope.push_back(New);
12271 ProcessDeclAttributeList(S, New, Attr);
12281 if (TUK == TUK_Friend)
12285 if (!Invalid && SearchDC->
isRecord())
12286 SetMemberAccessSpecifier(New, PrevDecl, AS);
12288 if (TUK == TUK_Definition)
12292 if (TUK == TUK_Friend) {
12301 if (
Scope *EnclosingScope = getScopeForDeclContext(S, DC))
12302 PushOnScopeChains(New, EnclosingScope,
false);
12304 S = getNonFieldDeclScope(S);
12305 PushOnScopeChains(New, S, !IsForwardReference);
12306 if (IsForwardReference)
12310 CurContext->addDecl(New);
12321 mergeDeclAttributes(New, PrevDecl);
12325 AddPushedVisibilityAttribute(New);
12330 return (Invalid && getLangOpts().
CPlusPlus) ?
nullptr : New;
12334 AdjustDeclIfTemplate(TagD);
12335 TagDecl *Tag = cast<TagDecl>(TagD);
12338 PushDeclContext(S, Tag);
12340 ActOnDocumentableDecl(TagD);
12344 AddPushedVisibilityAttribute(Tag);
12348 assert(isa<ObjCContainerDecl>(IDecl) &&
12349 "ActOnObjCContainerStartDefinition - Not ObjCContainerDecl");
12351 assert(getContainingDC(OCD) == CurContext &&
12352 "The next DeclContext should be lexically contained in the current one.");
12359 bool IsFinalSpelledSealed,
12361 AdjustDeclIfTemplate(TagD);
12364 FieldCollector->StartClass();
12371 FinalAttr(FinalLoc,
Context, IsFinalSpelledSealed));
12389 PushOnScopeChains(InjectedClassName, S);
12391 "Broken injected-class-name");
12396 AdjustDeclIfTemplate(TagD);
12397 TagDecl *Tag = cast<TagDecl>(TagD);
12402 assert(Tag->
isInvalidDecl() &&
"We should already have completed it");
12403 if (
RecordDecl *RD = dyn_cast<RecordDecl>(Tag))
12404 RD->completeDefinition();
12407 if (isa<CXXRecordDecl>(Tag))
12408 FieldCollector->FinishClass();
12413 if (getCurLexicalContext()->isObjCContainer() &&
12419 Consumer.HandleTagDeclDefinition(Tag);
12428 assert(DC == CurContext &&
"Mismatch of container contexts");
12429 OriginalLexicalContext = DC;
12430 ActOnObjCContainerFinishDefinition();
12434 ActOnObjCContainerStartDefinition(cast<Decl>(DC));
12435 OriginalLexicalContext =
nullptr;
12439 AdjustDeclIfTemplate(TagD);
12440 TagDecl *Tag = cast<TagDecl>(TagD);
12445 if (
RecordDecl *RD = dyn_cast<RecordDecl>(Tag))
12446 RD->completeDefinition();
12459 QualType FieldTy,
bool IsMsStruct,
12460 Expr *BitWidth,
bool *ZeroWidth) {
12469 if (RequireCompleteType(FieldLoc, FieldTy, diag::err_field_incomplete))
12472 return Diag(FieldLoc, diag::err_not_integral_type_bitfield)
12473 << FieldName << FieldTy << BitWidth->getSourceRange();
12474 return Diag(FieldLoc, diag::err_not_integral_type_anon_bitfield)
12475 << FieldTy << BitWidth->getSourceRange();
12476 }
else if (DiagnoseUnexpandedParameterPack(const_cast<Expr *>(BitWidth),
12477 UPPC_BitFieldWidth))
12485 llvm::APSInt
Value;
12486 ExprResult ICE = VerifyIntegerConstantExpression(BitWidth, &Value);
12489 BitWidth = ICE.
get();
12491 if (Value != 0 && ZeroWidth)
12492 *ZeroWidth =
false;
12495 if (Value == 0 && FieldName)
12496 return Diag(FieldLoc, diag::err_bitfield_has_zero_width) << FieldName;
12498 if (Value.isSigned() && Value.isNegative()) {
12500 return Diag(FieldLoc, diag::err_bitfield_has_negative_width)
12501 << FieldName << Value.toString(10);
12502 return Diag(FieldLoc, diag::err_anon_bitfield_has_negative_width)
12503 << Value.toString(10);
12508 if (Value.getZExtValue() > TypeSize) {
12509 if (!getLangOpts().CPlusPlus || IsMsStruct ||
12512 return Diag(FieldLoc, diag::err_bitfield_width_exceeds_type_size)
12513 << FieldName << (
unsigned)Value.getZExtValue()
12516 return Diag(FieldLoc, diag::err_anon_bitfield_width_exceeds_type_size)
12521 Diag(FieldLoc, diag::warn_bitfield_width_exceeds_type_size)
12522 << FieldName << (
unsigned)Value.getZExtValue()
12525 Diag(FieldLoc, diag::warn_anon_bitfield_width_exceeds_type_size)
12537 FieldDecl *Res = HandleField(S, cast_or_null<RecordDecl>(TagD),
12538 DeclStart, D, static_cast<Expr*>(BitfieldWidth),
12557 CheckExtraCXXDefaultArguments(D);
12560 UPPC_DataMemberType)) {
12569 Diag(Loc, diag::err_field_with_address_space);
12575 if (LangOpts.OpenCL && T->
isEventT()) {
12576 Diag(Loc, diag::err_event_t_struct_field);
12584 diag::err_invalid_thread)
12590 LookupName(Previous, S);
12612 PrevDecl =
nullptr;
12615 if (PrevDecl && !isDeclInScope(PrevDecl, Record, S))
12616 PrevDecl =
nullptr;
12622 = CheckFieldDecl(II, T, TInfo, Record, Loc, Mutable, BitWidth, InitStyle,
12623 TSSL, AS, PrevDecl, &D);
12635 PushOnScopeChains(NewFD, S);
12655 bool Mutable,
Expr *BitWidth,
12661 bool InvalidDecl =
false;
12667 InvalidDecl =
true;
12673 if (RequireCompleteType(Loc, EltTy, diag::err_field_incomplete)) {
12676 InvalidDecl =
true;
12682 InvalidDecl =
true;
12688 if (BitWidth && getLangOpts().OpenCL) {
12689 Diag(Loc, diag::err_opencl_bitfields);
12690 InvalidDecl =
true;
12696 bool SizeIsNegative;
12697 llvm::APSInt Oversized;
12704 Diag(Loc, diag::warn_illegal_constant_array_size);
12705 TInfo = FixedTInfo;
12708 if (SizeIsNegative)
12709 Diag(Loc, diag::err_typecheck_negative_array_size);
12710 else if (Oversized.getBoolValue())
12711 Diag(Loc, diag::err_array_too_large)
12712 << Oversized.toString(10);
12714 Diag(Loc, diag::err_typecheck_field_variable_size);
12715 InvalidDecl =
true;
12720 if (!InvalidDecl && RequireNonAbstractType(Loc, T,
12721 diag::err_abstract_type_in_decl,
12722 AbstractFieldType))
12723 InvalidDecl =
true;
12725 bool ZeroWidth =
false;
12727 BitWidth =
nullptr;
12733 InvalidDecl =
true;
12734 BitWidth =
nullptr;
12740 if (!InvalidDecl && Mutable) {
12741 unsigned DiagID = 0;
12743 DiagID = getLangOpts().MSVCCompat ? diag::ext_mutable_reference
12744 : diag::err_mutable_reference;
12746 DiagID = diag::err_mutable_const;
12752 Diag(ErrLoc, DiagID);
12753 if (DiagID != diag::ext_mutable_reference) {
12755 InvalidDecl =
true;
12767 BitWidth, Mutable, InitStyle);
12771 if (PrevDecl && !isa<TagDecl>(PrevDecl)) {
12772 Diag(Loc, diag::err_duplicate_member) << II;
12777 if (!InvalidDecl && getLangOpts().
CPlusPlus) {
12787 if (CheckNontrivialField(NewFD))
12797 diag::ext_union_member_of_reference_type :
12798 diag::err_union_member_of_reference_type)
12800 if (!getLangOpts().MicrosoftExt)
12810 ProcessDeclAttributes(getCurScope(), NewFD, *D);
12813 CheckAlignasUnderalignment(NewFD);
12818 if (getLangOpts().ObjCAutoRefCount && inferObjCARCLifetime(NewFD))
12822 Diag(Loc, diag::warn_attribute_weak_on_field);
12830 assert(getLangOpts().
CPlusPlus &&
"valid check only for C++");
12850 member = CXXCopyConstructor;
12852 member = CXXDefaultConstructor;
12854 member = CXXCopyAssignment;
12856 member = CXXDestructor;
12858 if (member != CXXInvalid) {
12859 if (!getLangOpts().CPlusPlus11 &&
12867 if (getSourceManager().isInSystemHeader(Loc)) {
12868 if (!FD->
hasAttr<UnavailableAttr>())
12870 "this system field has retaining ownership",
12877 diag::warn_cxx98_compat_nontrivial_union_or_anon_struct_member :
12878 diag::err_illegal_union_or_anon_struct_member)
12880 DiagnoseNontrivial(RDecl, member);
12881 return !getLangOpts().CPlusPlus11;
12893 switch (ivarVisibility) {
12894 default: llvm_unreachable(
"Unknown visitibility kind");
12910 Expr *BitWidth = (
Expr*)BitfieldWidth;
12922 BitWidth = VerifyBitField(Loc, II, T,
false, BitWidth).get();
12932 Diag(Loc, diag::err_ivar_reference_type);
12938 Diag(Loc, diag::err_typecheck_ivar_variable_size);
12952 dyn_cast<ObjCImplementationDecl>(EnclosingDecl)) {
12953 if (LangOpts.ObjCRuntime.isFragile()) {
12955 EnclosingContext = IMPDecl->getClassInterface();
12956 assert(EnclosingContext &&
"Implementation has no class interface!");
12959 EnclosingContext = EnclosingDecl;
12962 dyn_cast<ObjCCategoryDecl>(EnclosingDecl)) {
12963 if (LangOpts.ObjCRuntime.isFragile() || !CDecl->IsClassExtension()) {
12964 Diag(Loc, diag::err_misplaced_ivar) << CDecl->IsClassExtension();
12968 EnclosingContext = EnclosingDecl;
12973 DeclStart, Loc, II, T,
12974 TInfo, ac, (
Expr *)BitfieldWidth);
12977 NamedDecl *PrevDecl = LookupSingleName(S, II, Loc, LookupMemberName,
12979 if (PrevDecl && isDeclInScope(PrevDecl, EnclosingContext, S)
12980 && !isa<TagDecl>(PrevDecl)) {
12981 Diag(Loc, diag::err_duplicate_member) << II;
12988 ProcessDeclAttributes(S, NewID, D);
12994 if (getLangOpts().ObjCAutoRefCount && inferObjCARCLifetime(NewID))
13004 IdResolver.AddDecl(NewID);
13007 if (LangOpts.ObjCRuntime.isNonFragile() &&
13008 !NewID->
isInvalidDecl() && isa<ObjCInterfaceDecl>(EnclosingDecl))
13009 Diag(Loc, diag::warn_ivars_in_interface);
13020 if (LangOpts.ObjCRuntime.isFragile() || AllIvarDecls.empty())
13023 Decl *ivarDecl = AllIvarDecls[AllIvarDecls.size()-1];
13031 if (!CD->IsClassExtension())
13043 DeclLoc, DeclLoc,
nullptr,
13049 AllIvarDecls.push_back(Ivar);
13055 assert(EnclosingDecl &&
"missing record or interface decl");
13060 if (!Fields.empty() && isa<ObjCContainerDecl>(EnclosingDecl)) {
13064 case Decl::ObjCCategory:
13067 case Decl::ObjCImplementation:
13069 ResetObjCLayout(cast<ObjCImplementationDecl>(DC)->getClassInterface());
13078 unsigned NumNamedMembers = 0;
13080 for (
const auto *I : Record->
decls()) {
13081 if (
const auto *IFD = dyn_cast<IndirectFieldDecl>(I))
13082 if (IFD->getDeclName())
13090 bool ARCErrReported =
false;
13100 RecFields.push_back(FD);
13128 ((i + 1 == Fields.end() && !Record->
isUnion()) ||
13129 ((getLangOpts().MicrosoftExt ||
13131 (i + 1 == Fields.end() || Record->
isUnion())))) {
13136 unsigned DiagID = 0;
13138 DiagID = getLangOpts().MicrosoftExt
13139 ? diag::ext_flexible_array_union_ms
13140 : getLangOpts().CPlusPlus
13141 ? diag::ext_flexible_array_union_gnu
13142 : diag::err_flexible_array_union;
13143 else if (Fields.size() == 1)
13144 DiagID = getLangOpts().MicrosoftExt
13145 ? diag::ext_flexible_array_empty_aggregate_ms
13146 : getLangOpts().CPlusPlus
13147 ? diag::ext_flexible_array_empty_aggregate_gnu
13148 : NumNamedMembers < 1
13149 ? diag::err_flexible_array_empty_aggregate
13161 if (RD->getNumVBases() != 0)
13164 if (!getLangOpts().
C99)
13175 Diag(FD->
getLocation(), diag::err_flexible_array_has_nontrivial_dtor)
13185 diag::err_field_incomplete)) {
13199 if (i + 1 != Fields.end())
13210 if (isa<ObjCContainerDecl>(EnclosingDecl) &&
13212 diag::err_abstract_type_in_decl,
13213 AbstractIvarType)) {
13227 }
else if (getLangOpts().ObjCAutoRefCount && Record && !ARCErrReported &&
13238 if (getSourceManager().isInSystemHeader(loc)) {
13239 if (!FD->
hasAttr<UnavailableAttr>()) {
13241 "this system field has retaining ownership",
13248 ARCErrReported =
true;
13250 }
else if (getLangOpts().ObjC1 &&
13275 bool Completed =
false;
13276 if (
CXXRecordDecl *CXXRecord = dyn_cast<CXXRecordDecl>(Record)) {
13277 if (!CXXRecord->isInvalidDecl()) {
13280 I = CXXRecord->conversion_begin(),
13281 E = CXXRecord->conversion_end(); I != E; ++I)
13282 I.setAccess((*I)->getAccess());
13284 if (!CXXRecord->isDependentType()) {
13285 if (CXXRecord->hasUserDeclaredDestructor()) {
13287 if (getLangOpts().CPlusPlus11)
13288 AdjustDestructorExceptionSpec(CXXRecord,
13289 CXXRecord->getDestructor());
13293 AddImplicitlyDeclaredMembersToClass(CXXRecord);
13298 if (CXXRecord->getNumVBases()) {
13300 CXXRecord->getFinalOverriders(FinalOverriders);
13302 for (CXXFinalOverriderMap::iterator M = FinalOverriders.begin(),
13303 MEnd = FinalOverriders.end();
13306 SOEnd = M->second.end();
13307 SO != SOEnd; ++SO) {
13308 assert(SO->second.size() > 0 &&
13309 "Virtual function without overridding functions?");
13310 if (SO->second.size() == 1)
13318 << (
const NamedDecl *)M->first << Record;
13319 Diag(M->first->getLocation(),
13320 diag::note_overridden_virtual_function);
13322 OM = SO->second.begin(),
13323 OMEnd = SO->second.end();
13325 Diag(OM->Method->getLocation(), diag::note_final_overrider)
13326 << (
const NamedDecl *)M->first << OM->Method->getParent();
13331 CXXRecord->completeDefinition(&FinalOverriders);
13342 CheckAlignasUnderalignment(Record);
13344 if (
const MSInheritanceAttr *IA = Record->
getAttr<MSInheritanceAttr>())
13345 checkMSInheritanceAttrOnDefinition(cast<CXXRecordDecl>(Record),
13346 IA->getRange(), IA->getBestCase(),
13347 IA->getSemanticSpelling());
13353 bool CheckForZeroSize;
13354 if (!getLangOpts().CPlusPlus) {
13355 CheckForZeroSize =
true;
13364 if (CheckForZeroSize) {
13365 bool ZeroSize =
true;
13366 bool IsEmpty =
true;
13367 unsigned NonBitFields = 0;
13370 (NonBitFields == 0 || ZeroSize) && I != E; ++I) {
13372 if (I->isUnnamedBitfield()) {
13373 if (I->getBitWidthValue(
Context) > 0)
13377 QualType FieldType = I->getType();
13389 diag::warn_zero_size_struct_union_in_extern_c :
13390 diag::warn_zero_size_struct_union_compat)
13391 << IsEmpty << Record->
isUnion() << (NonBitFields > 1);
13396 if (NonBitFields == 0 && !getLangOpts().CPlusPlus) {
13397 Diag(RecLoc, IsEmpty ? diag::ext_empty_struct_union :
13398 diag::ext_no_named_members_in_struct_union)
13406 ID->setEndOfDefinitionLoc(RBrac);
13408 for (
unsigned i = 0, e = RecFields.size(); i != e; ++i) {
13410 ID->addDecl(ClsFields[i]);
13414 if (
ID->getSuperClass())
13415 DiagnoseDuplicateIvars(
ID,
ID->getSuperClass());
13417 dyn_cast<ObjCImplementationDecl>(EnclosingDecl)) {
13418 assert(IMPDecl &&
"ActOnFields - missing ObjCImplementationDecl");
13419 for (
unsigned I = 0, N = RecFields.size(); I != N; ++I)
13422 ClsFields[I]->setLexicalDeclContext(IMPDecl);
13423 CheckImplementationIvars(IMPDecl, ClsFields, RecFields.size(), RBrac);
13424 IMPDecl->setIvarLBraceLoc(LBrac);
13425 IMPDecl->setIvarRBraceLoc(RBrac);
13427 dyn_cast<ObjCCategoryDecl>(EnclosingDecl)) {
13435 for (
unsigned i = 0, e = RecFields.size(); i != e; ++i) {
13439 Diag(ClsFields[i]->getLocation(),
13440 diag::err_duplicate_ivar_declaration);
13441 Diag(ClsIvar->getLocation(), diag::note_previous_definition);
13447 Diag(ClsFields[i]->getLocation(),
13448 diag::err_duplicate_ivar_declaration);
13449 Diag(ClsExtIvar->getLocation(), diag::note_previous_definition);
13455 CDecl->addDecl(ClsFields[i]);
13457 CDecl->setIvarLBraceLoc(LBrac);
13458 CDecl->setIvarRBraceLoc(RBrac);
13463 ProcessDeclAttributeList(S, Record, Attr);
13469 llvm::APSInt &
Value,
13471 assert(T->
isIntegralType(Context) &&
"Integral type required!");
13474 if (Value.isUnsigned() || Value.isNonNegative()) {
13477 return Value.getActiveBits() <= BitWidth;
13479 return Value.getMinSignedBits() <= BitWidth;
13487 assert(T->
isIntegralType(Context) &&
"Integral type required!");
13488 const unsigned NumTypes = 4;
13489 QualType SignedIntegralTypes[NumTypes] = {
13492 QualType UnsignedIntegralTypes[NumTypes] = {
13499 : UnsignedIntegralTypes;
13500 for (
unsigned I = 0; I != NumTypes; ++I)
13513 llvm::APSInt EnumVal(IntWidth);
13516 if (Val && DiagnoseUnexpandedParameterPack(Val, UPPC_EnumeratorValue))
13520 Val = DefaultLvalueConversion(Val).get();
13527 if (getLangOpts().CPlusPlus11 && Enum->
isFixed() &&
13528 !getLangOpts().MSVCCompat) {
13539 Val = Converted.
get();
13541 !(Val = VerifyIntegerConstantExpression(Val,
13542 &EnumVal).get())) {
13553 if (getLangOpts().MSVCCompat) {
13554 Diag(IdLoc, diag::ext_enumerator_too_large) << EltTy;
13557 Diag(IdLoc, diag::err_enumerator_too_large) << EltTy;
13575 Diag(IdLoc, diag::ext_enum_value_not_int)
13576 << EnumVal.toString(10) << Val->getSourceRange()
13577 << (EnumVal.isUnsigned() || EnumVal.isNonNegative());
13589 if (Enum->isDependentType())
13591 else if (!LastEnumConst) {
13600 if (Enum->isFixed()) {
13601 EltTy = Enum->getIntegerType();
13608 EnumVal = LastEnumConst->getInitVal();
13610 EltTy = LastEnumConst->getType();
13613 if (EnumVal < LastEnumConst->getInitVal()) {
13625 if (T.
isNull() || Enum->isFixed()) {
13628 EnumVal = LastEnumConst->getInitVal();
13629 EnumVal = EnumVal.zext(EnumVal.getBitWidth() * 2);
13631 if (Enum->isFixed())
13633 Diag(IdLoc, diag::err_enumerator_wrapped)
13634 << EnumVal.toString(10)
13637 Diag(IdLoc, diag::ext_enumerator_increment_too_large)
13638 << EnumVal.toString(10);
13646 EnumVal = LastEnumConst->getInitVal();
13647 EnumVal.setIsSigned(EltTy->isSignedIntegerOrEnumerationType());
13656 if (!getLangOpts().CPlusPlus && !T.
isNull())
13657 Diag(IdLoc, diag::warn_enum_value_overflow);
13658 }
else if (!getLangOpts().CPlusPlus &&
13661 Diag(IdLoc, diag::ext_enum_value_not_int)
13662 << EnumVal.toString(10) << 1;
13667 if (!EltTy->isDependentType()) {
13671 EnumVal.setIsSigned(EltTy->isSignedIntegerOrEnumerationType());
13689 auto *PrevECD = dyn_cast_or_null<EnumConstantDecl>(PrevDecl);
13706 EnumDecl *TheEnumDecl = cast<EnumDecl>(theEnumDecl);
13708 cast_or_null<EnumConstantDecl>(lastEnumConst);
13722 PrevDecl =
nullptr;
13729 "Received TagDecl when not in C++!");
13731 if (isa<EnumConstantDecl>(PrevDecl))
13732 Diag(IdLoc, diag::err_redefinition_of_enumerator) << Id;
13734 Diag(IdLoc, diag::err_redefinition) << Id;
13779 if (!BO->isAdditiveOp())
13787 InitExpr = BO->getLHS();
13810 : val(val), isTombstoneOrEmptyKey(isTombstoneOrEmptyKey) {}
13814 return DupKey(Val.isSigned() ? Val.getSExtValue() : Val.getZExtValue(),
13822 return (
unsigned)(Key.
val * 37);
13848 typedef llvm::PointerUnion<EnumConstantDecl*, ECDVector*> DeclOrVector;
13849 typedef llvm::DenseMap<DupKey, DeclOrVector, DenseMapInfoDupKey>
13852 DuplicatesVector DupVector;
13853 ValueToVectorMap EnumMap;
13857 for (
unsigned i = 0, e = Elements.size(); i != e; ++i) {
13870 DeclOrVector &Entry = EnumMap[Key];
13873 if (Entry.isNull())
13878 for (
unsigned i = 0, e = Elements.size(); i != e; ++i) {
13885 DeclOrVector& Entry = EnumMap[Key];
13886 if (Entry.isNull())
13895 ECDVector *Vec =
new ECDVector();
13897 Vec->push_back(ECD);
13904 DupVector.push_back(Vec);
13908 ECDVector *Vec = Entry.get<ECDVector*>();
13910 if (*Vec->begin() == ECD)
13913 Vec->push_back(ECD);
13917 for (DuplicatesVector::iterator DupVectorIter = DupVector.begin(),
13918 DupVectorEnd = DupVector.end();
13919 DupVectorIter != DupVectorEnd; ++DupVectorIter) {
13920 ECDVector *Vec = *DupVectorIter;
13921 assert(Vec->size() > 1 &&
"ECDVector should have at least 2 elements.");
13924 ECDVector::iterator I = Vec->begin();
13925 S.
Diag((*I)->getLocation(), diag::warn_duplicate_enum_values)
13926 << (*I)->getName() << (*I)->getInitVal().toString(10)
13927 << (*I)->getSourceRange();
13932 for (ECDVector::iterator E = Vec->end(); I != E; ++I)
13933 S.
Diag((*I)->getLocation(), diag::note_duplicate_element)
13934 << (*I)->getName() << (*I)->getInitVal().toString(10)
13935 << (*I)->getSourceRange();
13942 bool AllowMask)
const {
13943 FlagEnumAttr *FEAttr = ED->
getAttr<FlagEnumAttr>();
13944 assert(FEAttr &&
"looking for value in non-flag enum");
13946 llvm::APInt FlagMask = ~FEAttr->getFlagBits();
13947 unsigned Width = FlagMask.getBitWidth();
13950 llvm::APInt ExtVal = Val.zextOrSelf(Width);
13960 if (!(FlagMask & ExtVal))
13975 ExtVal |= llvm::APInt::getHighBitsSet(Width, Width - Val.getBitWidth());
13976 if (!(FlagMask & ~ExtVal))
13987 EnumDecl *Enum = cast<EnumDecl>(EnumDeclX);
13994 for (
unsigned i = 0, e = Elements.size(); i != e; ++i) {
13996 cast_or_null<EnumConstantDecl>(Elements[i]);
13997 if (!ECD)
continue;
14015 unsigned NumNegativeBits = 0;
14016 unsigned NumPositiveBits = 0;
14019 bool AllElementsInt =
true;
14021 for (
unsigned i = 0, e = Elements.size(); i != e; ++i) {
14023 cast_or_null<EnumConstantDecl>(Elements[i]);
14024 if (!ECD)
continue;
14026 const llvm::APSInt &InitVal = ECD->
getInitVal();
14029 if (InitVal.isUnsigned() || InitVal.isNonNegative())
14030 NumPositiveBits = std::max(NumPositiveBits,
14031 (
unsigned)InitVal.getActiveBits());
14033 NumNegativeBits = std::max(NumNegativeBits,
14034 (
unsigned)InitVal.getMinSignedBits());
14037 if (AllElementsInt)
14043 unsigned BestWidth;
14056 bool Packed = Enum->
hasAttr<PackedAttr>();
14067 BestPromotionType = BestType;
14071 else if (NumNegativeBits) {
14075 if (Packed && NumNegativeBits <= CharWidth && NumPositiveBits < CharWidth) {
14077 BestWidth = CharWidth;
14078 }
else if (Packed && NumNegativeBits <= ShortWidth &&
14079 NumPositiveBits < ShortWidth) {
14081 BestWidth = ShortWidth;
14082 }
else if (NumNegativeBits <= IntWidth && NumPositiveBits < IntWidth) {
14084 BestWidth = IntWidth;
14088 if (NumNegativeBits <= BestWidth && NumPositiveBits < BestWidth) {
14093 if (NumNegativeBits > BestWidth || NumPositiveBits >= BestWidth)
14098 BestPromotionType = (BestWidth <= IntWidth ?
Context.
IntTy : BestType);
14103 if (Packed && NumPositiveBits <= CharWidth) {
14106 BestWidth = CharWidth;
14107 }
else if (Packed && NumPositiveBits <= ShortWidth) {
14110 BestWidth = ShortWidth;
14111 }
else if (NumPositiveBits <= IntWidth) {
14113 BestWidth = IntWidth;
14115 = (NumPositiveBits == BestWidth || !
getLangOpts().CPlusPlus)
14117 }
else if (NumPositiveBits <=
14121 = (NumPositiveBits == BestWidth || !
getLangOpts().CPlusPlus)
14125 assert(NumPositiveBits <= BestWidth &&
14126 "How could an initializer get larger than ULL?");
14129 = (NumPositiveBits == BestWidth || !
getLangOpts().CPlusPlus)
14134 FlagEnumAttr *FEAttr = Enum->
getAttr<FlagEnumAttr>();
14136 FEAttr->getFlagBits() = llvm::APInt(BestWidth, 0);
14141 for (
auto *D : Elements) {
14142 auto *ECD = cast_or_null<EnumConstantDecl>(D);
14143 if (!ECD)
continue;
14152 llvm::APSInt InitVal = ECD->getInitVal();
14163 NewWidth = IntWidth;
14165 }
else if (ECD->getType() == BestType) {
14171 ECD->setType(EnumType);
14175 NewWidth = BestWidth;
14180 InitVal = InitVal.extOrTrunc(NewWidth);
14181 InitVal.setIsSigned(NewSign);
14182 ECD->setInitVal(InitVal);
14185 if (ECD->getInitExpr() &&
14189 ECD->getInitExpr(),
14196 ECD->setType(EnumType);
14198 ECD->setType(NewTy);
14204 llvm::APInt ExtVal = InitVal.zextOrSelf(BestWidth);
14205 if (ExtVal != 0 && !(ExtVal & (ExtVal - 1))) {
14206 FEAttr->getFlagBits() |= ExtVal;
14212 for (
Decl *D : Elements) {
14214 if (!ECD)
continue;
14226 NumPositiveBits, NumNegativeBits);
14241 AsmString, StartLoc,
14250 if (
auto *LSD = dyn_cast<LinkageSpecDecl>(DC)) {
14251 switch (LSD->getLanguage()) {
14254 S.
Diag(ImportLoc, diag::err_module_import_in_extern_c)
14256 S.
Diag(LSD->getLocStart(), diag::note_module_import_in_extern_c);
14266 while (isa<LinkageSpecDecl>(DC))
14268 if (!isa<TranslationUnitDecl>(DC)) {
14269 S.
Diag(ImportLoc, diag::err_module_import_not_at_top_level)
14271 S.
Diag(cast<Decl>(DC)->getLocStart(),
14272 diag::note_module_import_not_at_top_level)
14294 Diag(ImportLoc, diag::err_module_self_import)
14297 Diag(ImportLoc, diag::err_module_import_in_implementation)
14302 for (
unsigned I = 0, N = Path.size(); I != N; ++I) {
14307 ModCheck = ModCheck->
Parent;
14309 IdentifierLocs.push_back(Path[I].second);
14314 AtLoc.
isValid()? AtLoc : ImportLoc,
14315 Mod, IdentifierLocs);
14328 bool IsInModuleIncludes =
14334 if (!IsInModuleIncludes) {
14344 VisibleModules.
setVisible(Mod, DirectiveLoc);
14351 VisibleModulesStack.push_back(std::move(VisibleModules));
14352 VisibleModules.
setVisible(Mod, DirectiveLoc);
14359 VisibleModules = std::move(VisibleModulesStack.back());
14360 VisibleModulesStack.pop_back();
14361 VisibleModules.
setVisible(Mod, DirectiveLoc);
14390 AsmLabelAttr *
Attr =
14391 AsmLabelAttr::CreateImplicit(
Context, AliasName->
getName(), AliasNameLoc);
14398 (isa<FunctionDecl>(PrevDecl) || isa<VarDecl>(PrevDecl)) &&
14412 PrevDecl->
addAttr(WeakAttr::CreateImplicit(
Context, PragmaLoc));
14415 std::pair<IdentifierInfo*,WeakInfo>
14430 if (!PrevDecl->
hasAttr<AliasAttr>())
14431 if (
NamedDecl *ND = dyn_cast<NamedDecl>(PrevDecl))
14435 std::pair<IdentifierInfo*,WeakInfo>(AliasName, W));
14440 return (dyn_cast_or_null<ObjCContainerDecl>(
CurContext));
14457 D = MD->getClassInterface();
14462 dyn_cast<ObjCImplementationDecl>(D)) {
14463 D =
ID->getClassInterface();
static bool ShouldWarnAboutMissingPrototype(const FunctionDecl *FD, const FunctionDecl *&PossibleZeroParamPrototype)
MutableArrayRef< TemplateParameterList * > MultiTemplateParamsArg
unsigned getFlags() const
A call to an overloaded operator written using operator syntax.
unsigned getAddressSpace() const
getAddressSpace - Return the address space of this type.
SourceLocation getThreadStorageClassSpecLoc() const
param_const_iterator param_begin() const
ValueDecl * getMemberDecl() const
Retrieve the member declaration to which this expression refers.
void setHasSkippedBody(bool Skipped=true)
Defines the clang::ASTContext interface.
const AttributedType * getCallingConvAttributedType(QualType T) const
void setScopeInfo(unsigned scopeDepth, unsigned parameterIndex)
SourceLocation getEnd() const
QualType getCurrentThisType()
Try to retrieve the type of the 'this' pointer.
T getAs() const
Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...
CastKind getCastKind() const
IdKind getKind() const
Determine what kind of name we have.
bool RequireNonAbstractType(SourceLocation Loc, QualType T, TypeDiagnoser &Diagnoser)
void setImplicit(bool I=true)
bool isMSVCRTEntryPoint() const
Determines whether this function is a MSVCRT user defined entry point.
ParsedType CreateParsedType(QualType T, TypeSourceInfo *TInfo)
Package the given type and TSI into a ParsedType.
void setDeclsInPrototypeScope(ArrayRef< NamedDecl * > NewDecls)
Name lookup found a set of overloaded functions that met the criteria.
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
SourceRange IntroducerRange
Source range covering the lambda introducer [...].
DeclaratorChunk::FunctionTypeInfo & getFunctionTypeInfo()
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 isTransparentContext() const
bool isTemplateParameter() const
QualType getPromotedIntegerType(QualType PromotableType) const
Return the type that PromotableType will promote to: C99 6.3.1.1p2, assuming that PromotableType is a...
StringRef getName() const
bool CheckNontrivialField(FieldDecl *FD)
void setjmp_bufDecl(TypeDecl *jmp_bufDecl)
Set the type for the C jmp_buf type.
no exception specification
bool isTombstoneOrEmptyKey
bool canDecayToPointerType() const
Determines whether this type can decay to a pointer type.
void setAnonymousStructOrUnion(bool Anon)
EvaluatedExprVisitor - This class visits 'Expr *'s.
SourceLocation getRestrictSpecLoc() const
GVALinkage GetGVALinkageForFunction(const FunctionDecl *FD) const
APValue * evaluateValue() const
Attempt to evaluate the value of the initializer attached to this declaration, and produce notes expl...
TemplateSpecializationKind getTemplateSpecializationKind() const
If this variable is an instantiation of a variable template or a static data member of a class templa...
Decl * ActOnIvar(Scope *S, SourceLocation DeclStart, Declarator &D, Expr *BitfieldWidth, tok::ObjCKeywordKind visibility)
bool ShouldWarnIfUnusedFileScopedDecl(const DeclaratorDecl *D) const
Simple class containing the result of Sema::CorrectTypo.
capture_const_range captures() const
const IdentifierInfo * getLiteralIdentifier() const
void InstantiatedLocal(const Decl *D, Decl *Inst)
bool isEvaluatable(const ASTContext &Ctx) const
const AttributeList * getAttrs() const
If there are attributes applied to this declaratorchunk, return them.
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
virtual unsigned getManglingNumber(const CXXMethodDecl *CallOperator)=0
Retrieve the mangling number of a new lambda expression with the given call operator within this cont...
SourceLocation getConstSpecLoc() const
void ActOnPragmaWeakAlias(IdentifierInfo *WeakName, IdentifierInfo *AliasName, SourceLocation PragmaLoc, SourceLocation WeakNameLoc, SourceLocation AliasNameLoc)
ActOnPragmaWeakAlias - Called on well formed #pragma weak ident = ident.
static bool InjectAnonymousStructOrUnionMembers(Sema &SemaRef, Scope *S, DeclContext *Owner, RecordDecl *AnonRecord, AccessSpecifier AS, SmallVectorImpl< NamedDecl * > &Chaining, bool MSAnonStruct)
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
bool isReplaceableGlobalAllocationFunction() const
Determines whether this function is one of the replaceable global allocation functions: void *operato...
SourceLocation getExplicitSpecLoc() const
ExtInfo withCallingConv(CallingConv cc) const
CharUnits getDeclAlign(const Decl *D, bool ForAlignof=false) const
Return a conservative estimate of the alignment of the specified decl D.
bool isBitField() const
Determines whether this field is a bitfield.
SourceRange getSourceRange() const LLVM_READONLY
Return the source range that covers this unqualified-id.
bool hasTrivialDestructor() const
Determine whether this class has a trivial destructor (C++ [class.dtor]p3)
DestructionKind isDestructedType() const
void CheckTypedefForVariablyModifiedType(Scope *S, TypedefNameDecl *D)
bool hasLinkageBeenComputed() const
True if something has required us to compute the linkage of this declaration.
QualType getType() const
Retrieves the type of the base class.
bool isElidable() const
Whether this construction is elidable.
SourceLocation StartLocation
The location of the first token that describes this unqualified-id, which will be the location of the...
bool isUnavailable(std::string *Message=nullptr) const
Determine whether this declaration is marked 'unavailable'.
IdentifierInfo * Name
FIXME: Temporarily stores the name of a specialization.
IdentifierInfo * getIdentifier() const
Decl * getRepAsDecl() const
void setAttrs(const AttrVec &Attrs)
const LangOptions & getLangOpts() const
void setLookupName(DeclarationName Name)
Sets the name to look up.
SourceLocation TemplateNameLoc
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false)
Perform unqualified name lookup starting from a given scope.
const Scope * getFnParent() const
static void CheckForDuplicateEnumValues(Sema &S, ArrayRef< Decl * > Elements, EnumDecl *Enum, QualType EnumType)
Qualifiers::ObjCLifetime getObjCARCImplicitLifetime() const
Return the implicit lifetime for this type, which must not be dependent.
DeclClass * getAsSingle() const
IdentifierInfo * Identifier
When Kind == IK_Identifier, the parsed identifier, or when Kind == IK_UserLiteralId, the identifier suffix.
NamedDecl * getRepresentativeDecl() const
Fetches a representative decl. Useful for lazy diagnostics.
void setStarLoc(SourceLocation Loc)
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.
bool isExternCContext() const
Determines whether this context or some of its ancestors is a linkage specification context that spec...
void setPreviousDecl(decl_type *PrevDecl)
Set the previous declaration. If PrevDecl is NULL, set this as the first and only declaration...
TemplateDecl * getAsTemplateDecl() const
Retrieve the underlying template declaration that this template name refers to, if known...
bool isMain() const
Determines whether this function is "main", which is the entry point into an executable program...
const Expr * getInitExpr() const
bool isOutOfLine() const override
Determine whether this is or was instantiated from an out-of-line definition of a member function...
unsigned IsExternC
Whether this is an 'extern "C"' module (which implicitly puts all headers in it within an 'extern "...
unsigned getIntWidth(QualType T) const
void setTypedefNameForAnonDecl(TypedefNameDecl *TDD)
const Scope * getParent() const
Defines the SourceManager interface.
void setObjCClassRedefinitionType(QualType RedefType)
Set the user-written type that redefines 'SEL'.
void ActOnDocumentableDecls(ArrayRef< Decl * > Group)
void ActOnDocumentableDecl(Decl *D)
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in...
void setucontext_tDecl(TypeDecl *ucontext_tDecl)
Set the type for the C ucontext_t type.
static ClassScopeFunctionSpecializationDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation Loc, CXXMethodDecl *FD, bool HasExplicitTemplateArgs, TemplateArgumentListInfo TemplateArgs)
unsigned getFunctionScopeIndex() const
Returns the index of this parameter in its prototype or method scope.
QuantityType getQuantity() const
getQuantity - Get the raw integer representation of this quantity.
A conversion function name, e.g., operator int.
bool CheckFunctionDeclaration(Scope *S, FunctionDecl *NewFD, LookupResult &Previous, bool IsExplicitSpecialization)
Perform semantic checking of a new function declaration.
void computeNRVO(Stmt *Body, sema::FunctionScopeInfo *Scope)
Given the set of return statements within a function body, compute the variables that are subject to ...
void erase()
Erase the last element returned from this iterator.
NestedNameSpecifierLoc getPrefix() const
Return the prefix of this nested-name-specifier.
bool isRecordType() const
static const TST TST_typeofExpr
QualType getUnderlyingType() const
const DeclContext * getParentFunctionOrMethod() const
If this decl is defined inside a function/method/block it returns the corresponding DeclContext...
SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)
Emit a diagnostic.
void setRangeEnd(SourceLocation E)
bool isPredefinedLibFunction(unsigned ID) const
Determines whether this builtin is a predefined libc/libm function, such as "malloc", where we know the signature a priori.
LambdaCaptureDefault
The default, if any, capture method for a lambda expression.
VarDecl * getDefinition(ASTContext &)
Get the real (not just tentative) definition for this declaration.
void DiagnoseFunctionSpecifiers(const DeclSpec &DS)
Diagnose function specifiers on a declaration of an identifier that does not identify a function...
static StringRef getHeaderName(ASTContext::GetBuiltinTypeError Error)
bool isPrintfLike(unsigned ID, unsigned &FormatIdx, bool &HasVAListArg)
Determine whether this builtin is like printf in its formatting rules and, if so, set the index to th...
bool isLiteralType(const ASTContext &Ctx) const
AutoType * getContainedAutoType() const
Get the AutoType whose type will be deduced for a variable with an initializer of this type...
Defines the C++ template declaration subclasses.
void setModulePrivate(bool MP=true)
Specify whether this declaration was marked as being private to the module in which it was defined...
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...
bool isVoidPointerType() const
bool hasNonTrivialDestructor() const
Determine whether this class has a non-trivial destructor (C++ [class.dtor]p3)
Represents a C++11 auto or C++1y decltype(auto) type.
static bool canRedefineFunction(const FunctionDecl *FD, const LangOptions &LangOpts)
void setPure(bool P=true)
bool hasFlexibleArrayMember() const
void setPreviousDeclaration(FunctionDecl *PrevDecl)
bool RebuildNestedNameSpecifierInCurrentInstantiation(CXXScopeSpec &SS)
SCS getStorageClassSpec() const
bool hasDefinition() const
FunctionDefinitionKind getFunctionDefinitionKind() const
static InitializationKind CreateDirect(SourceLocation InitLoc, SourceLocation LParenLoc, SourceLocation RParenLoc)
Create a direct initialization.
bool hasErrorOccurred() const
Determine whether any SFINAE errors have been trapped.
IdentifierInfo * getAsIdentifierInfo() const
bool isInStdNamespace() const
bool hasLinkage() const
Determine whether this declaration has linkage.
bool isDependentContext() const
Determines whether this context is dependent on a template parameter.
const IncompleteArrayType * getAsIncompleteArrayType(QualType T) const
unsigned getLength() const
Efficiently return the length of this identifier info.
static bool haveIncompatibleLanguageLinkages(const T *Old, const T *New)
static void checkDuplicateDefaultInit(Sema &S, CXXRecordDecl *Parent, SourceLocation DefaultInitLoc)
MapType::iterator iterator
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...
Declaration of a variable template.
const Expr * getInit() const
static InitializationKind CreateDefault(SourceLocation InitLoc)
Create a default initialization.
NamespaceDecl - Represent a C++ namespace.
RedeclarationKind
Specifies whether (or how) name lookup is being performed for a redeclaration (vs. a reference).
Represents a call to a C++ constructor.
static const char * getSpecifierName(DeclSpec::TST T, const PrintingPolicy &Policy)
Turn a type-specifier-type into a string like "_Bool" or "union".
virtual void completeDefinition()
ObjCDeclQualifier getObjCDeclQualifier() const
bool isDecltypeAuto() const
SourceLocation getInlineSpecLoc() const
AccessSpecifier
A C++ access specifier (public, private, protected), plus the special value "none" which means differ...
bool isBooleanType() const
void ActOnExitFunctionContext()
A container of type source information.
Wrapper for void* pointer.
static NestedNameSpecifier * synthesizeCurrentNestedNameSpecifier(ASTContext &Context, DeclContext *DC)
unsigned getFunctionPrototypeDepth() const
SourceRange getIntegerTypeRange() const LLVM_READONLY
Retrieve the source range that covers the underlying type if specified.
bool isBlockPointerType() const
static unsigned GetDiagnosticTypeSpecifierID(DeclSpec::TST T)
void SetIdentifier(IdentifierInfo *Id, SourceLocation IdLoc)
Set the name of this declarator to be the given identifier.
unsigned getRawEncoding() const
When a SourceLocation itself cannot be used, this returns an (opaque) 32-bit integer encoding for it...
SourceLocation getLocEnd() const LLVM_READONLY
static DupKey getTombstoneKey()
void setInitStyle(InitializationStyle Style)
Represents a path from a specific derived class (which is not represented as part of the path) to a p...
Represents a C++ constructor within a class.
static bool mergeDeclAttribute(Sema &S, NamedDecl *D, const InheritableAttr *Attr, bool Override)
bool CheckVariableDeclaration(VarDecl *NewVD, LookupResult &Previous)
Perform semantic checking on a newly-created variable declaration.
bool isCopyAssignmentOperator() const
Determine whether this is a copy-assignment operator, regardless of whether it was declared implicitl...
OptimizeNoneAttr * mergeOptimizeNoneAttr(Decl *D, SourceRange Range, unsigned AttrSpellingListIndex)
***static FixItHint createFriendTagNNSFixIt(Sema &SemaRef, NamedDecl *ND, Scope *S, SourceLocation NameLoc)
const TemplateArgumentLoc * getArgumentArray() const
DeclGroupPtrTy BuildDeclaratorGroup(MutableArrayRef< Decl * > Group, bool TypeMayContainAuto=true)
Retains information about a function, method, or block that is currently being parsed.
This file provides some common utility functions for processing Lambda related AST Constructs...
bool DiagnoseClassNameShadow(DeclContext *DC, DeclarationNameInfo Info)
ModuleLoader & getModuleLoader() const
Retrieve the module loader associated with the preprocessor.
void setRAngleLoc(SourceLocation Loc)
void ActOnObjCReenterContainerContext(DeclContext *DC)
DeclContext::lookup_result Decls
The set of declarations found inside this base class subobject.
RAII object that enters a new expression evaluation context.
bool isUsableInConstantExpressions(ASTContext &C) const
Determine whether this variable's value can be used in a constant expression, according to the releva...
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
NamedDecl * LazilyCreateBuiltin(IdentifierInfo *II, unsigned ID, Scope *S, bool ForRedeclaration, SourceLocation Loc)
static CXXConversionDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool isInline, bool isExplicit, bool isConstexpr, SourceLocation EndLocation)
bool isFileVarDecl() const
isFileVarDecl - Returns true for file scoped variable declaration.
static const TST TST_underlyingType
static NestedNameSpecifier * Create(const ASTContext &Context, NestedNameSpecifier *Prefix, IdentifierInfo *II)
Builds a specifier combining a prefix and an identifier.
Information about one declarator, including the parsed type information and the identifier.
DiagnosticsEngine & Diags
void setCXXLiteralOperatorNameLoc(SourceLocation Loc)
const Expr * getCallee() const
TLSKind getTLSKind() const
ExtProtoInfo - Extra information about a function prototype.
AccessSpecifier getAccess() const
TypeSpecifierType
Specifies the kind of type.
QualType getObjCClassType() const
Represents the Objective-C Class type.
field_iterator field_begin() const
bool isCLike() const
True if this class is C-like, without C++-specific features, e.g. it contains only public fields...
The "__interface" keyword.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
void ActOnTagFinishSkippedDefinition(SkippedDefinitionContext Context)
NamedDecl * getUnderlyingDecl()
Looks through UsingDecls and ObjCCompatibleAliasDecls for the underlying named decl.
void ActOnObjCTemporaryExitContainerContext(DeclContext *DC)
Invoked when we must temporarily exit the objective-c container scope for parsing/looking-up C constr...
bool hasGlobalStorage() const
Returns true for all variables that do not have local storage.
static const TST TST_interface
bool AddOverriddenMethods(CXXRecordDecl *DC, CXXMethodDecl *MD)
Stores a list of template parameters for a TemplateDecl and its derived classes.
static StringRef getTagTypeKindName(TagTypeKind Kind)
Visibility getVisibility() const
Determines the visibility of this entity.
static InitializationKind CreateDirectList(SourceLocation InitLoc)
Expr * getCond() const
getCond - Return the condition expression; this is defined in terms of the opaque value...
Describes how types, statements, expressions, and declarations should be printed. ...
NamedDecl * ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, LookupResult &Previous, MultiTemplateParamsArg TemplateParamLists, bool &AddToScope)
Decl * ActOnParamDeclarator(Scope *S, Declarator &D)
bool canSkipFunctionBody(Decl *D)
Determine whether we can skip parsing the body of a function definition, assuming we don't care about...
bool isSingleTagDecl() const
Asks if the result is a single tag decl.
static QualType getCoreType(QualType Ty)
ParmVarDecl - Represents a parameter to a function.
bool isMoveAssignmentOperator() const
Determine whether this is a move assignment operator.
Defines the clang::Expr interface and subclasses for C++ expressions.
FormatAttr * mergeFormatAttr(Decl *D, SourceRange Range, IdentifierInfo *Format, int FormatIdx, int FirstArg, unsigned AttrSpellingListIndex)
void removeDecl(Decl *D)
Removes a declaration from this context.
bool isEmpty() const
No scope specifier.
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
void setTagNameForLinkagePurposes(TagDecl *TagFromDeclSpec, TypedefNameDecl *NewTD)
static const TemplateDecl * isTemplate(const NamedDecl *ND, const TemplateArgumentList *&TemplateArgs)
NamedDecl * getTargetDecl() const
Gets the underlying declaration which has been brought into the local scope.
static TypeSourceInfo * TryToFixInvalidVariablyModifiedTypeSourceInfo(TypeSourceInfo *TInfo, ASTContext &Context, bool &SizeIsNegative, llvm::APSInt &Oversized)
void ActOnUninitializedDecl(Decl *dcl, bool TypeMayContainAuto)
Information about a template-id annotation token.
FieldDecl * HandleField(Scope *S, RecordDecl *TagD, SourceLocation DeclStart, Declarator &D, Expr *BitfieldWidth, InClassInitStyle InitStyle, AccessSpecifier AS)
bool hasExternalFormalLinkage() const
True if this decl has external linkage.
bool FTIHasNonVoidParameters(const DeclaratorChunk::FunctionTypeInfo &FTI)
QualType CheckConstructorDeclarator(Declarator &D, QualType R, StorageClass &SC)
void setCorrectionDecl(NamedDecl *CDecl)
Clears the list of NamedDecls before adding the new one.
void setTemplateParameterListsInfo(ASTContext &Context, unsigned NumTPLists, TemplateParameterList **TPLists)
Base wrapper for a particular "section" of type source info.
Expr * IgnoreImpCasts() LLVM_READONLY
unsigned getNumParams() const
std::string getFullModuleName() const
Retrieve the full name of this module, including the path from its top-level module.
bool hasBody(const FunctionDecl *&Definition) const
Returns true if the function has a body (definition). The function body might be in any of the (re-)d...
bool isFunctionTemplateSpecialization() const
Determine whether this function is a function template specialization.
bool isExternC() const
Determines whether this function is a function with external, C linkage.
TemplateIdAnnotation * TemplateId
When Kind == IK_TemplateId or IK_ConstructorTemplateId, the template-id annotation that contains the ...
DeclarationName getName() const
getName - Returns the embedded declaration name.
void setIntegerType(QualType T)
Set the underlying integer type.
LocalInstantiationScope * CurrentInstantiationScope
The current instantiation scope used to store local variables.
ExtInfo withProducesResult(bool producesResult) const
Name lookup results in an ambiguity; use getAmbiguityKind to figure out what kind of ambiguity we hav...
bool isScalarType() const
void MarkUnusedFileScopedDecl(const DeclaratorDecl *D)
If it's a file scoped decl that must warn if not used, keep track of it.
static bool isFunctionDefinitionDiscarded(Sema &S, FunctionDecl *FD)
DeclarationNameInfo GetNameFromUnqualifiedId(const UnqualifiedId &Name)
Retrieves the declaration name from a parsed unqualified-id.
method_iterator end_overridden_methods() const
QualType apply(const ASTContext &Context, QualType QT) const
Apply the collected qualifiers to the given type.
void RegisterLocallyScopedExternCDecl(NamedDecl *ND, Scope *S)
Register the given locally-scoped extern "C" declaration so that it can be found later for redeclarat...
OpaquePtr< QualType > ParsedType
void MergeVarDeclTypes(VarDecl *New, VarDecl *Old, bool MergeTypeWithOld)
TagDecl * getAsTagDecl() const
Retrieves the TagDecl that this type refers to, either because the type is a TagType or because it is...
void DiagnoseTemplateParameterShadow(SourceLocation Loc, Decl *PrevDecl)
TagDecl * getAnonDeclWithTypedefName(bool AnyRedecl=false) const
ExprResult RebuildExprInCurrentInstantiation(Expr *E)
UnionParsedType ConversionFunctionId
When Kind == IK_ConversionFunctionId, the type that the conversion function names.
static RecordDecl * Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, RecordDecl *PrevDecl=nullptr)
IdentifierInfo * getCorrectionAsIdentifierInfo() const
AttributeList * getList() const
void setManglingNumber(const NamedDecl *ND, unsigned Number)
Expr * getSizeExpr() const
static void mergeParamDeclTypes(ParmVarDecl *NewParam, const ParmVarDecl *OldParam, Sema &S)
static void checkDLLAttributeRedeclaration(Sema &S, NamedDecl *OldDecl, NamedDecl *NewDecl, bool IsSpecialization)
bool isVariablyModifiedType() const
Whether this type is a variably-modified type (C99 6.7.5).
TypeLoc getPointeeLoc() const
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
A C++ nested-name-specifier augmented with source location information.
void AddTypeInfo(const DeclaratorChunk &TI, ParsedAttributes &attrs, SourceLocation EndLoc)
The results of name lookup within a DeclContext. This is either a single result (with no stable stora...
ArrayRef< QualType > getParamTypes() const
void ActOnTagStartDefinition(Scope *S, Decl *TagDecl)
Missing a type from <ucontext.h>
bool CheckEnumUnderlyingType(TypeSourceInfo *TI)
Check that this is a valid underlying type for an enum declaration.
bool hasNonTrivialCopyConstructor() const
Determine whether this class has a non-trivial copy constructor (C++ [class.copy]p6, C++11 [class.copy]p12)
const CXXScopeSpec & getCXXScopeSpec() const
ObjCIvarDecl * getIvarDecl(IdentifierInfo *Id) const
Base class for callback objects used by Sema::CorrectTypo to check the validity of a potential typo c...
QualType getLifetimeQualifiedType(QualType type, Qualifiers::ObjCLifetime lifetime)
Return a type with the given lifetime qualifier.
bool isReferenceType() const
TypeSourceInfo * getTypeSourceInfo(ASTContext &Context, QualType T)
Creates a TypeSourceInfo for the given type.
bool isInIdentifierNamespace(unsigned NS) const
static const TST TST_class
QualType getReturnType() const
bool isAcceptableTagRedeclaration(const TagDecl *Previous, TagTypeKind NewTag, bool isDefinition, SourceLocation NewTagLoc, const IdentifierInfo *Name)
Determine whether a tag with a given kind is acceptable as a redeclaration of the given tag declarati...
bool isStructureOrClassType() const
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
bool isCompleteDefinition() const
int hasAttribute(AttrSyntax Syntax, const IdentifierInfo *Scope, const IdentifierInfo *Attr, const llvm::Triple &T, const LangOptions &LangOpts)
Return the version number associated with the attribute if we recognize and implement the attribute s...
DeclGroupPtrTy ConvertDeclToDeclGroup(Decl *Ptr, Decl *OwnedType=nullptr)
OverloadedOperatorKind Operator
The kind of overloaded operator.
bool isReferenced() const
Whether any declaration of this entity was referenced.
bool isAnonymousNamespace() const
Returns true if this is an anonymous namespace declaration.
bool declarationReplaces(NamedDecl *OldD, bool IsKnownNewer=true) const
Determine whether this declaration, if known to be well-formed within its context, will replace the declaration OldD if introduced into scope. A declaration will replace another declaration if, for example, it is a redeclaration of the same variable or function, but not if it is a declaration of a different kind (function vs. class) or an overloaded function.
static bool isIncrementDecrementOp(Opcode Op)
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
void startDefinition()
Starts the definition of this tag declaration.
struct OFI OperatorFunctionId
When Kind == IK_OperatorFunctionId, the overloaded operator that we parsed.
CXXMethodDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
void setName(DeclarationName N)
setName - Sets the embedded declaration name.
CXXRecordDecl * getDefinition() const
bool isTranslationUnit() const
bool isNoreturnSpecified() const
void setElaboratedKeywordLoc(SourceLocation Loc)
TagKind getTagKind() const
bool isPreviousDeclInSameBlockScope() const
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
static const TST TST_error
void setStaticLocalNumber(const VarDecl *VD, unsigned Number)
SkipBodyInfo shouldSkipAnonEnumBody(Scope *S, IdentifierInfo *II, SourceLocation IILoc)
bool hasInClassInitializer() const
Whether this class has any in-class initializers for non-static data members (including those in anon...
const RecordType * getAsUnionType() const
NOTE: getAs*ArrayType are methods on ASTContext.
SmallVector< Attr *, 2 > AttrVec
AttrVec - A vector of Attr, which is how they are stored on the AST.
This declaration is definitely a definition.
static const TST TST_enum
void CheckMain(FunctionDecl *FD, const DeclSpec &D)
SourceLocation getTypeSpecTypeLoc() const
TypedefDecl * ParseTypedefDecl(Scope *S, Declarator &D, QualType T, TypeSourceInfo *TInfo)
Subroutines of ActOnDeclarator().
SourceLocation getLocStart() const LLVM_READONLY
Decl * ActOnEnumConstant(Scope *S, Decl *EnumDecl, Decl *LastEnumConstant, SourceLocation IdLoc, IdentifierInfo *Id, AttributeList *Attrs, SourceLocation EqualLoc, Expr *Val)
bool isMicrosoftMissingTypename(const CXXScopeSpec *SS, Scope *S)
void ActOnFinishDelayedAttribute(Scope *S, Decl *D, ParsedAttributes &Attrs)
static unsigned getNumAddressingBits(ASTContext &Context, QualType ElementType, const llvm::APInt &NumElements)
Determine the number of bits required to address a member of.
void ClearStorageClassSpecs()
bool isForRedeclaration() const
True if this lookup is just looking for an existing declaration.
unsigned getRegParm() const
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
Declaration of a function specialization at template class scope.
Decl * ActOnTag(Scope *S, unsigned TagSpec, TagUseKind TUK, SourceLocation KWLoc, CXXScopeSpec &SS, IdentifierInfo *Name, SourceLocation NameLoc, AttributeList *Attr, AccessSpecifier AS, SourceLocation ModulePrivateLoc, MultiTemplateParamsArg TemplateParameterLists, bool &OwnedDecl, bool &IsDependent, SourceLocation ScopedEnumKWLoc, bool ScopedEnumUsesClassTag, TypeResult UnderlyingType, bool IsTypeSpecifier, SkipBodyInfo *SkipBody=nullptr)
This is invoked when we see 'struct foo' or 'struct {'. In the former case, Name will be non-null...
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.
std::pair< NullabilityKind, bool > DiagNullabilityKind
No entity found met the criteria within the current instantiation,, but there were dependent base cla...
static bool adjustContextForLocalExternDecl(DeclContext *&DC)
Describes a module or submodule.
bool isThisDeclarationADefinition() const
StorageClass getStorageClass() const
Returns the storage class as written in the source. For the computed linkage of symbol, see getLinkage.
RawCommentList & getRawCommentList()
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
static InitializedEntity InitializeBlock(SourceLocation BlockVarLoc, QualType Type, bool NRVO)
bool hasExternalStorage() const
Returns true if a variable has extern or private_extern storage.
bool isLinkageValid() const
True if the computed linkage is valid. Used for consistency checking. Should always return true...
Provides information about a function template specialization, which is a FunctionDecl that has been ...
bool isExplicitlyDefaulted() const
unsigned getRegParmType() const
QualType mergeObjCGCQualifiers(QualType, QualType)
SourceLocation getBeginLoc() const
Get the begin source location.
VarDecl * getActingDefinition()
Get the tentative definition that acts as the real definition in a TU. Returns null if there is a pro...
UnionParsedType DestructorName
When Kind == IK_DestructorName, the type referred to by the class-name.
Describes an C or C++ initializer list.
Represents a C++ unqualified-id that has been parsed.
static ExprResult CheckConvertedConstantExpression(Sema &S, Expr *From, QualType T, APValue &Value, Sema::CCEKind CCE, bool RequireInt)
QualType getParenType(QualType NamedType) const
DeclContext * getEnclosingNamespaceContext()
Retrieve the nearest enclosing namespace context.
void resolveKind()
Resolves the result kind of the lookup, possibly hiding decls.
void setNameLoc(SourceLocation Loc)
Represents the results of name lookup.
const TargetInfo & getTargetInfo() const
TypeVisibilityAttr * mergeTypeVisibilityAttr(Decl *D, SourceRange Range, TypeVisibilityAttr::VisibilityType Vis, unsigned AttrSpellingListIndex)
void mergeDeclAttributes(NamedDecl *New, Decl *Old, AvailabilityMergeKind AMK=AMK_Redeclaration)
mergeDeclAttributes - Copy attributes from the Old decl to the New one.
MinSizeAttr * mergeMinSizeAttr(Decl *D, SourceRange Range, unsigned AttrSpellingListIndex)
const LangOptions & getLangOpts() const
static void filterNonConflictingPreviousTypedefDecls(Sema &S, TypedefNameDecl *Decl, LookupResult &Previous)
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 isLocalVarDeclOrParm() const
Similar to isLocalVarDecl but also includes parameters.
void setcudaConfigureCallDecl(FunctionDecl *FD)
Scope * getNonFieldDeclScope(Scope *S)
static bool mergeAlignedAttrs(Sema &S, NamedDecl *New, Decl *Old)
bool isValidGCCRegisterName(StringRef Name) const
Returns whether the passed in string is a valid register name according to GCC.
DeclarationNameInfo getNameInfo() const
Keeps track of the mangled names of lambda expressions and block literals within a particular context...
QualType getReturnType() const
Wrapper for source info for functions.
static void RebuildLambdaScopeInfo(CXXMethodDecl *CallOperator, Sema &S)
void ActOnInitializerError(Decl *Dcl)
SCS
storage-class-specifier
static EnumConstantDecl * Create(ASTContext &C, EnumDecl *DC, SourceLocation L, IdentifierInfo *Id, QualType T, Expr *E, const llvm::APSInt &V)
QualType GetBuiltinType(unsigned ID, GetBuiltinTypeError &Error, unsigned *IntegerConstantArgs=nullptr) const
Return the type for the specified builtin.
const CXXRecordDecl * getParent() const
AmbiguityKind getAmbiguityKind() const
bool isExternC() const
Determines whether this variable is a variable with external, C linkage.
NamedDecl * ActOnVariableDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, LookupResult &Previous, MultiTemplateParamsArg TemplateParamLists, bool &AddToScope)
Visibility
Describes the different kinds of visibility that a declaration may have.
field_range fields() const
Decl * ActOnObjCContainerStartDefinition(Decl *IDecl)
static ParsedType recoverFromTypeInKnownDependentBase(Sema &S, const IdentifierInfo &II, SourceLocation NameLoc)
VarTemplateDecl * getInstantiatedFromMemberTemplate()
static bool isEqual(const DupKey &LHS, const DupKey &RHS)
bool isObjCLifetimeType() const
const ArrayType * getAsArrayType(QualType T) const
char * location_data() const
Retrieve the data associated with the source-location information.
bool diagnoseQualifiedDeclaration(CXXScopeSpec &SS, DeclContext *DC, DeclarationName Name, SourceLocation Loc)
Diagnose a declaration whose declarator-id has the given nested-name-specifier.
static bool isRecordType(QualType T)
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
A builtin binary operation expression such as "x + y" or "x <= y".
void setRedeclaration(bool Val)
void setHasObjectMember(bool val)
An implicit 'self' parameter.
bool isValueDependent() const
static OpenCLParamType getOpenCLKernelParameterType(QualType PT)
QualType CheckDestructorDeclarator(Declarator &D, QualType R, StorageClass &SC)
QualType withoutLocalFastQualifiers() const
void setHasImplicitReturnZero(bool IRZ)
ParsedTemplateArgument * getTemplateArgs()
Retrieves a pointer to the template arguments.
Module * Parent
The parent of this module. This will be NULL for the top-level module.
static bool isAcceptableTagRedeclContext(Sema &S, DeclContext *OldDC, DeclContext *NewDC)
Determine whether a tag originally declared in context OldDC can be redeclared with an unqualfied nam...
bool isOverloadedOperator() const
LabelStmt * getStmt() const
FunctionTemplateDecl * getInstantiatedFromMemberTemplate()
void ActOnModuleInclude(SourceLocation DirectiveLoc, Module *Mod)
The parser has processed a module import translated from a #include or similar preprocessing directiv...
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...
Decl * ActOnFileScopeAsmDecl(Expr *expr, SourceLocation AsmLoc, SourceLocation RParenLoc)
CXXRecordDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
bool isTemplateInstantiation() const
Determines if the given function was instantiated from a function template.
static DupKey getEmptyKey()
bool isDependent() const
Whether this nested name specifier refers to a dependent type or not.
void DiagnoseUnusedDecl(const NamedDecl *ND)
Represents a C++ nested-name-specifier or a global scope specifier.
void ActOnFinishInlineMethodDef(CXXMethodDecl *D)
bool hasUnrecoverableErrorOccurred() const
bool isStructureType() const
void setRedeclarationKind(Sema::RedeclarationKind RK)
Change this lookup's redeclaration kind.
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...
DeclContext * getLexicalDeclContext()
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
bool isIncompatibleTypedef(TypeDecl *Old, TypedefNameDecl *New)
void UpdateExprRep(Expr *Rep)
void CheckCompleteVariableDeclaration(VarDecl *var)
void CheckVariableDeclarationType(VarDecl *NewVD)
SourceLocation getLocation() const
bool isStaticLocal() const
static VarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S)
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'.
bool isExternInLinkageSpec() const
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
const char * getHeaderName(unsigned ID) const
If this is a library function that comes from a specific header, retrieve that header name...
bool isLambdaCallOperator(const CXXMethodDecl *MD)
void CheckMSVCRTEntryPoint(FunctionDecl *FD)
Decl * ActOnFinishFunctionBody(Decl *Decl, Stmt *Body)
Represents an ObjC class declaration.
Represents a linkage specification.
static FunctionTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a function template node.
const SourceRange & getSourceRange() const LLVM_READONLY
SourceLocation getLocStart() const LLVM_READONLY
void addDecl(NamedDecl *D)
Add a declaration to these results with its natural access. Does not test the acceptance criteria...
static bool isDeclTUScopedExternallyVisible(const Decl *D)
Returns true if given declaration is TU-scoped and externally visible.
llvm::DenseMap< IdentifierInfo *, AsmLabelAttr * > ExtnameUndeclaredIdentifiers
static bool isUsingDecl(NamedDecl *D)
CanQualType UnsignedCharTy
const LangOptions & LangOpts
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)
UnionParsedType ConstructorName
When Kind == IK_ConstructorName, the class-name of the type whose constructor is being referenced...
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
T castAs() const
Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type...
void DiagnoseUnknownTypeName(IdentifierInfo *&II, SourceLocation IILoc, Scope *S, CXXScopeSpec *SS, ParsedType &SuggestedType, bool AllowClassTemplates=false)
void ProcessDeclAttributeList(Scope *S, Decl *D, const AttributeList *AL, bool IncludeCXX11Attributes=true)
bool isFunctionOrFunctionTemplate() const
Whether this declaration is a function or function template.
The lookup results will be used for redeclaration of a name, if an entity by that name already exists...
TypeSpecTypeLoc pushTypeSpec(QualType T)
bool isDefined(const FunctionDecl *&Definition) const
param_iterator param_begin()
unsigned getMSLastManglingNumber() const
void setHasInheritedPrototype(bool P=true)
TyLocType push(QualType T)
field_iterator field_end() const
bool hasPrototype() const
Whether this function has a prototype, either because one was explicitly written or because it was "i...
bool IsOverload(FunctionDecl *New, FunctionDecl *Old, bool IsForUsingDecl)
Class that aids in the construction of nested-name-specifiers along with source-location information ...
SourceLocation getLoc() const
getLoc - Returns the main location of the declaration name.
AvailabilityResult
Captures the result of checking the availability of a declaration.
ImplicitCaptureStyle ImpCaptureStyle
void ForgetBuiltin(unsigned ID, IdentifierTable &Table)
Completely forget that the given ID was ever considered a builtin, e.g., because the user provided a ...
RAII class used to determine whether SFINAE has trapped any errors that occur during template argumen...
static const Decl * getDefinition(const Decl *D)
bool isLateTemplateParsed() const
Whether this templated function will be late parsed.
SmallVectorImpl< NamedDecl * >::const_iterator const_decl_iterator
CXXSpecialMember
Kinds of C++ special members.
void adjustDeducedFunctionResultType(FunctionDecl *FD, QualType ResultType)
Change the result type of a function type once it is deduced.
void completeDefinition(QualType NewType, QualType PromotionType, unsigned NumPositiveBits, unsigned NumNegativeBits)
static ImportDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, Module *Imported, ArrayRef< SourceLocation > IdentifierLocs)
Create a new module import declaration.
Decl * ActOnStartOfFunctionDef(Scope *S, Declarator &D)
DeclSpec & getMutableDeclSpec()
void setLazyBody(uint64_t Offset)
const ParmVarDecl *const * param_const_iterator
AvailabilityResult getAvailability(std::string *Message=nullptr) const
Determine the availability of the given declaration.
const ArrayType * castAsArrayTypeUnsafe() const
ExtInfo getExtInfo() const
Sema - This implements semantic analysis and AST building for C.
void pushExternalDeclIntoScope(NamedDecl *D, DeclarationName Name)
Make the given externally-produced declaration visible at the top level scope.
llvm::APInt getValue() const
bool isFunctionDeclarator(unsigned &idx) const
bool Mutable
Whether this is a mutable lambda.
TST getTypeSpecType() const
SmallVector< ReturnStmt *, 4 > Returns
The list of return statements that occur within the function or block, if there is any chance of appl...
const DeclarationNameInfo & getLookupNameInfo() const
Gets the name info to look up.
QualType getParamType(unsigned i) const
void AddInitializerToDecl(Decl *dcl, Expr *init, bool DirectInit, bool TypeMayContainAuto)
void MakeTrivial(ASTContext &Context, NestedNameSpecifier *Qualifier, SourceRange R)
Make a new nested-name-specifier from incomplete source-location information.
bool isReturnsTwice(unsigned ID) const
Return true if we know this builtin can return twice.
SourceLocation getLocStart() const LLVM_READONLY
SourceLocation getModulePrivateSpecLoc() const
std::string CurrentModule
The name of the current module.
static void mergeParamDeclAttributes(ParmVarDecl *newDecl, const ParmVarDecl *oldDecl, Sema &S)
Qualifiers::ObjCLifetime getObjCLifetime() const
getObjCLifetime - Returns lifetime attribute of this type.
TypeSpecifierType isTagName(IdentifierInfo &II, Scope *S)
bool inferObjCARCLifetime(ValueDecl *decl)
Represents a ValueDecl that came out of a declarator. Contains type source information through TypeSo...
void SetRangeStart(SourceLocation Loc)
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat)
DeclarationNameTable DeclarationNames
SourceLocation getLBracketLoc() const
bool MergeFunctionDecl(FunctionDecl *New, NamedDecl *&Old, Scope *S, bool MergeTypeWithOld)
SourceLocation getTypeSpecStartLoc() const
std::vector< bool > & Stack
SourceLocation getInnerLocStart() const
ArrayRef< NamedDecl * > getDeclsInPrototypeScope() const
Captures information about a #pragma weak directive.
ID
Defines the set of possible language-specific address spaces.
StorageClass getStorageClass() const
Returns the storage class as written in the source. For the computed linkage of symbol, see getLinkage.
const CXXMethodDecl *const * method_iterator
QualType getPointeeType() const
bool isFunctionPointerType() const
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
bool isCXXClassMember() const
Determine whether this declaration is a C++ class member.
NameKind getNameKind() const
getNameKind - Determine what kind of name this is.
static NamedDecl * DiagnoseInvalidRedeclaration(Sema &SemaRef, LookupResult &Previous, FunctionDecl *NewFD, ActOnFDArgs &ExtraArgs, bool IsLocalFriend, Scope *S)
Generate diagnostics for an invalid function redeclaration.
static bool isDeclRep(TST T)
unsigned getTypeQualifiers() const
getTypeQualifiers - Return a set of TQs.
void setVisible(Module *M, SourceLocation Loc, VisibleCallback Vis=[](Module *){}, ConflictCallback Cb=[](ArrayRef< Module * >, Module *, StringRef){})
Make a specific module visible.
bool canKeyFunctionBeInline() const
Can an out-of-line inline function serve as a key function?
static CXXDestructorDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool isInline, bool isImplicitlyDeclared)
bool isSignedIntegerOrEnumerationType() const
SpecifierKind getKind() const
Determine what kind of nested name specifier is stored.
unsigned getNumExprs() const
bool isDeleted() const
Whether this function has been deleted.
DeclContext * getLexicalParent()
CXXMethodDecl * CallOperator
The lambda's compiler-generated operator().
bool isGlobal() const
Determines whether this is a global function.
const char * getTypeName(ID Id)
getTypeName - Return the name of the type for Id.
bool isNoThrow(unsigned ID) const
Return true if we know this builtin never throws an exception.
bool isMicrosoft() const
Is this ABI an MSVC-compatible ABI?
VarTemplateDecl * getDescribedVarTemplate() const
Retrieves the variable template that is described by this variable declaration.
const Type * getTypeForDecl() const
SourceLocation getRBracketLoc() const
unsigned param_size() const
unsigned getTypeQualifiers() const
bool isUndeducedType() const
Determine whether this type is an undeduced type, meaning that it somehow involves a C++11 'auto' typ...
DeclarationName getLookupName() const
Gets the name to look up.
LookupNameKind
Describes the kind of name lookup to perform.
StringRef getName() const
Return the actual identifier string.
const Expr * getExpr(unsigned Init) const
static bool isResultTypeOrTemplate(LookupResult &R, const Token &NextToken)
Determine whether the given result set contains either a type name or.
Represents a character-granular source range.
The "typename" keyword precedes the qualified type name, e.g., typename T::type.
DLLImportAttr * mergeDLLImportAttr(Decl *D, SourceRange Range, unsigned AttrSpellingListIndex)
static unsigned getMaxSizeBits(ASTContext &Context)
Determine the maximum number of active bits that an array's size can require, which limits the maximu...
SourceLocation getAtomicSpecLoc() const
bool isDeclScope(Decl *D)
llvm::SmallPtrSet< const Decl *, 4 > ParsingInitForAutoVars
static Kind getNullabilityAttrKind(NullabilityKind kind)
static bool checkForConflictWithNonVisibleExternC(Sema &S, const T *ND, LookupResult &Previous)
NestedNameSpecifier * getCorrectionSpecifier() const
Gets the NestedNameSpecifier needed to use the typo correction.
bool isFunctionDefinition() const
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...
unsigned SymbolLocations[3]
The source locations of the individual tokens that name the operator, e.g., the "new", "[", and "]" tokens in operator new [].
SourceLocation getNameLoc() const
This file defines the classes used to store parsed information about declaration-specifiers and decla...
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context encloses the declaration context DC.
TemplateName getOverloadedTemplateName(UnresolvedSetIterator Begin, UnresolvedSetIterator End) const
Retrieve the template name that corresponds to a non-empty lookup.
static InitializedEntity InitializeVariable(VarDecl *Var)
Create the initialization entity for a variable.
static bool ValidDuplicateEnum(EnumConstantDecl *ECD, EnumDecl *Enum)
Represents a C++ destructor within a class.
void setInvalidDecl(bool Invalid=true)
TranslationUnitDecl * getTranslationUnitDecl() const
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup. Asserts that one was found.
bool isObjCGCWeak() const
isObjCGCWeak true when Type is objc's weak.
void ClearTypeQualifiers()
Clear out all of the type qualifiers.
bool isVariableArrayType() const
Decl * BuildMicrosoftCAnonymousStruct(Scope *S, DeclSpec &DS, RecordDecl *Record)
Defines the clang::Preprocessor interface.
static DelayedDiagnostic makeForbiddenType(SourceLocation loc, unsigned diagnostic, QualType type, unsigned argument)
Decl * getMostRecentDecl()
Retrieve the most recent declaration that declares the same entity as this declaration (which may be ...
const ParmVarDecl * getParamDecl(unsigned i) const
ExtProtoInfo getExtProtoInfo() const
ExtProtoInfo withExceptionSpec(const ExceptionSpecInfo &O)
static void CheckPoppedLabel(LabelDecl *L, Sema &S)
llvm::MapVector< IdentifierInfo *, WeakInfo > WeakUndeclaredIdentifiers
Defines the classes clang::DelayedDiagnostic and clang::AccessedEntity.
SourceLocation getVolatileSpecLoc() const
bool isLocalExternDecl()
Determine whether this is a block-scope declaration with linkage. This will either be a local variabl...
bool isFirstDecl() const
True if this is the first declaration in its redeclaration chain.
bool supportsVariadicCall(CallingConv CC)
Checks whether the given calling convention supports variadic calls. Unprototyped calls also use the ...
DeclContext * getDeclContext()
void CheckAlignasUnderalignment(Decl *D)
This declaration is a tentative definition.
bool isFloatingType() const
ParmVarDecl *const * param_iterator
void setObjCIdRedefinitionType(QualType RedefType)
Set the user-written type that redefines id.
static QualType getNextLargerIntegralType(ASTContext &Context, QualType T)
static TagTypeKind getTagTypeKindForTypeSpec(unsigned TypeSpec)
void setMemberSpecialization()
Note that this member template is a specialization.
Represents a C++ template name within the type system.
bool isWrittenInMainFile(SourceLocation Loc) const
Returns true if the spelling location for the given location is in the main file buffer.
bool isInSystemHeader(SourceLocation Loc) const
Returns if a SourceLocation is in a system header.
NamedDecl * ActOnTypedefNameDecl(Scope *S, DeclContext *DC, TypedefNameDecl *D, LookupResult &Previous, bool &Redeclaration)
bool isMSAsmLabel() const
bool isFunctionNoProtoType() const
bool isObjCIdType() const
Decl * ActOnField(Scope *S, Decl *TagD, SourceLocation DeclStart, Declarator &D, Expr *BitfieldWidth)
bool isVisible(const NamedDecl *D)
Determine whether a declaration is visible to name lookup.
bool isInlined() const
Determine whether this function should be inlined, because it is either marked "inline" or "constexpr...
void UpdateTypeRep(ParsedType Rep)
SourceLocation getLocation() const
Return a source location identifier for the specified offset in the current file. ...
bool isConstexprSpecified() const
CharUnits toCharUnitsFromBits(int64_t BitSize) const
Convert a size in bits to a size in characters.
void setConstexpr(bool IC)
FieldDecl * CheckFieldDecl(DeclarationName Name, QualType T, TypeSourceInfo *TInfo, RecordDecl *Record, SourceLocation Loc, bool Mutable, Expr *BitfieldWidth, InClassInitStyle InitStyle, SourceLocation TSSL, AccessSpecifier AS, NamedDecl *PrevDecl, Declarator *D=nullptr)
Build a new FieldDecl and check its well-formedness.
Expr * getAsmLabel() const
MSInheritanceAttr * mergeMSInheritanceAttr(Decl *D, SourceRange Range, bool BestCase, unsigned AttrSpellingListIndex, MSInheritanceAttr::Spelling SemanticSpelling)
QualType getType() const
Get the type for which this source info wrapper provides information.
static void checkNewAttributesAfterDef(Sema &S, Decl *New, const Decl *Old)
static StorageClass getFunctionStorageClass(Sema &SemaRef, Declarator &D)
QualType getAdjustedParameterType(QualType T) const
Perform adjustment on the parameter type of a function.
bool isScoped() const
Returns true if this is a C++11 scoped enumeration.
static bool hasSimilarParameters(ASTContext &Context, FunctionDecl *Declaration, FunctionDecl *Definition, SmallVectorImpl< unsigned > &Params)
StorageClass
Storage classes.
Expr * getSubExpr() const
const SourceRange & getRange() const
bool isDependentType() const
void AdjustDestructorExceptionSpec(CXXRecordDecl *ClassDecl, CXXDestructorDecl *Destructor)
Build an exception spec for destructors that don't have one.
Direct list-initialization (C++11)
bool isFunctionOrMethod() const
InClassInitStyle
In-class initialization styles for non-static data members.
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool EvaluateAsInt(llvm::APSInt &Result, const ASTContext &Ctx, SideEffectsKind AllowSideEffects=SE_NoSideEffects) const
QualType getCXXNameType() const
QualType getObjCIdType() const
Represents the Objective-CC id type.
An expression that sends a message to the given Objective-C object or class.
bool isExternallyVisible() const
void setModedTypeSourceInfo(TypeSourceInfo *unmodedTSI, QualType modedTy)
DeclContextLookupResult slice(size_t N) const
const IdentifierInfo * getBaseTypeIdentifier() const
Retrieves a pointer to the name of the base type.
Sema & getSema() const
Get the Sema object that this lookup result is searching with.
struct CXXOpName CXXOperatorName
DeclarationName getDeclName() const
DeclContext * getContainingDC(DeclContext *DC)
void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext=true)
Add this decl to the scope shadowed decl chains.
TagDecl * getDefinition() const
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
Linkage getFormalLinkage() const
Get the linkage from a semantic point of view. Entities in anonymous namespaces are external (in c++9...
void setStorageClass(StorageClass SC)
Represents a C++ conversion function within a class.
sema::LambdaScopeInfo * PushLambdaScope()
The result type of a method or function.
NamedDecl * LookupSingleName(Scope *S, DeclarationName Name, SourceLocation Loc, LookupNameKind NameKind, RedeclarationKind Redecl=NotForRedeclaration)
Look up a name, looking for a single declaration. Return null if the results were absent...
SourceLocation getLocEnd() const LLVM_READONLY
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
SourceLocation getStorageClassSpecLoc() const
RecordDecl * getDefinition() const
FunctionTemplateDecl * getTemplate() const
Retrieve the template from which this function was specialized.
static bool shouldConsiderLinkage(const VarDecl *VD)
bool checkInitIsICE() const
Determine whether the value of the initializer attached to this declaration is an integral constant e...
bool isTemplateInstantiation(TemplateSpecializationKind Kind)
Determine whether this template specialization kind refers to an instantiation of an entity (as oppos...
bool hasNonTrivialCopyAssignment() const
Determine whether this class has a non-trivial copy assignment operator (C++ [class.copy]p11, C++11 [class.copy]p25)
TypeSourceInfo * getTypeSourceInfo() const
bool isVirtualSpecified() const
static void ReportOverrides(Sema &S, unsigned DiagID, const CXXMethodDecl *MD, OverrideErrorKind OEK=OEK_All)
Report an error regarding overriding, along with any relevant overriden methods.
ObjCKeywordKind
Provides a namespace for Objective-C keywords which start with an '@'.
static bool CheckAnonMemberRedeclaration(Sema &SemaRef, Scope *S, DeclContext *Owner, DeclarationName Name, SourceLocation NameLoc, unsigned diagnostic)
void setDeclContext(DeclContext *DC)
CallingConv
CallingConv - Specifies the calling convention that a function uses.
TypedefNameDecl * getTypedefNameForAnonDecl() const
VarDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
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.
unsigned getSpellingListIndex() const
const clang::PrintingPolicy & getPrintingPolicy() const
bool isConstexpr() const
Whether this is a (C++11) constexpr function or constexpr constructor.
decl_type * getFirstDecl()
Return the first declaration of this declaration or itself if this is the only declaration.
TemplateName getQualifiedTemplateName(NestedNameSpecifier *NNS, bool TemplateKeyword, TemplateDecl *Template) const
Retrieve the template name that represents a qualified template name such as std::vector.
StringRef getTopLevelModuleName() const
Retrieve the name of the top-level module.
static InitializationKind CreateCopy(SourceLocation InitLoc, SourceLocation EqualLoc, bool AllowExplicitConvs=false)
Create a copy initialization.
static CXXRecordDecl * Create(const ASTContext &C, TagKind TK, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, CXXRecordDecl *PrevDecl=nullptr, bool DelayTypeCreation=false)
NameClassification ClassifyName(Scope *S, CXXScopeSpec &SS, IdentifierInfo *&Name, SourceLocation NameLoc, const Token &NextToken, bool IsAddressOfOperand, std::unique_ptr< CorrectionCandidateCallback > CCC=nullptr)
Perform name lookup on the given name, classifying it based on the results of name lookup and the fol...
param_const_iterator param_end() const
static bool checkGlobalOrExternCConflict(Sema &S, const T *ND, bool IsGlobal, LookupResult &Previous)
static UnqualifiedTypeNameLookupResult lookupUnqualifiedTypeNameInBase(Sema &S, const IdentifierInfo &II, SourceLocation NameLoc, const CXXRecordDecl *RD)
Tries to perform unqualified lookup of the type decls in bases for dependent class.
NestedNameSpecifier * getScopeRep() const
Retrieve the representation of the nested-name-specifier.
Decl * ActOnSkippedFunctionBody(Decl *Decl)
bool isInMainFile(SourceLocation Loc) const
Returns whether the PresumedLoc for a given SourceLocation is in the main file.
SourceLocation getLocStart() const LLVM_READONLY
UnqualifiedTypeNameLookupResult
NamedDecl * ImplicitlyDefineFunction(SourceLocation Loc, IdentifierInfo &II, Scope *S)
static bool isIncompleteDeclExternC(Sema &S, const T *D)
void initializeFullCopy(TypeLoc Other) const
Initializes this by copying its information from another TypeLoc of the same type.
TypeLoc getInnerLoc() const
void setTypeForDecl(const Type *TD)
Wrapper for source info for arrays.
ClassTemplateDecl * getDescribedClassTemplate() const
Retrieves the class template that is described by this class declaration.
static unsigned getMSManglingNumber(const LangOptions &LO, Scope *S)
bool doesThisDeclarationHaveABody() const
There is no lifetime qualification on this type.
ExtInfo withRegParm(unsigned RegParm) const
DeclContext * getEntity() const
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
SourceRange getReturnTypeSourceRange() const
Attempt to compute an informative source range covering the function return type. This may omit quali...
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl. It will iterate at least once ...
unsigned getTypeAlign(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in bits.
void makeDeclVisibleInContext(NamedDecl *D)
Makes a declaration visible within this context.
void ActOnFinishKNRParamDeclarations(Scope *S, Declarator &D, SourceLocation LocAfterDecls)
DeclarationNameInfo getNameForTemplate(TemplateName Name, SourceLocation NameLoc) const
static bool hasParsedAttr(Scope *S, const AttributeList *AttrList, AttributeList::Kind Kind)
bool isIntegralOrEnumerationType() const
Determine whether this type is an integral or enumeration type.
bool isConst(unsigned ID) const
Return true if this function has no side effects and doesn't read memory.
decl_type * getPreviousDecl()
Return the previous declaration of this declaration or NULL if this is the first declaration.
static DeclaratorChunk getReference(unsigned TypeQuals, SourceLocation Loc, bool lvalue)
Return a DeclaratorChunk for a reference.
bool isInjectedClassName() const
Determines whether this declaration represents the injected class name.
FunctionDecl * getAsFunction() LLVM_READONLY
Returns the function itself, or the templated function if this is a function template.
bool IsValueInFlagEnum(const EnumDecl *ED, const llvm::APInt &Val, bool AllowMask) const
SourceLocation getOuterLocStart() const
ExternCContextDecl * getExternCContextDecl() const
Encodes a location in the source. The SourceManager can decode this to get at the full include stack...
bool isAnonymousStructOrUnion() const
void setTopLevelDeclInObjCContainer(bool V=true)
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
bool CheckForConstantInitializer(Expr *e, QualType t)
type checking declaration initializers (C99 6.7.8)
unsigned getNumParams() const
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
SourceLocation CurrentPragmaLocation
const Type * getTypePtr() const
bool containedInPrototypeScope() const
unsigned getBitWidthValue(const ASTContext &Ctx) const
method_iterator begin_overridden_methods() const
bool isPredefinedRuntimeFunction(unsigned ID) const
Determines whether this builtin is a predefined compiler-rt/libgcc function, such as "__clear_cache"...
CXXRecordDecl * Lambda
The class that describes the lambda.
static bool FindOverriddenMethod(const CXXBaseSpecifier *Specifier, CXXBasePath &Path, void *UserData)
Member lookup function that determines whether a given C++ method overrides a method in a base class...
An overloaded operator name, e.g., operator+.
Expr * getRepAsExpr() const
bool isShadowed() const
Determine whether the lookup result was shadowed by some other declaration that lookup ignored...
DLLExportAttr * mergeDLLExportAttr(Decl *D, SourceRange Range, unsigned AttrSpellingListIndex)
UnqualifiedId & getName()
Retrieve the name specified by this declarator.
void FinalizeDeclaration(Decl *D)
static CXXConstructorDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, bool isExplicit, bool isInline, bool isImplicitlyDeclared, bool isConstexpr)
void AddKnownFunctionAttributes(FunctionDecl *FD)
Adds any function attributes that we know a priori based on the declaration of this function...
void ActOnPragmaWeakID(IdentifierInfo *WeakName, SourceLocation PragmaLoc, SourceLocation WeakNameLoc)
ActOnPragmaWeakID - Called on well formed #pragma weak ident.
bool isValid() const
Return true if this is a valid SourceLocation object.
OverloadedOperatorKind getCXXOverloadedOperator() const
void setFreeStanding(bool isFreeStanding=true)
void disableCheckFallThrough()
void ExitDeclaratorContext(Scope *S)
TagDecl - Represents the declaration of a struct/union/class/enum.
LanguageLinkage
Describes the different kinds of language linkage (C++ [dcl.link]) that an entity may have...
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
ASTContext & getASTContext() const LLVM_READONLY
TypeSourceInfo * getTrivialTypeSourceInfo(QualType T, SourceLocation Loc=SourceLocation()) const
Allocate a TypeSourceInfo where all locations have been initialized to a given location, which defaults to the empty location.
ASTContext & getASTContext() const
bool isLocalVarDecl() const
Data used with FindOverriddenMethod.
static const TST TST_union
InheritableAttr * getDLLAttr(Decl *D)
Return a DLL attribute from the declaration.
bool SetStorageClassSpec(Sema &S, SCS SC, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
ParsedType getRepAsType() const
bool isConstWithoutErrno(unsigned ID) const
Return true if this function has no side effects and doesn't read memory, except for possibly errno...
const char * GetName(unsigned ID) const
Return the identifier name for the specified builtin, e.g. "__builtin_abs".
Represents a static or instance method of a struct/union/class.
void setDefaulted(bool D=true)
void setHasFlexibleArrayMember(bool V)
bool canDelayFunctionBody(const Declarator &D)
Determine whether we can delay parsing the body of a function or function template until it is used...
bool hasVisibleDefinition(NamedDecl *D, NamedDecl **Suggested, bool OnlyNeedComplete=false)
Determine whether there is any declaration of D that was ever a definition (perhaps before module mer...
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
void addOverriddenMethod(const CXXMethodDecl *MD)
static ParsedType buildNestedType(Sema &S, CXXScopeSpec &SS, QualType T, SourceLocation NameLoc)
Build a ParsedType for a simple-type-specifier with a nested-name-specifier.
void setEntity(DeclContext *E)
QualType getElaboratedType(ElaboratedTypeKeyword Keyword, const CXXScopeSpec &SS, QualType T)
Retrieve a version of the type 'T' that is elaborated by Keyword and qualified by the nested-name-spe...
ExtInfo withNoReturn(bool noReturn) const
bool isInvalid() const
An error occurred during parsing of the scope specifier.
SourceLocation getStrTokenLoc(unsigned TokNum) const
A friend of a previously-declared entity.
Name lookup found an unresolvable value declaration and cannot yet complete. This only happens in C++...
MemberPointerTypeInfo Mem
void ResetObjCLayout(const ObjCContainerDecl *CD)
bool isIntegerConstantExpr(llvm::APSInt &Result, const ASTContext &Ctx, SourceLocation *Loc=nullptr, bool isEvaluated=true) const
SourceLocation getConstexprSpecLoc() const
bool MergeCompatibleFunctionDecls(FunctionDecl *New, FunctionDecl *Old, Scope *S, bool MergeTypeWithOld)
Completes the merge of two function declarations that are known to be compatible. ...
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...
bool hasVolatileMember() const
FunctionTemplateDecl * getPreviousDecl()
Retrieve the previous declaration of this function template, or NULL if no such declaration exists...
This declaration is only a declaration.
static DeclaratorChunk getFunction(bool HasProto, bool IsAmbiguous, SourceLocation LParenLoc, ParamInfo *Params, unsigned NumParams, SourceLocation EllipsisLoc, SourceLocation RParenLoc, unsigned TypeQuals, bool RefQualifierIsLvalueRef, SourceLocation RefQualifierLoc, SourceLocation ConstQualifierLoc, SourceLocation VolatileQualifierLoc, SourceLocation RestrictQualifierLoc, SourceLocation MutableLoc, ExceptionSpecificationType ESpecType, SourceLocation ESpecLoc, ParsedType *Exceptions, SourceRange *ExceptionRanges, unsigned NumExceptions, Expr *NoexceptExpr, CachedTokens *ExceptionSpecTokens, SourceLocation LocalRangeBegin, SourceLocation LocalRangeEnd, Declarator &TheDeclarator, TypeResult TrailingReturnType=TypeResult())
SourceLocation getVirtualSpecLoc() const
static const TST TST_typeofType
SourceLocation getBegin() const
bool isTypeDependent() const
SourceLocation getBeginLoc() 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.
QualType getAttributedType(AttributedType::Kind attrKind, QualType modifiedType, QualType equivalentType)
bool isFileContext() const
static bool AllowOverloadingOfFunction(LookupResult &Previous, ASTContext &Context)
Determine whether we allow overloading of the function PrevDecl with another declaration.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
bool is(tok::TokenKind K) const
bool isDependentType() const
Whether this declaration declares a type that is dependent, i.e., a type that somehow depends on temp...
void ActOnLastBitfield(SourceLocation DeclStart, SmallVectorImpl< Decl * > &AllIvarDecls)
unsigned getBuiltinID() const
Returns a value indicating whether this function corresponds to a builtin function.
bool isPromotableIntegerType() const
More type predicates useful for type checking/promotion.
static ImportDecl * CreateImplicit(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, Module *Imported, SourceLocation EndLoc)
Create a new module import declaration for an implicitly-generated import.
bool isInlineSpecified() const
Determine whether the "inline" keyword was specified for this function.
Assigning into this object requires a lifetime extension.
bool hasObjectMember() const
static bool isExternC(T *D)
Attr * clone(ASTContext &C) const
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
bool isScanfLike(unsigned ID, unsigned &FormatIdx, bool &HasVAListArg)
Determine whether this builtin is like scanf in its formatting rules and, if so, set the index to the...
void ActOnFields(Scope *S, SourceLocation RecLoc, Decl *TagDecl, ArrayRef< Decl * > Fields, SourceLocation LBrac, SourceLocation RBrac, AttributeList *AttrList)
void setObjCSuperType(QualType ST)
SourceLocation getLocStart() const LLVM_READONLY
bool isIgnored(unsigned DiagID, SourceLocation Loc) const
Determine whether the diagnostic is known to be ignored.
void setLAngleLoc(SourceLocation Loc)
static bool isRepresentableIntegerValue(ASTContext &Context, llvm::APSInt &Value, QualType T)
Determine whether the given integral value is representable within the given type T...
MutableArrayRef< Expr * > MultiExprArg
void setFunctionDefinitionKind(FunctionDefinitionKind Val)
QualType getType() const
Return the type wrapped by this type source info.
void setTemplateParameterListsInfo(ASTContext &Context, unsigned NumTPLists, TemplateParameterList **TPLists)
static void LookupPredefedObjCSuperType(Sema &ThisSema, Scope *S, IdentifierInfo *II)
Looks up the declaration of "struct objc_super" and saves it for later use in building builtin declar...
static unsigned getRedeclDiagFromTagKind(TagTypeKind Tag)
Get diagnostic select index for tag kind for redeclaration diagnostic message. WARNING: Indexes apply...
Describes a module import declaration, which makes the contents of the named module visible in the cu...
SourceLocation getExprLoc() const LLVM_READONLY
bool isFunctionProtoType() const
QualType getPointeeType() const
void setVirtualAsWritten(bool V)
A constructor named via a template-id.
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
CXXSpecialMember getSpecialMember(const CXXMethodDecl *MD)
getSpecialMember - get the special member enum for a method.
QualType getDependentNameType(ElaboratedTypeKeyword Keyword, NestedNameSpecifier *NNS, const IdentifierInfo *Name, QualType Canon=QualType()) const
bool containsPlaceholderType() const
QualType getObjCSelType() const
Retrieve the type that corresponds to the predefined Objective-C 'SEL' type.
static bool isOutOfScopePreviousDeclaration(NamedDecl *, DeclContext *, ASTContext &)
Determines whether the given declaration is an out-of-scope previous declaration. ...
void takeAttributes(ParsedAttributes &attrs, SourceLocation lastLoc)
AttributeFactory & getFactory() const
CanQualType UnsignedShortTy
bool isInitCapture() const
Whether this variable is the implicit variable for a lambda init-capture.
static void checkModuleImportContext(Sema &S, Module *M, SourceLocation ImportLoc, DeclContext *DC)
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
void createImplicitModuleImportForErrorRecovery(SourceLocation Loc, Module *Mod)
Create an implicit import of the given module at the given source location, for error recovery...
void diagnoseTypo(const TypoCorrection &Correction, const PartialDiagnostic &TypoDiag, bool ErrorRecovery=true)
attr::Kind getKind() const
Base class for declarations which introduce a typedef-name.
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T-> getSizeExpr()))
TLS with a dynamic initializer.
void ActOnReenterFunctionContext(Scope *S, Decl *D)
Push the parameters of D, which must be a function, into scope.
ParsedType ActOnDelayedDefaultTemplateArg(const IdentifierInfo &II, SourceLocation NameLoc)
For compatibility with MSVC, we delay parsing of some default template type arguments until instantia...
Represents a type which was implicitly adjusted by the semantic engine for arbitrary reasons...
static DeclGroupRef Create(ASTContext &C, Decl **Decls, unsigned NumDecls)
TagTypeKind
The kind of a tag type.
TSCS getThreadStorageClassSpec() const
static ParmVarDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, StorageClass S, Expr *DefArg)
static LinkageSpecDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation ExternLoc, SourceLocation LangLoc, LanguageIDs Lang, bool HasBraces)
SourceRange getCXXOperatorNameRange() const
static void FixInvalidVariablyModifiedTypeLoc(TypeLoc SrcTL, TypeLoc DstTL)
void setImplicitlyInline()
Flag that this function is implicitly inline.
void setHasVolatileMember(bool val)
ParmVarDecl * BuildParmVarDeclForTypedef(DeclContext *DC, SourceLocation Loc, QualType T)
Synthesizes a variable for a parameter arising from a typedef.
A qualifier set is used to build a set of qualifiers.
QualType mergeTypes(QualType, QualType, bool OfBlockPointer=false, bool Unqualified=false, bool BlockReturnType=false)
unsigned getMSCurManglingNumber() const
bool isAggregateType() const
Determines whether the type is a C++ aggregate type or C aggregate or union type. ...
The base class of all kinds of template declarations (e.g., class, function, etc.).
void EnterDeclaratorContext(Scope *S, DeclContext *DC)
Sema::LookupNameKind getLookupKind() const
Gets the kind of lookup to perform.
A template instantiation that is currently in progress.
bool isZero() const
isZero - Test whether the quantity equals zero.
static const TST TST_decltype
SmallVectorImpl< UniqueVirtualMethod >::iterator overriding_iterator
static const TST TST_auto
bool lookupInBases(BaseMatchesCallback *BaseMatches, void *UserData, CXXBasePaths &Paths) const
Look for entities within the base classes of this C++ class, transitively searching all base class su...
bool isFriendSpecified() const
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return 0.
void DeclApplyPragmaWeak(Scope *S, NamedDecl *ND, WeakInfo &W)
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
bool isCanonicalDecl() const
Whether this particular Decl is a canonical one.
comments::FullComment * getCommentForDecl(const Decl *D, const Preprocessor *PP) const
void ActOnEnumBody(SourceLocation EnumLoc, SourceLocation LBraceLoc, SourceLocation RBraceLoc, Decl *EnumDecl, ArrayRef< Decl * > Elements, Scope *S, AttributeList *Attr)
SourceLocation getLocStart() const LLVM_READONLY
void ActOnTagFinishDefinition(Scope *S, Decl *TagDecl, SourceLocation RBraceLoc)
bool isInvalidDecl() const
unsigned getCharWidth() const
bool getProducesResult() const
TypeLoc IgnoreParens() const
void ActOnModuleBegin(SourceLocation DirectiveLoc, Module *Mod)
The parsed has entered a submodule.
bool DiagRuntimeBehavior(SourceLocation Loc, const Stmt *Statement, const PartialDiagnostic &PD)
Conditionally issue a diagnostic based on the current evaluation context.
unsigned getNextFunctionPrototypeIndex()
CanQualType UnsignedLongLongTy
bool isMissingDeclaratorOk()
Checks if this DeclSpec can stand alone, without a Declarator.
static FixItHint CreateRemoval(CharSourceRange RemoveRange)
Create a code modification hint that removes the given source range.
bool isCallingConv() const
const llvm::APSInt & getInitVal() const
ObjCInterfaceDecl * getDefinition()
Retrieve the definition of this class, or NULL if this class has been forward-declared (with @class) ...
SectionAttr * mergeSectionAttr(Decl *D, SourceRange Range, StringRef Name, unsigned AttrSpellingListIndex)
This is a scope that corresponds to the template parameters of a C++ template. Template parameter sco...
virtual void HandleImplicitImportDecl(ImportDecl *D)
Handle an ImportDecl that was implicitly created due to an inclusion directive. The default implement...
void setShadowed()
Note that we found and ignored a declaration while performing lookup.
unsigned getShortWidth() const
Return the size of 'signed short' and 'unsigned short' for this target, in bits.
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).
unsigned short getMaxTLSAlign() const
Return the maximum alignment (in bits) of a TLS variable.
static ObjCIvarDecl::AccessControl TranslateIvarVisibility(tok::ObjCKeywordKind ivarVisibility)
CallingConv getCC() const
const Type * strip(QualType type)
void handleTagNumbering(const TagDecl *Tag, Scope *TagScope)
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
Expr * getSizeExpr() const
DefinitionKind isThisDeclarationADefinition(ASTContext &) const
Check whether this declaration is a definition. If this could be a tentative definition (in C)...
bool isUsed(bool CheckUsedAttr=true) const
Whether this declaration was used, meaning that a definition is required.
void PushDeclContext(Scope *S, DeclContext *DC)
Set the current declaration context until it gets popped.
static FunctionDecl * CreateNewFunctionDecl(Sema &SemaRef, Declarator &D, DeclContext *DC, QualType &R, TypeSourceInfo *TInfo, StorageClass SC, bool &IsVirtualOkay)
MangleNumberingContext & getManglingNumberContext(const DeclContext *DC)
Retrieve the context for computing mangling numbers in the given DeclContext.
A mapping from each virtual member function to its set of final overriders.
StringRef getString() const
virtual ModuleLoadResult loadModule(SourceLocation ImportLoc, ModuleIdPath Path, Module::NameVisibilityKind Visibility, bool IsInclusionDirective)=0
Attempt to load the given module.
bool isThisDeclarationADefinition() const
SourceLocation getLocStart() const LLVM_READONLY
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
VisibilityAttr * mergeVisibilityAttr(Decl *D, SourceRange Range, VisibilityAttr::VisibilityType Vis, unsigned AttrSpellingListIndex)
void mergeNRVOIntoParent()
QualType getModifiedType() const
static bool isTagTypeWithMissingTag(Sema &SemaRef, LookupResult &Result, Scope *S, CXXScopeSpec &SS, IdentifierInfo *&Name, SourceLocation NameLoc)
bool isSimpleTypeSpecifier(tok::TokenKind Kind) const
Determine whether the token kind starts a simple-type-specifier.
const FunctionType * adjustFunctionType(const FunctionType *Fn, FunctionType::ExtInfo EInfo)
Change the ExtInfo on a function type.
SourceLocation getNoreturnSpecLoc() const
unsigned getNumArgs() const
bool isSingleResult() const
static bool ShouldDiagnoseUnusedDecl(const NamedDecl *D)
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
void ActOnStartCXXMemberDeclarations(Scope *S, Decl *TagDecl, SourceLocation FinalLoc, bool IsFinalSpelledSealed, SourceLocation LBraceLoc)
bool isMsStruct(const ASTContext &C) const
void MergeTypedefNameDecl(TypedefNameDecl *New, LookupResult &OldDecls)
void setPreviousDeclInSameBlockScope(bool Same)
static EnumDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, EnumDecl *PrevDecl, bool IsScoped, bool IsScopedUsingClassTag, bool IsFixed)
ParmVarDecl * CheckParameter(DeclContext *DC, SourceLocation StartLoc, SourceLocation NameLoc, IdentifierInfo *Name, QualType T, TypeSourceInfo *TSInfo, StorageClass SC)
static const TST TST_unspecified
static FileScopeAsmDecl * Create(ASTContext &C, DeclContext *DC, StringLiteral *Str, SourceLocation AsmLoc, SourceLocation RParenLoc)
DeclarationName getCorrection() const
Gets the DeclarationName of the typo correction.
std::string ImplementationOfModule
The name of the module that the translation unit is an implementation of. Prevents semantic imports...
bool DeclAttrsMatchCUDAMode(const LangOptions &LangOpts, Decl *D)
enum clang::DeclaratorChunk::@184 Kind
const RecordType * getAsStructureType() const
static std::pair< diag::kind, SourceLocation > getNoteDiagForInvalidRedeclaration(const T *Old, const T *New)
void setObjectOfFriendDecl(bool PerformFriendInjection=false)
Changes the namespace of this declaration to reflect that it's the object of a friend declaration...
All of the names in this module are visible.
known_extensions_range known_extensions() const
Expr * IgnoreParenImpCasts() LLVM_READONLY
DupKey(int64_t val, bool isTombstoneOrEmptyKey)
const VariableArrayType * getAsVariableArrayType(QualType T) const
param_iterator param_end()
void setLocalExternDecl()
Changes the namespace of this declaration to reflect that it's a function-local extern declaration...
void setNameLoc(SourceLocation Loc)
AvailabilityMergeKind
Describes the kind of merge to perform for availability attributes (including "deprecated", "unavailable", and "availability").
bool isConstantInitializer(ASTContext &Ctx, bool ForRef, const Expr **Culprit=nullptr) const
NamedDecl * ActOnTypedefDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, LookupResult &Previous)
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 ObjCIvarDecl * Create(ASTContext &C, ObjCContainerDecl *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, QualType T, TypeSourceInfo *TInfo, AccessControl ac, Expr *BW=nullptr, bool synthesized=false)
bool isObjCObjectType() const
NamedDecl * getCorrectionDecl() const
Gets the pointer to the declaration of the typo correction.
void DiagnoseUnusedParameters(ParmVarDecl *const *Begin, ParmVarDecl *const *End)
Diagnose any unused parameters in the given sequence of ParmVarDecl pointers.
bool isNotEmpty() const
A scope specifier is present, but may be valid or invalid.
bool isOneOf(tok::TokenKind K1, tok::TokenKind K2) const
unsigned getNumNegativeBits() const
Returns the width in bits required to store all the negative enumerators of this enum. These widths include the rightmost leading 1; that is:
void setIsUsed()
Set whether the declaration is used, in the sense of odr-use.
VarDecl * getTemplatedDecl() const
Get the underlying variable declarations of the template.
SourceManager & getSourceManager() const
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
void ActOnTagDefinitionError(Scope *S, Decl *TagDecl)
static void GenerateFixForUnusedDecl(const NamedDecl *D, ASTContext &Ctx, FixItHint &Hint)
void add(const sema::DelayedDiagnostic &diag)
Adds a delayed diagnostic.
QualType getCanonicalType() const
UsingDecl * getUsingDecl() const
Gets the using declaration to which this declaration is tied.
void setDescribedFunctionTemplate(FunctionTemplateDecl *Template)
CanQualType UnsignedLongTy
void addThisCapture(bool isNested, SourceLocation Loc, QualType CaptureType, Expr *Cpy)
void setNonMemberOperator()
Specifies that this declaration is a C++ overloaded non-member.
void setQualifierInfo(NestedNameSpecifierLoc QualifierLoc)
bool isRedeclaration() const
bool isDeclInScope(NamedDecl *D, DeclContext *Ctx, Scope *S=nullptr, bool AllowInlineNamespace=false)
EnumConstantDecl * CheckEnumConstant(EnumDecl *Enum, EnumConstantDecl *LastEnumConst, SourceLocation IdLoc, IdentifierInfo *Id, Expr *val)
static Scope * getScopeForDeclContext(Scope *S, DeclContext *DC)
QualType getIntegerType() const
void setTypeSourceInfo(TypeSourceInfo *TI)
void setBuiltinID(unsigned ID)
void setNonKeyFunction(const CXXMethodDecl *method)
Observe that the given method cannot be a key function. Checks the key-function cache for the method'...
bool isFunctionType() const
void CheckForFunctionRedefinition(FunctionDecl *FD, const FunctionDecl *EffectiveDefinition=nullptr)
static const TST TST_typename
Expr * getArg(unsigned Arg)
Return the specified argument.
DeclContext * getRedeclContext()
CXXConstructorDecl * getConstructor() const
const DeclarationNameLoc & getInfo() const
static void SetNestedNameSpecifier(DeclaratorDecl *DD, Declarator &D)
Simple template class for restricting typo correction candidates to ones having a single Decl* of the...
CXXRecordDecl * getAsCXXRecordDecl() const
Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...
FriendObjectKind getFriendObjectKind() const
Determines whether this declaration is the object of a friend declaration and, if so...
TypeSourceInfo * RebuildTypeInCurrentInstantiation(TypeSourceInfo *T, SourceLocation Loc, DeclarationName Name)
Rebuilds a type within the context of the current instantiation.
DeclGroupPtrTy FinalizeDeclaratorGroup(Scope *S, const DeclSpec &DS, ArrayRef< Decl * > Group)
void CheckShadow(Scope *S, VarDecl *D, const LookupResult &R)
Diagnose variable or built-in function shadowing. Implements -Wshadow.
void ActOnPragmaRedefineExtname(IdentifierInfo *WeakName, IdentifierInfo *AliasName, SourceLocation PragmaLoc, SourceLocation WeakNameLoc, SourceLocation AliasNameLoc)
static CXXMethodDecl * Create(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc, const DeclarationNameInfo &NameInfo, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool isInline, bool isConstexpr, SourceLocation EndLocation)
void setCXXForRangeDecl(bool FRD)
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
void ActOnCXXForRangeDecl(Decl *D)
Decl * BuildAnonymousStructOrUnion(Scope *S, DeclSpec &DS, AccessSpecifier AS, RecordDecl *Record, const PrintingPolicy &Policy)
bool wasNotFoundInCurrentInstantiation() const
Determine whether no result was found because we could not search into dependent base classes of the ...
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.
static SourceLocation findDefaultInitializer(const CXXRecordDecl *Record)
Implements a partial diagnostic that can be emitted anwyhere in a DiagnosticBuilder stream...
void setInherited(bool I)
void setBlockVarCopyInits(VarDecl *VD, Expr *Init)
Set the copy inialization expression of a block var decl.
bool isInlineSpecified() const
StmtResult ActOnCXXForRangeIdentifier(Scope *S, SourceLocation IdentLoc, IdentifierInfo *Ident, ParsedAttributes &Attrs, SourceLocation AttrEnd)
unsigned getIntWidth() const
unsigned getLongLongWidth() 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...
DeclResult ActOnModuleImport(SourceLocation AtLoc, SourceLocation ImportLoc, ModuleIdPath Path)
The parser has processed a module import declaration.
bool isStaticDataMember() const
Determines whether this is a static data member.
Represents a base class of a C++ class.
CXXScopeSpec & getTypeSpecScope()
static QualType GetTypeFromParser(ParsedType Ty, TypeSourceInfo **TInfo=nullptr)
void setNamedTypeInfo(TypeSourceInfo *TInfo)
void setDescribedClassTemplate(ClassTemplateDecl *Template)
This is a scope that can contain a declaration. Some scopes just contain loop constructs but don't co...
bool isCompatibleWithMSVC(MSVCMajorVersion MajorVersion) const
SourceManager & getSourceManager()
void * SkippedDefinitionContext
bool isTLSSupported() const
Whether the target supports thread-local storage.
IdentifierInfo * getIdentifier() const
bool SetTypeSpecType(TST T, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
NamedDecl * HandleDeclarator(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParameterLists)
bool LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx, bool InUnqualifiedLookup=false)
Perform qualified name lookup into a given context.
Expr * getFalseExpr() const
getFalseExpr - Return the subexpression which will be evaluated if the condnition evaluates to false;...
Decl * ParsedFreeStandingDeclSpec(Scope *S, AccessSpecifier AS, DeclSpec &DS)
void setPromotionType(QualType T)
Set the promotion type.
ObjCInterfaceDecl * getObjCInterfaceDecl(IdentifierInfo *&Id, SourceLocation IdLoc, bool TypoCorrection=false)
Look for an Objective-C class in the translation unit.
bool isFunctionPrototypeScope() const
const DeclContext * getCurObjCLexicalContext() const
bool isObjCGCStrong() const
isObjCGCStrong true when Type is objc's strong.
void setLoc(SourceLocation L)
setLoc - Sets the main location of the declaration name.
void setInvalidType(bool Val=true)
Reading or writing from this object requires a barrier call.
static bool isClassCompatTagKind(TagTypeKind Tag)
Determine if tag kind is a class-key compatible with class for redeclaration (class, struct, or __interface).
static bool isMainFileLoc(const Sema &S, SourceLocation Loc)
bool isPODType(ASTContext &Context) const
Determine whether this is a Plain Old Data (POD) type (C++ 3.9p10).
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate.h) and friends (in DeclFriend.h).
bool hasAddressSpace() const
Call-style initialization (C++98)
AttributePool & getPool() const
bool typesAreCompatible(QualType T1, QualType T2, bool CompareUnqualified=false)
Compatibility predicates used to check assignment expressions.
FunctionTemplateSpecializationInfo * getTemplateSpecializationInfo() const
If this function is actually a function template specialization, retrieve information about this func...
bool Failed() const
Determine whether the initialization sequence is invalid.
ThreadStorageClassSpecifier
Thread storage-class-specifier.
Describes the sequence of initializations required to initialize a given object or reference with a s...
static QualType TryToFixInvalidVariablyModifiedType(QualType T, ASTContext &Context, bool &SizeIsNegative, llvm::APSInt &Oversized)
Captures information about "declaration specifiers".
bool isExplicitSpecified() const
SourceLocation getIdentifierLoc() const
unsigned getNumPositiveBits() const
Returns the width in bits required to store all the non-negative enumerators of this enum...
const CXXMethodDecl * getCurrentKeyFunction(const CXXRecordDecl *RD)
Get our current best idea for the key function of the given record decl, or NULL if there isn't one...
Represents a C++ struct/union/class.
BoundNodesTreeBuilder *const Builder
TargetCXXABI getCXXABI() const
Get the C++ ABI currently in use.
static bool isCompoundAssignmentOp(Opcode Opc)
static const TSCS TSCS_thread_local
void setTSCSpec(ThreadStorageClassSpecifier TSC)
A user-defined literal name, e.g., operator "" _i.
static void RemoveUsingDecls(LookupResult &R)
Removes using shadow declarations from the lookup results.
void MergeVarDecl(VarDecl *New, LookupResult &Previous)
bool isObjCObjectPointerType() const
void setDescribedVarTemplate(VarTemplateDecl *Template)
static bool RebuildDeclaratorInCurrentInstantiation(Sema &S, Declarator &D, DeclarationName Name)
ExprResult VerifyBitField(SourceLocation FieldLoc, IdentifierInfo *FieldName, QualType FieldTy, bool IsMsStruct, Expr *BitWidth, bool *ZeroWidth=nullptr)
Missing a type from <stdio.h>
Optional< sema::TemplateDeductionInfo * > isSFINAEContext() const
Determines whether we are currently in a context where template argument substitution failures are no...
bool isOutOfLine() const override
Determine whether this is or was instantiated from an out-of-line definition of a static data member...
void setConstexpr(bool IC)
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
virtual bool isOutOfLine() const
static void filterNonConflictingPreviousDecls(Sema &S, NamedDecl *decl, LookupResult &previous)
Filter out any previous declarations that the given declaration should not consider because they are ...
static TypedefDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation IdLoc, IdentifierInfo *Id, TypeSourceInfo *TInfo)
CallingConv getDefaultCallingConvention(bool isVariadic, bool IsCXXMethod) const
Retrieves the default calling convention for the current target.
bool duplicatesAllowed() const
By default, attributes cannot be duplicated when being merged; however, an attribute can override thi...
TypeLoc getElementLoc() const
bool isClassScope() const
isClassScope - Return true if this scope is a class/struct/union scope.
void setLParenLoc(SourceLocation Loc)
Builtin::Context & BuiltinInfo
DeclContext * CurContext
CurContext - This is the current declaration context of parsing.
void ActOnPopScope(SourceLocation Loc, Scope *S)
Scope actions.
static VarTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, VarDecl *Decl)
Create a variable template node.
Declaration of a class template.
DeclContext * getLookupParent()
Find the parent context of this context that will be used for unqualified name lookup.
bool isConstexpr() const
Whether this variable is (C++11) constexpr.
unsigned kind
All of the diagnostics that can be emitted by the frontend.
static StorageClass StorageClassSpecToVarDeclStorageClass(const DeclSpec &DS)
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string...
void addVLATypeCapture(SourceLocation Loc, QualType CaptureType)
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
SmallVectorImpl< NamedDecl * >::iterator decl_iterator
LookupResultKind getResultKind() const
const T * getTypePtr() const
Retrieve the underlying type pointer, which refers to a canonical type.
unsigned getLongWidth() const
bool isTypeSpecOwned() const
TranslationUnitKind TUKind
The kind of translation unit we are processing.
Defines the clang::TargetInfo interface.
static IndirectFieldDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, IdentifierInfo *Id, QualType T, NamedDecl **CH, unsigned CHS)
bool Equals(const DeclContext *DC) const
Determine whether this declaration context is equivalent to the declaration context DC...
TLS with a known-constant initializer.
SourceRange getSourceRange() const override LLVM_READONLY
Source range that this declaration covers.
AvailabilityResult getCurContextAvailability() const
The translation unit is a complete translation unit.
void DiagnoseSizeOfParametersAndReturnValue(ParmVarDecl *const *Begin, ParmVarDecl *const *End, QualType ReturnTy, NamedDecl *D)
Diagnose whether the size of parameters or return value of a function or obj-c method definition is p...
static TagDecl * castFromDeclContext(const DeclContext *DC)
bool getHasRegParm() const
void setObjCSelRedefinitionType(QualType RedefType)
Set the user-written type that redefines 'SEL'.
static bool DeclHasAttr(const Decl *D, const Attr *A)
bool isIncompleteArrayType() const
static OpaquePtr make(QualTypeP)
static bool checkUsingShadowRedecl(Sema &S, UsingShadowDecl *OldS, ExpectedDecl *New)
Check whether a redeclaration of an entity introduced by a using-declaration is valid, given that we know it's not an overload (nor a hidden tag declaration).
decl_type * getMostRecentDecl()
Returns the most recent (re)declaration of this declaration.
TranslationUnitDecl - The top declaration context.
A reference to a declared variable, function, enum, etc. [C99 6.5.1p2].
void CheckConversionDeclarator(Declarator &D, QualType &R, StorageClass &SC)
Represents a type template specialization; the template must be a class template, a type alias templa...
SourceLocation getRAngleLoc() const
static const TST TST_atomic
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
NamedDecl * findLocallyScopedExternCDecl(DeclarationName Name)
Look for a locally scoped extern "C" declaration by the given name.
DeclContext * getPrimaryContext()
AvailabilityAttr * mergeAvailabilityAttr(NamedDecl *D, SourceRange Range, IdentifierInfo *Platform, VersionTuple Introduced, VersionTuple Deprecated, VersionTuple Obsoleted, bool IsUnavailable, StringRef Message, bool Override, unsigned AttrSpellingListIndex)
Attribute merging methods. Return true if a new attribute was added.
void ActOnObjCContainerFinishDefinition()
SourceManager & SourceMgr
bool isResolvedMSAsmLabel() const
static const TST TST_struct
Annotates a diagnostic with some code that should be inserted, removed, or replaced to fix the proble...
void addCapture(VarDecl *Var, bool isBlock, bool isByref, bool isNested, SourceLocation Loc, SourceLocation EllipsisLoc, QualType CaptureType, Expr *Cpy)
bool CheckEnumRedeclaration(SourceLocation EnumLoc, bool IsScoped, QualType EnumUnderlyingTy, const EnumDecl *Prev)
bool hasExceptionSpec() const
Return whether this function has any kind of exception spec.
SkippedDefinitionContext ActOnTagStartSkippedDefinition(Scope *S, Decl *TD)
Invoked when we enter a tag definition that we're skipping.
static bool hasDependentAlignment(VarDecl *VD)
Determines if a variable's alignment is dependent.
void suppressDiagnostics()
const DeclaratorChunk & getTypeObject(unsigned i) const
void ActOnModuleEnd(SourceLocation DirectiveLoc, Module *Mod)
The parser has left a submodule.
AttributeList * getNext() const
static StringRef getNameForCallConv(CallingConv CC)
uint32_t TypeID
An ID number that refers to a type in an AST file.
An l-value expression is a reference to an object with independent storage.
void setRParenLoc(SourceLocation Loc)
static bool anyDependentTemplateArguments(const TemplateArgumentLoc *Args, unsigned NumArgs, bool &InstantiationDependent)
Determine whether any of the given template arguments are dependent.
static DupKey GetDupKey(const llvm::APSInt &Val)
static unsigned getHashValue(const DupKey Key)
bool isInitICE() const
Determines whether the initializer is an integral constant expression, or in C++11, whether the initializer is a constant expression.
A trivial tuple used to represent a source range.
SourceLocation getLocation() const
UnqualTypeLoc getUnqualifiedLoc() const
Skips past any qualifiers, if this is qualified.
void setIntegerTypeSourceInfo(TypeSourceInfo *TInfo)
Set the underlying integer type source info.
void setLexicalDeclContext(DeclContext *DC)
TypoCorrection CorrectTypo(const DeclarationNameInfo &Typo, Sema::LookupNameKind LookupKind, Scope *S, CXXScopeSpec *SS, std::unique_ptr< CorrectionCandidateCallback > CCC, CorrectTypoKind Mode, DeclContext *MemberContext=nullptr, bool EnteringContext=false, const ObjCObjectPointerType *OPT=nullptr, bool RecordFailure=true)
Try to "correct" a typo in the source code by finding visible declarations whose names are similar to...
FunctionDecl * getCanonicalDecl() override
Retrieves the "canonical" declaration of the given declaration.
AlwaysInlineAttr * mergeAlwaysInlineAttr(Decl *D, SourceRange Range, IdentifierInfo *Ident, unsigned AttrSpellingListIndex)
void setIdentifier(const IdentifierInfo *Id, SourceLocation IdLoc)
Specify that this unqualified-id was parsed as an identifier.
DeclarationNameInfo getNameInfo() const
void setsigjmp_bufDecl(TypeDecl *sigjmp_bufDecl)
Set the type for the C sigjmp_buf type.
bool isInvalidType() const
void setFILEDecl(TypeDecl *FILEDecl)
Set the type for the C FILE type.
bool isModulePrivateSpecified() const
void setTypeSourceInfo(TypeSourceInfo *newType)
void setAccess(AccessSpecifier AS)
bool DeclMustBeEmitted(const Decl *D)
Determines if the decl can be CodeGen'ed or deserialized from PCH lazily, only when used; this is onl...
No keyword precedes the qualified type name.
static bool IsDisallowedCopyOrAssign(const CXXMethodDecl *D)
Check for this common pattern:
bool isConstQualified() const
Determine whether this type is const-qualified.
bool hasImplicitReturnZero() const
static void checkAttributesAfterMerging(Sema &S, NamedDecl &ND)
SourceLocation EndLocation
The location of the last token that describes this unqualified-id.
static bool mergeTypeWithPrevious(Sema &S, VarDecl *NewVD, VarDecl *OldVD, LookupResult &Previous)
bool isNull() const
isNull - Return true if this QualType doesn't point to a type yet.
TypeSourceInfo * getTypeSourceInfo() const
LambdaCaptureDefault getLambdaCaptureDefault() const
virtual void makeModuleVisible(Module *Mod, Module::NameVisibilityKind Visibility, SourceLocation ImportLoc)=0
Make the given module visible.
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.
Decl * getObjCDeclContext() const
bool isFirstDeclarationOfMember()
Returns true if this declares a real member and not a friend.
void SetRangeEnd(SourceLocation Loc)
void mergeObjCMethodDecls(ObjCMethodDecl *New, ObjCMethodDecl *Old)
Missing a type from <setjmp.h>
void setType(QualType newType)
Wrapper for source info for pointers.
Optional< NullabilityKind > getNullability(const ASTContext &context) const
void setDeletedAsWritten(bool D=true)
static bool isAttributeTargetADefinition(Decl *D)
DeclarationNameInfo GetNameForDeclarator(Declarator &D)
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.
QualType getBaseElementType(const ArrayType *VAT) const
Return the innermost element type of an array type.
enum clang::UnqualifiedId::IdKind Kind
Defines enum values for all the target-independent builtin functions.
Declaration of a template function.
void clear()
Clears out any current state.
void setElaboratedKeywordLoc(SourceLocation Loc)
Attr - This represents one attribute.
ParsedAttributes & getAttributes()
Represents a shadow declaration introduced into a scope by a (resolved) using declaration.
bool hasLocalStorage() const
void setRBraceLoc(SourceLocation L)
ParsedTemplateTy Template
const RecordDecl * getParent() const
Expr * IgnoreParens() LLVM_READONLY
const DeclSpec & getDeclSpec() const
Decl * ActOnDeclarator(Scope *S, Declarator &D)
CanQualType UnsignedIntTy
static void checkIsValidOpenCLKernelParameter(Sema &S, Declarator &D, ParmVarDecl *Param, llvm::SmallPtrSetImpl< const Type * > &ValidTypes)
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
void FilterLookupForScope(LookupResult &R, DeclContext *Ctx, Scope *S, bool ConsiderLinkage, bool AllowInlineNamespace)
bool isPointerType() const
unsigned getNumTemplateParameterLists() const
bool isPOD() const
Whether this class is a POD-type (C++ [class]p4)
void DiagnoseUnusedNestedTypedefs(const RecordDecl *D)
The translation unit is a module.
const AttributeList * getAttributes() const
SourceLocation getTemplateLoc() const
static NestedNameSpecifier * GlobalSpecifier(const ASTContext &Context)
Returns the nested name specifier representing the global scope.
QualType getDeducedType() const
Get the type deduced for this auto type, or null if it's either not been deduced or was deduced to a ...