45 #include "llvm/ADT/SmallString.h"
46 #include "llvm/ADT/Triple.h"
50 using namespace clang;
55 Decl *Group[2] = { OwnedType, Ptr };
66 TypeNameValidatorCCC(
bool AllowInvalid,
bool WantClass=
false,
67 bool AllowTemplates=
false)
68 : AllowInvalidDecl(AllowInvalid), WantClassName(WantClass),
69 AllowClassTemplates(AllowTemplates) {
70 WantExpressionKeywords =
false;
71 WantCXXNamedCasts =
false;
72 WantRemainingKeywords =
false;
77 bool IsType = isa<TypeDecl>(ND) || isa<ObjCInterfaceDecl>(ND);
78 bool AllowedTemplate = AllowClassTemplates && isa<ClassTemplateDecl>(ND);
79 return (IsType || AllowedTemplate) &&
80 (AllowInvalidDecl || !ND->isInvalidDecl());
82 return !WantClassName && candidate.
isKeyword();
86 bool AllowInvalidDecl;
88 bool AllowClassTemplates;
100 case tok::kw___int64:
101 case tok::kw___int128:
103 case tok::kw_unsigned:
110 case tok::kw_wchar_t:
112 case tok::kw___underlying_type:
113 case tok::kw___auto_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.getFoundDecl();
817 NamedDecl *UnderlyingFirstDecl = Corrected.getCorrectionDecl();
818 if (getLangOpts().
CPlusPlus && NextToken.
is(tok::less) &&
819 UnderlyingFirstDecl && isa<TemplateDecl>(UnderlyingFirstDecl)) {
820 UnqualifiedDiag = diag::err_no_template_suggest;
821 QualifiedDiag = diag::err_no_member_template_suggest;
822 }
else if (UnderlyingFirstDecl &&
823 (isa<TypeDecl>(UnderlyingFirstDecl) ||
824 isa<ObjCInterfaceDecl>(UnderlyingFirstDecl) ||
825 isa<ObjCCompatibleAliasDecl>(UnderlyingFirstDecl))) {
826 UnqualifiedDiag = diag::err_unknown_typename_suggest;
827 QualifiedDiag = diag::err_unknown_nested_typename_suggest;
831 diagnoseTypo(Corrected, PDiag(UnqualifiedDiag) << Name);
833 std::string CorrectedStr(Corrected.getAsString(getLangOpts()));
834 bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
835 Name->
getName().equals(CorrectedStr);
836 diagnoseTypo(Corrected, PDiag(QualifiedDiag)
837 << Name << computeDeclContext(SS,
false)
838 << DroppedSpecifier << SS.getRange());
842 Name = Corrected.getCorrectionAsIdentifierInfo();
845 if (Corrected.isKeyword())
861 ExprResult E(LookupInObjCMethod(Result, S, Ivar->getIdentifier()));
889 NameInfo, IsAddressOfOperand,
899 if (getLangOpts().
CPlusPlus && NextToken.
is(tok::less) &&
900 hasAnyAcceptableTemplateNames(Result)) {
912 FilterAcceptableTemplateNames(Result);
914 IsFilteredTemplateName =
true;
923 if (getLangOpts().
CPlusPlus && NextToken.
is(tok::less) &&
924 (IsFilteredTemplateName || hasAnyAcceptableTemplateNames(Result))) {
931 if (!IsFilteredTemplateName)
932 FilterAcceptableTemplateNames(Result);
934 if (!Result.
empty()) {
935 bool IsFunctionTemplate;
938 if (Result.
end() - Result.
begin() > 1) {
939 IsFunctionTemplate =
true;
944 = cast<TemplateDecl>((*Result.
begin())->getUnderlyingDecl());
945 IsFunctionTemplate = isa<FunctionTemplateDecl>(TD);
946 IsVarTemplate = isa<VarTemplateDecl>(TD);
956 if (IsFunctionTemplate) {
962 return NameClassification::FunctionTemplate(Template);
965 return IsVarTemplate ? NameClassification::VarTemplate(Template)
966 : NameClassification::TypeTemplate(Template);
972 DiagnoseUseOfDecl(
Type, NameLoc);
973 MarkAnyDeclReferenced(
Type->getLocation(),
Type,
false);
984 dyn_cast<ObjCCompatibleAliasDecl>(FirstDecl))
985 Class = Alias->getClassInterface();
989 DiagnoseUseOfDecl(Class, NameLoc);
991 if (NextToken.
is(tok::period)) {
1003 if (isa<TemplateDecl>(FirstDecl) && !isa<FunctionTemplateDecl>(FirstDecl))
1004 return NameClassification::TypeTemplate(
1009 bool NextIsOp = NextToken.
isOneOf(tok::amp, tok::star);
1010 if ((NextToken.
is(tok::identifier) ||
1015 DiagnoseUseOfDecl(Type, NameLoc);
1023 return BuildPossibleImplicitMemberExpr(SS,
SourceLocation(), Result,
1026 bool ADL = UseArgumentDependentLookup(SS, Result, NextToken.
is(tok::l_paren));
1027 return BuildDeclarationNameExpr(SS, Result, ADL);
1052 if (!isa<CXXRecordDecl>(DC))
1070 assert(getContainingDC(DC) == CurContext &&
1071 "The next DeclContext should be lexically contained in the current one.");
1077 assert(CurContext &&
"DeclContext imbalance!");
1079 CurContext = getContainingDC(CurContext);
1080 assert(CurContext &&
"Popped translation unit!");
1090 assert(CurContext &&
"skipping definition of undefined tag");
1093 S->
setEntity(CurContext->getLookupParent());
1098 CurContext =
static_cast<decltype(CurContext)
>(
Context);
1121 assert(!S->
getEntity() &&
"scope already has entity");
1125 while (!Ancestor->getEntity()) Ancestor = Ancestor->
getParent();
1126 assert(Ancestor->getEntity() == CurContext &&
"ancestor context mismatch");
1134 assert(S->
getEntity() == CurContext &&
"Context imbalance!");
1139 while (!Ancestor->getEntity()) Ancestor = Ancestor->
getParent();
1157 "The next DeclContext should be lexically contained in the current one.");
1161 for (
unsigned P = 0, NumParams = FD->
getNumParams();
P < NumParams; ++
P) {
1166 IdResolver.AddDecl(Param);
1175 assert(CurContext &&
"DeclContext imbalance!");
1176 CurContext = CurContext->getLexicalParent();
1177 assert(CurContext &&
"Popped translation unit!");
1214 CurContext->addDecl(D);
1225 if (isa<FunctionDecl>(D) &&
1226 cast<FunctionDecl>(D)->isFunctionTemplateSpecialization())
1231 IEnd = IdResolver.end();
1232 for (; I != IEnd; ++
I) {
1235 IdResolver.RemoveDecl(*I);
1244 if (isa<LabelDecl>(D) && !cast<LabelDecl>(D)->isGnuLocal()) {
1248 for (I = IdResolver.begin(D->
getDeclName()); I != IEnd; ++
I) {
1250 if (IDC == CurContext) {
1253 }
else if (IDC->
Encloses(CurContext))
1257 IdResolver.InsertDeclAfter(I, D);
1259 IdResolver.AddDecl(D);
1264 if (IdResolver.tryAddTopLevelDecl(D, Name) && TUScope)
1265 TUScope->AddDecl(D);
1269 bool AllowInlineNamespace) {
1270 return IdResolver.isDeclInScope(D, Ctx, S, AllowInlineNamespace);
1277 if (ScopeDC->getPrimaryContext() == TargetDC)
1291 bool ConsiderLinkage,
1292 bool AllowInlineNamespace) {
1297 if (isDeclInScope(D, Ctx, S, AllowInlineNamespace))
1310 return isa<UsingShadowDecl>(D) ||
1311 isa<UnresolvedUsingTypenameDecl>(D) ||
1312 isa<UnresolvedUsingValueDecl>(D);
1339 return CD->isCopyConstructor();
1340 if (
const CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(D))
1341 return Method->isCopyAssignmentOperator();
1357 bool Sema::mightHaveNonExternalLinkage(
const DeclaratorDecl *D) {
1360 if (
const RecordDecl *RD = dyn_cast<RecordDecl>(DC)){
1361 if (!RD->hasNameForLinkage())
1390 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
1394 if (
const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD)) {
1399 if (FD->isInlined() && !
isMainFileLoc(*
this, FD->getLocation()))
1403 if (FD->doesThisDeclarationHaveABody() &&
1406 }
else if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
1416 if (VD->isStaticDataMember() &&
1426 return mightHaveNonExternalLinkage(D);
1433 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
1435 if (FD != First && ShouldWarnIfUnusedFileScopedDecl(First))
1439 if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
1441 if (VD != First && ShouldWarnIfUnusedFileScopedDecl(First))
1445 if (ShouldWarnIfUnusedFileScopedDecl(D))
1446 UnusedFileScopedDecls.push_back(D);
1454 D->
hasAttr<ObjCPreciseLifetimeAttr>())
1457 if (isa<LabelDecl>(D))
1463 if (
const auto *R = dyn_cast<CXXRecordDecl>(D->
getDeclContext()))
1466 WithinFunction || (R->isLocalClass() && !R->isDependentType());
1467 if (!WithinFunction)
1470 if (isa<TypedefNameDecl>(D))
1474 if (!isa<VarDecl>(D) || isa<ParmVarDecl>(D) || isa<ImplicitParamDecl>(D))
1478 if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
1485 if (TT->getDecl()->hasAttr<UnusedAttr>())
1495 const TagDecl *Tag = TT->getDecl();
1496 if (Tag->
hasAttr<UnusedAttr>())
1499 if (
const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(Tag)) {
1500 if (!RD->hasTrivialDestructor() && !RD->hasAttr<WarnUnusedAttr>())
1503 if (
const Expr *Init = VD->getInit()) {
1505 dyn_cast<ExprWithCleanups>(Init))
1506 Init = Cleanups->getSubExpr();
1511 if (!CD->
isTrivial() && !RD->hasAttr<WarnUnusedAttr>())
1526 if (isa<LabelDecl>(D)) {
1541 for (
auto *TmpD : D->
decls()) {
1542 if (
const auto *T = dyn_cast<TypedefNameDecl>(TmpD))
1543 DiagnoseUnusedDecl(T);
1544 else if(
const auto *R = dyn_cast<RecordDecl>(TmpD))
1545 DiagnoseUnusedNestedTypedefs(R);
1555 if (
auto *TD = dyn_cast<TypedefNameDecl>(D)) {
1558 UnusedLocalTypedefNameCandidates.insert(TD);
1566 if (isa<VarDecl>(D) && cast<VarDecl>(D)->isExceptionVariable())
1567 DiagID = diag::warn_unused_exception_param;
1568 else if (isa<LabelDecl>(D))
1569 DiagID = diag::warn_unused_label;
1571 DiagID = diag::warn_unused_variable;
1581 bool Diagnose =
false;
1585 Diagnose = L->
getStmt() ==
nullptr;
1595 "Scope shouldn't contain decls!");
1597 for (
auto *TmpD : S->
decls()) {
1598 assert(TmpD &&
"This decl didn't get pushed??");
1600 assert(isa<NamedDecl>(TmpD) &&
"Decl isn't NamedDecl?");
1607 DiagnoseUnusedDecl(D);
1608 if (
const auto *RD = dyn_cast<RecordDecl>(D))
1609 DiagnoseUnusedNestedTypedefs(RD);
1613 if (
LabelDecl *LD = dyn_cast<LabelDecl>(D))
1617 IdResolver.RemoveDecl(D);
1636 bool DoTypoCorrection) {
1639 NamedDecl *IDecl = LookupSingleName(TUScope, Id, IdLoc, LookupOrdinaryName);
1641 if (!IDecl && DoTypoCorrection) {
1647 CTK_ErrorRecovery)) {
1648 diagnoseTypo(
C, PDiag(diag::err_undef_interface_suggest) << Id);
1697 if (!II->
isStr(
"objc_msgSendSuper"))
1718 return "ucontext.h";
1720 llvm_unreachable(
"unhandled error kind");
1728 Scope *
S,
bool ForRedeclaration,
1735 if (ForRedeclaration)
1736 Diag(Loc, diag::warn_implicit_decl_requires_sysheader)
1742 Diag(Loc, diag::ext_implicit_lib_function_decl)
1745 !Diags.isIgnored(diag::ext_implicit_lib_function_decl, Loc))
1746 Diag(Loc, diag::note_include_header_or_declare)
1757 Parent->
addDecl(CLinkageDecl);
1758 Parent = CLinkageDecl;
1763 Loc, Loc, II, R,
nullptr,
1773 for (
unsigned i = 0, e = FT->getNumParams(); i != e; ++i) {
1776 nullptr, FT->getParamType(i),
nullptr,
1779 Params.push_back(parm);
1781 New->setParams(Params);
1784 AddKnownFunctionAttributes(New);
1785 RegisterLocallyScopedExternCDecl(New, S);
1792 CurContext = Parent;
1793 PushOnScopeChains(New, TUScope);
1794 CurContext = SavedContext;
1810 if (Previous.
empty())
1823 if (
auto *OldTD = dyn_cast<TypedefNameDecl>(Old)) {
1831 OldTD->getAnonDeclWithTypedefName(
true) &&
1845 OldType = OldTypedef->getUnderlyingType();
1852 int Kind = isa<TypeAliasDecl>(Old) ? 1 : 0;
1853 Diag(New->
getLocation(), diag::err_redefinition_variably_modified_typedef)
1861 if (OldType != NewType &&
1865 int Kind = isa<TypeAliasDecl>(Old) ? 1 : 0;
1867 << Kind << NewType << OldType;
1889 if (getLangOpts().ObjC1) {
1895 if (!TypeID->
isStr(
"id"))
1911 if (!TypeID->
isStr(
"Class"))
1918 if (!TypeID->
isStr(
"SEL"))
1945 if (
auto *OldTD = dyn_cast<TypedefNameDecl>(Old)) {
1946 auto *OldTag = OldTD->getAnonDeclWithTypedefName(
true);
1949 if (getLangOpts().
CPlusPlus && OldTag && NewTag &&
1950 OldTag->getCanonicalDecl() != NewTag->getCanonicalDecl() &&
1951 !hasVisibleDefinition(OldTag, &Hidden)) {
1955 if (OldTD->isModed())
1957 OldTD->getUnderlyingType());
1962 makeMergedDefinitionVisible(Hidden, NewTag->
getLocation());
1966 if (isa<EnumDecl>(NewTag)) {
1967 Scope *EnumScope = getNonFieldDeclScope(S);
1968 for (
auto *D : NewTag->decls()) {
1969 auto *ED = cast<EnumConstantDecl>(D);
1972 IdResolver.RemoveDecl(ED);
1973 ED->getLexicalDeclContext()->removeDecl(ED);
1981 if (isIncompatibleTypedef(Old, New))
1988 mergeDeclAttributes(New, Old);
1991 if (getLangOpts().MicrosoftExt)
1999 if (!isa<CXXRecordDecl>(CurContext))
2023 if (!isa<TypedefNameDecl>(Old))
2033 if (getLangOpts().Modules || getLangOpts().
C11)
2040 if (getDiagnostics().getSuppressSystemWarnings() &&
2053 const OwnershipAttr *OA = dyn_cast<OwnershipAttr>(A);
2054 const AnnotateAttr *Ann = dyn_cast<AnnotateAttr>(A);
2055 for (
const auto *i : D->
attrs())
2056 if (i->getKind() == A->
getKind()) {
2058 if (Ann->getAnnotation() == cast<AnnotateAttr>(i)->getAnnotation())
2063 if (OA && isa<OwnershipAttr>(i))
2064 return OA->getOwnKind() == cast<OwnershipAttr>(i)->getOwnKind();
2072 if (
VarDecl *VD = dyn_cast<VarDecl>(D))
2073 return VD->isThisDeclarationADefinition();
2074 if (
TagDecl *TD = dyn_cast<TagDecl>(D))
2075 return TD->isCompleteDefinition() || TD->isBeingDefined();
2086 AlignedAttr *OldAlignasAttr =
nullptr;
2087 AlignedAttr *OldStrictestAlignAttr =
nullptr;
2088 unsigned OldAlign = 0;
2096 if (
I->isAlignmentDependent())
2102 unsigned Align =
I->getAlignment(S.
Context);
2103 if (Align > OldAlign) {
2105 OldStrictestAlignAttr =
I;
2110 AlignedAttr *NewAlignasAttr =
nullptr;
2111 unsigned NewAlign = 0;
2113 if (
I->isAlignmentDependent())
2119 unsigned Align =
I->getAlignment(S.
Context);
2120 if (Align > NewAlign)
2124 if (OldAlignasAttr && NewAlignasAttr && OldAlign != NewAlign) {
2132 if (OldAlign == 0 || NewAlign == 0) {
2134 if (
ValueDecl *VD = dyn_cast<ValueDecl>(New))
2145 if (OldAlign != NewAlign) {
2146 S.
Diag(NewAlignasAttr->getLocation(), diag::err_alignas_mismatch)
2149 S.
Diag(OldAlignasAttr->getLocation(), diag::note_previous_declaration);
2164 S.
Diag(OldAlignasAttr->getLocation(), diag::note_alignas_on_declaration)
2168 bool AnyAdded =
false;
2171 if (OldAlign > NewAlign) {
2172 AlignedAttr *Clone = OldStrictestAlignAttr->clone(S.
Context);
2173 Clone->setInherited(
true);
2179 if (OldAlignasAttr && !NewAlignasAttr &&
2180 !(AnyAdded && OldStrictestAlignAttr->isAlignas())) {
2181 AlignedAttr *Clone = OldAlignasAttr->clone(S.
Context);
2182 Clone->setInherited(
true);
2195 if (
const auto *AA = dyn_cast<AvailabilityAttr>(Attr))
2197 AA->getIntroduced(), AA->getDeprecated(),
2198 AA->getObsoleted(), AA->getUnavailable(),
2199 AA->getMessage(), AMK,
2200 AttrSpellingListIndex);
2201 else if (
const auto *VA = dyn_cast<VisibilityAttr>(Attr))
2203 AttrSpellingListIndex);
2204 else if (
const auto *VA = dyn_cast<TypeVisibilityAttr>(Attr))
2206 AttrSpellingListIndex);
2207 else if (
const auto *ImportA = dyn_cast<DLLImportAttr>(Attr))
2209 AttrSpellingListIndex);
2210 else if (
const auto *ExportA = dyn_cast<DLLExportAttr>(Attr))
2212 AttrSpellingListIndex);
2213 else if (
const auto *FA = dyn_cast<FormatAttr>(Attr))
2215 FA->getFormatIdx(), FA->getFirstArg(),
2216 AttrSpellingListIndex);
2217 else if (
const auto *SA = dyn_cast<SectionAttr>(Attr))
2219 AttrSpellingListIndex);
2220 else if (
const auto *IA = dyn_cast<MSInheritanceAttr>(Attr))
2222 AttrSpellingListIndex,
2223 IA->getSemanticSpelling());
2224 else if (
const auto *AA = dyn_cast<AlwaysInlineAttr>(Attr))
2227 AttrSpellingListIndex);
2228 else if (
const auto *MA = dyn_cast<MinSizeAttr>(Attr))
2230 else if (
const auto *OA = dyn_cast<OptimizeNoneAttr>(Attr))
2232 else if (
const auto *InternalLinkageA = dyn_cast<InternalLinkageAttr>(Attr))
2234 D, InternalLinkageA->getRange(),
2236 AttrSpellingListIndex);
2237 else if (
const auto *CommonA = dyn_cast<CommonAttr>(Attr))
2240 AttrSpellingListIndex);
2241 else if (isa<AlignedAttr>(Attr))
2245 else if ((isa<DeprecatedAttr>(Attr) || isa<UnavailableAttr>(Attr)) &&
2250 NewAttr = cast<InheritableAttr>(Attr->
clone(S.
Context));
2262 if (
const TagDecl *TD = dyn_cast<TagDecl>(D))
2263 return TD->getDefinition();
2264 if (
const VarDecl *VD = dyn_cast<VarDecl>(D)) {
2270 if (
const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
2272 if (FD->isDefined(Def))
2279 for (
const auto *Attribute : D->
attrs())
2280 if (Attribute->getKind() ==
Kind)
2292 if (!Def || Def == New)
2296 for (
unsigned I = 0,
E = NewAttributes.size();
I !=
E;) {
2297 const Attr *NewAttribute = NewAttributes[
I];
2299 if (isa<AliasAttr>(NewAttribute)) {
2306 NewAttributes.erase(NewAttributes.begin() +
I);
2311 VarDecl *VD = cast<VarDecl>(New);
2312 unsigned Diag = cast<VarDecl>(Def)->isThisDeclarationADefinition() ==
2314 ? diag::err_alias_after_tentative
2315 : diag::err_redefinition;
2324 if (
const VarDecl *VD = dyn_cast<VarDecl>(Def)) {
2337 if (isa<C11NoReturnAttr>(NewAttribute)) {
2341 }
else if (
const AlignedAttr *AA = dyn_cast<AlignedAttr>(NewAttribute)) {
2342 if (AA->isAlignas()) {
2353 S.
Diag(NewAttribute->
getLocation(), diag::note_alignas_on_declaration)
2355 NewAttributes.erase(NewAttributes.begin() +
I);
2362 diag::warn_attribute_precede_definition);
2364 NewAttributes.erase(NewAttributes.begin() +
I);
2373 UsedAttr *NewAttr = OldAttr->clone(
Context);
2374 NewAttr->setInherited(
true);
2384 if (AsmLabelAttr *NewA = New->
getAttr<AsmLabelAttr>()) {
2385 if (AsmLabelAttr *OldA = Old->
getAttr<AsmLabelAttr>()) {
2386 if (OldA->getLabel() != NewA->getLabel()) {
2389 Diag(OldA->getLocation(), diag::note_previous_declaration);
2391 }
else if (Old->
isUsed()) {
2395 << isa<FunctionDecl>(Old) << New->
getAttr<AsmLabelAttr>()->getRange();
2411 if (isa<DeprecatedAttr>(
I) ||
2412 isa<UnavailableAttr>(
I) ||
2413 isa<AvailabilityAttr>(
I)) {
2418 case AMK_Redeclaration:
2420 case AMK_ProtocolImplementation:
2427 if (isa<UsedAttr>(
I))
2449 const CarriesDependencyAttr *CDA = newDecl->
getAttr<CarriesDependencyAttr>();
2450 if (CDA && !oldDecl->
hasAttr<CarriesDependencyAttr>()) {
2451 S.
Diag(CDA->getLocation(),
2452 diag::err_carries_dependency_missing_on_first_decl) << 1;
2460 diag::note_carries_dependency_missing_first_decl) << 1;
2466 bool foundAny = newDecl->
hasAttrs();
2475 cast<InheritableParamAttr>(
I->clone(S.
Context));
2490 if (*Oldnullability != *Newnullability) {
2491 S.
Diag(NewParam->
getLocation(), diag::warn_mismatched_nullability_attr)
2516 struct GNUCompatibleParamWarning {
2527 if (Ctor->isDefaultConstructor())
2530 if (Ctor->isCopyConstructor())
2533 if (Ctor->isMoveConstructor())
2535 }
else if (isa<CXXDestructorDecl>(MD)) {
2548 template <
typename T>
2549 static std::pair<diag::kind, SourceLocation>
2553 if (Old->isThisDeclarationADefinition())
2554 PrevDiag = diag::note_previous_definition;
2555 else if (Old->isImplicit()) {
2556 PrevDiag = diag::note_previous_implicit_declaration;
2558 OldLocation = New->getLocation();
2560 PrevDiag = diag::note_previous_declaration;
2561 return std::make_pair(PrevDiag, OldLocation);
2569 return ((FD->
hasAttr<GNUInlineAttr>() || LangOpts.GNUInline) &&
2570 !LangOpts.CPlusPlus &&
2582 template <
typename T>
2596 template<
typename T>
static bool isExternC(T *D) {
return D->isExternC(); }
2602 template<
typename ExpectedDecl>
2604 ExpectedDecl *New) {
2624 !Old->getDeclContext()->getRedeclContext()->Equals(
2625 New->getDeclContext()->getRedeclContext()) &&
2630 S.
Diag(New->getLocation(), diag::err_using_decl_conflict_reverse);
2643 const auto *AttrA = A->
getAttr<PassObjectSizeAttr>();
2644 const auto *AttrB = B->
getAttr<PassObjectSizeAttr>();
2647 return AttrA && AttrB && AttrA->getType() == AttrB->getType();
2650 return std::equal(A->param_begin(), A->param_end(), B->
param_begin(), AttrEq);
2665 Scope *
S,
bool MergeTypeWithOld) {
2672 Diag(Shadow->getTargetDecl()->getLocation(),
2673 diag::note_using_decl_target);
2674 Diag(Shadow->getUsingDecl()->getLocation(),
2675 diag::note_using_decl) << 0;
2680 if (checkUsingShadowRedecl<FunctionDecl>(*
this, Shadow, New))
2682 OldD = Old = cast<FunctionDecl>(Shadow->getTargetDecl());
2697 std::tie(PrevDiag, OldLocation) =
2704 if (!isa<CXXMethodDecl>(New) && !isa<CXXMethodDecl>(Old) &&
2709 if (getLangOpts().MicrosoftExt) {
2711 Diag(OldLocation, PrevDiag);
2714 Diag(OldLocation, PrevDiag);
2719 if (New->
hasAttr<InternalLinkageAttr>() &&
2720 !Old->
hasAttr<InternalLinkageAttr>()) {
2724 New->
dropAttr<InternalLinkageAttr>();
2742 const FunctionType *OldType = cast<FunctionType>(OldQType);
2743 const FunctionType *NewType = cast<FunctionType>(NewQType);
2746 bool RequiresAdjustment =
false;
2748 if (OldTypeInfo.getCC() != NewTypeInfo.
getCC()) {
2753 bool NewCCExplicit = getCallingConvAttributedType(New->
getType());
2754 if (!NewCCExplicit) {
2758 RequiresAdjustment =
true;
2761 bool FirstCCExplicit = getCallingConvAttributedType(First->
getType());
2765 << (!FirstCCExplicit ?
"" :
2775 if (OldTypeInfo.getNoReturn() && !NewTypeInfo.
getNoReturn()) {
2777 RequiresAdjustment =
true;
2781 if (OldTypeInfo.getHasRegParm() != NewTypeInfo.
getHasRegParm() ||
2782 OldTypeInfo.getRegParm() != NewTypeInfo.
getRegParm()) {
2785 << NewType->getRegParmType()
2787 Diag(OldLocation, diag::note_previous_declaration);
2791 NewTypeInfo = NewTypeInfo.
withRegParm(OldTypeInfo.getRegParm());
2792 RequiresAdjustment =
true;
2799 Diag(OldLocation, diag::note_previous_declaration);
2804 RequiresAdjustment =
true;
2807 if (RequiresAdjustment) {
2812 NewType = cast<FunctionType>(NewQType);
2818 !New->
hasAttr<GNUInlineAttr>() &&
2819 !getLangOpts().GNUInline &&
2827 if (New->
hasAttr<GNUInlineAttr>() &&
2838 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
2856 : OldType)->getReturnType();
2860 : NewType)->getReturnType();
2870 Diag(New->
getLocation(), diag::err_member_def_does_not_match_ret_type)
2875 Diag(OldLocation, PrevDiag) << Old << Old->
getType()
2884 QualType NewReturnType = cast<FunctionType>(NewQType)->getReturnType();
2885 if (OldReturnType != NewReturnType) {
2895 SubstAutoType(NewQType,
2903 if (OldMethod && NewMethod) {
2910 bool IsClassScopeExplicitSpecialization =
2912 NewMethod->isFunctionTemplateSpecialization();
2913 bool isFriend = NewMethod->getFriendObjectKind();
2915 if (!isFriend && NewMethod->getLexicalDeclContext()->isRecord() &&
2916 !IsClassScopeExplicitSpecialization) {
2920 if (OldMethod->
isStatic() != NewMethod->isStatic()) {
2922 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
2930 if (ActiveTemplateInstantiations.empty()) {
2932 if (isa<CXXConstructorDecl>(OldMethod))
2933 NewDiag = diag::err_constructor_redeclared;
2934 else if (isa<CXXDestructorDecl>(NewMethod))
2935 NewDiag = diag::err_destructor_redeclared;
2936 else if (isa<CXXConversionDecl>(NewMethod))
2937 NewDiag = diag::err_conv_function_redeclared;
2939 NewDiag = diag::err_member_redeclared;
2943 Diag(New->
getLocation(), diag::err_member_redeclared_in_instantiation)
2946 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
2956 NewMethod->setImplicit();
2958 Diag(NewMethod->getLocation(),
2959 diag::err_definition_of_implicitly_declared_member)
2960 << New << getSpecialMember(OldMethod);
2964 Diag(NewMethod->getLocation(),
2965 diag::err_definition_of_explicitly_defaulted_member)
2966 << getSpecialMember(OldMethod);
2975 const CXX11NoReturnAttr *NRA = New->
getAttr<CXX11NoReturnAttr>();
2976 if (NRA && !Old->
hasAttr<CXX11NoReturnAttr>()) {
2977 Diag(NRA->getLocation(), diag::err_noreturn_missing_on_first_decl);
2979 diag::note_noreturn_missing_first_decl);
2986 const CarriesDependencyAttr *CDA = New->
getAttr<CarriesDependencyAttr>();
2987 if (CDA && !Old->
hasAttr<CarriesDependencyAttr>()) {
2988 Diag(CDA->getLocation(),
2989 diag::err_carries_dependency_missing_on_first_decl) << 0;
2991 diag::note_carries_dependency_missing_first_decl) << 0;
3000 QualType OldQTypeForComparison = OldQType;
3001 if (!OldTypeInfo.getNoReturn() && NewTypeInfo.
getNoReturn()) {
3002 assert(OldQType ==
QualType(OldType, 0));
3005 OldQTypeForComparison =
QualType(OldTypeForComparison, 0);
3020 Diag(OldLocation, PrevDiag);
3022 Diag(New->
getLocation(), diag::err_different_language_linkage) << New;
3023 Diag(OldLocation, PrevDiag);
3028 if (OldQTypeForComparison == NewQType)
3029 return MergeCompatibleFunctionDecls(New, Old, S, MergeTypeWithOld);
3044 if (!getLangOpts().CPlusPlus &&
3049 if (MergeTypeWithOld && isa<FunctionNoProtoType>(NewFuncType) &&
3053 assert(!OldProto->hasExceptionSpec() &&
"Exception spec in C");
3057 OldProto->getExtProtoInfo());
3063 for (
const auto &ParamType : OldProto->param_types()) {
3070 Params.push_back(Param);
3073 New->setParams(Params);
3076 return MergeCompatibleFunctionDecls(New, Old, S, MergeTypeWithOld);
3103 NewProto->getReturnType());
3104 bool LooseCompatible = !MergedReturn.
isNull();
3106 LooseCompatible && Idx !=
End; ++Idx) {
3110 NewProto->getParamType(Idx))) {
3111 ArgTypes.push_back(NewParm->
getType());
3115 GNUCompatibleParamWarning Warn = { OldParm, NewParm,
3116 NewProto->getParamType(Idx) };
3117 Warnings.push_back(Warn);
3118 ArgTypes.push_back(NewParm->
getType());
3120 LooseCompatible =
false;
3123 if (LooseCompatible) {
3124 for (
unsigned Warn = 0; Warn < Warnings.size(); ++Warn) {
3125 Diag(Warnings[Warn].NewParm->getLocation(),
3126 diag::ext_param_promoted_not_compatible_with_prototype)
3127 << Warnings[Warn].PromotedType
3128 << Warnings[Warn].OldParm->getType();
3129 if (Warnings[Warn].OldParm->getLocation().isValid())
3130 Diag(Warnings[Warn].OldParm->getLocation(),
3131 diag::note_previous_declaration);
3134 if (MergeTypeWithOld)
3137 return MergeCompatibleFunctionDecls(New, Old, S, MergeTypeWithOld);
3154 Diag(OldLocation, diag::note_previous_builtin_declaration)
3171 PrevDiag = diag::note_previous_builtin_declaration;
3175 Diag(OldLocation, PrevDiag) << Old << Old->
getType();
3189 Scope *
S,
bool MergeTypeWithOld) {
3191 mergeDeclAttributes(New, Old);
3204 for (
unsigned i = 0, e = New->
getNumParams(); i != e; ++i) {
3212 return MergeCXXFunctionDecl(New, Old, S);
3218 if (!Merged.
isNull() && MergeTypeWithOld)
3231 ? AMK_ProtocolImplementation
3232 : isa<ObjCImplDecl>(newMethod->
getDeclContext()) ? AMK_Redeclaration
3235 mergeDeclAttributes(newMethod, oldMethod, MergeKind);
3242 ni != ne && oi != oe; ++ni, ++oi)
3245 CheckObjCMethodOverride(newMethod, oldMethod);
3256 bool MergeTypeWithOld) {
3261 if (getLangOpts().CPlusPlus) {
3267 return MergeVarDeclExceptionSpecs(New, Old);
3325 ? diag::err_redefinition_different_type
3326 : diag::err_redeclaration_different_type)
3331 std::tie(PrevDiag, OldLocation) =
3333 Diag(OldLocation, PrevDiag);
3339 if (MergeTypeWithOld)
3385 if (!shouldLinkPossiblyHiddenDecl(Previous, New))
3400 if (checkUsingShadowRedecl<VarTemplateDecl>(*
this, Shadow, NewTemplate))
3407 if (checkUsingShadowRedecl<VarDecl>(*
this, Shadow, New))
3415 diag::note_previous_definition);
3423 true, TPL_TemplateMatch))
3437 mergeDeclAttributes(New, Old);
3440 if (New->
hasAttr<WeakImportAttr>() &&
3442 !Old->
hasAttr<WeakImportAttr>()) {
3449 if (New->
hasAttr<InternalLinkageAttr>() &&
3450 !Old->
hasAttr<InternalLinkageAttr>()) {
3454 New->
dropAttr<InternalLinkageAttr>();
3459 if (MostRecent != Old) {
3460 MergeVarDeclTypes(New, MostRecent,
3472 std::tie(PrevDiag, OldLocation) =
3479 if (getLangOpts().MicrosoftExt) {
3482 Diag(OldLocation, PrevDiag);
3486 Diag(OldLocation, PrevDiag);
3505 Diag(OldLocation, PrevDiag);
3513 Diag(OldLocation, PrevDiag);
3519 Diag(OldLocation, PrevDiag);
3532 Diag(OldLocation, PrevDiag);
3539 Diag(OldLocation, PrevDiag);
3542 Diag(OldLocation, PrevDiag);
3550 Diag(OldLocation, PrevDiag);
3560 if (!hasVisibleDefinition(Def, &Hidden) &&
3569 Diag(Def->getLocation(), diag::note_previous_definition);
3576 Diag(New->
getLocation(), diag::err_different_language_linkage) << New;
3577 Diag(OldLocation, PrevDiag);
3620 if (isa<CXXRecordDecl>(Tag->
getParent())) {
3634 Decl *ManglingContextDecl;
3638 Tag, MCtx->getManglingNumber(
3658 if (getLangOpts().CPlusPlus)
3673 tagLoc = getLocForEndOfToken(tagLoc);
3676 textToInsert +=
' ';
3678 Diag(tagLoc, diag::note_typedef_changes_linkage)
3700 llvm_unreachable(
"unexpected type specifier");
3710 bool IsExplicitInstantiation) {
3711 Decl *TagD =
nullptr;
3726 if (isa<TagDecl>(TagD))
3727 Tag = cast<TagDecl>(TagD);
3729 Tag = CTD->getTemplatedDecl();
3733 handleTagNumbering(Tag, S);
3744 diag::err_typecheck_invalid_restrict_not_pointer_noarg)
3768 DiagnoseFunctionSpecifiers(DS);
3775 return ActOnFriendTypeDecl(S, DS, TemplateParams);
3779 bool IsExplicitSpecialization =
3780 !TemplateParams.empty() && TemplateParams.back()->size() == 0;
3782 !IsExplicitInstantiation && !IsExplicitSpecialization &&
3783 !isa<ClassTemplatePartialSpecializationDecl>(Tag)) {
3792 Diag(SS.
getBeginLoc(), diag::err_standalone_class_nested_name_specifier)
3798 bool DeclaresAnything =
true;
3801 if (
RecordDecl *Record = dyn_cast_or_null<RecordDecl>(Tag)) {
3802 if (!Record->getDeclName() && Record->isCompleteDefinition() &&
3804 if (getLangOpts().CPlusPlus ||
3805 Record->getDeclContext()->isRecord())
3806 return BuildAnonymousStructOrUnion(S, DS, AS, Record,
3809 DeclaresAnything =
false;
3819 if (!getLangOpts().CPlusPlus && CurContext->isRecord() &&
3835 Record = RT->getDecl();
3837 Record = UT->getDecl();
3839 if (Record && getLangOpts().MicrosoftExt) {
3842 return BuildMicrosoftCAnonymousStruct(S, DS, Record);
3845 DeclaresAnything =
false;
3854 if (getLangOpts().CPlusPlus &&
3856 if (
EnumDecl *Enum = dyn_cast_or_null<EnumDecl>(Tag))
3857 if (Enum->enumerator_begin() == Enum->enumerator_end() &&
3858 !Enum->getIdentifier() && !Enum->isInvalidDecl())
3859 DeclaresAnything =
false;
3867 DeclaresAnything =
false;
3876 ActOnDocumentableDecl(TagD);
3886 if (!DeclaresAnything) {
3901 unsigned DiagID = diag::warn_standalone_specifier;
3903 DiagID = diag::ext_standalone_specifier;
3943 Diag(attrs->getLoc(), diag::warn_declspec_attribute_ignored)
3967 assert(PrevDecl &&
"Expected a non-null Decl");
3972 SemaRef.
Diag(NameLoc, diag::err_anonymous_record_member_redecl)
3974 SemaRef.
Diag(PrevDecl->
getLocation(), diag::note_previous_declaration);
4000 bool MSAnonStruct) {
4001 bool Invalid =
false;
4004 for (
auto *D : AnonRecord->
decls()) {
4005 if ((isa<FieldDecl>(D) || isa<IndirectFieldDecl>(D)) &&
4006 cast<NamedDecl>(D)->getDeclName()) {
4022 unsigned OldChainingSize = Chaining.size();
4024 Chaining.append(IF->chain_begin(), IF->chain_end());
4026 Chaining.push_back(VD);
4028 assert(Chaining.size() >= 2);
4031 for (
unsigned i = 0; i < Chaining.size(); i++)
4032 NamedChain[i] = Chaining[i];
4036 VD->
getType(), NamedChain, Chaining.size());
4048 Chaining.resize(OldChainingSize);
4063 "Parser allowed 'typedef' as storage class VarDecl.");
4064 switch (StorageClassSpec) {
4078 llvm_unreachable(
"unknown storage class specifier");
4084 for (
const auto *
I : Record->
decls()) {
4086 if (
const auto *IFD = dyn_cast<IndirectFieldDecl>(
I))
4087 FD = IFD->getAnonField();
4088 if (FD && FD->hasInClassInitializer())
4092 llvm_unreachable(
"couldn't find in-class initializer");
4100 S.
Diag(DefaultInitLoc, diag::err_multiple_mem_union_initialization);
4123 if (Record->
isUnion() && !getLangOpts().CPlusPlus && !getLangOpts().C11)
4125 else if (!Record->
isUnion() && getLangOpts().CPlusPlus)
4127 else if (!Record->
isUnion() && !getLangOpts().C11)
4132 bool Invalid =
false;
4133 if (getLangOpts().CPlusPlus) {
4134 const char *PrevSpec =
nullptr;
4141 (isa<TranslationUnitDecl>(Owner) ||
4142 (isa<NamespaceDecl>(Owner) &&
4143 cast<NamespaceDecl>(Owner)->getDeclName()))) {
4149 PrevSpec, DiagID, Policy);
4155 isa<RecordDecl>(Owner)) {
4157 diag::err_anonymous_union_with_storage_spec)
4171 << Record->
isUnion() <<
"const"
4175 diag::ext_anonymous_struct_union_qualified)
4176 << Record->
isUnion() <<
"volatile"
4180 diag::ext_anonymous_struct_union_qualified)
4181 << Record->
isUnion() <<
"restrict"
4185 diag::ext_anonymous_struct_union_qualified)
4186 << Record->
isUnion() <<
"_Atomic"
4196 for (
auto *Mem : Record->
decls()) {
4197 if (
auto *FD = dyn_cast<FieldDecl>(Mem)) {
4201 assert(FD->getAccess() !=
AS_none);
4203 Diag(FD->getLocation(), diag::err_anonymous_record_nonpublic_member)
4213 if (CheckNontrivialField(FD))
4215 }
else if (Mem->isImplicit()) {
4217 }
else if (isa<TagDecl>(Mem) && Mem->getDeclContext() != Record) {
4222 }
else if (
auto *MemRecord = dyn_cast<RecordDecl>(Mem)) {
4223 if (!MemRecord->isAnonymousStructOrUnion() &&
4224 MemRecord->getDeclName()) {
4226 if (getLangOpts().MicrosoftExt)
4227 Diag(MemRecord->getLocation(), diag::ext_anonymous_record_with_type)
4231 Diag(MemRecord->getLocation(), diag::err_anonymous_record_with_type)
4239 Diag(MemRecord->getLocation(),
4240 diag::ext_anonymous_record_with_anonymous_type)
4243 }
else if (isa<AccessSpecDecl>(Mem)) {
4245 }
else if (isa<StaticAssertDecl>(Mem)) {
4250 unsigned DK = diag::err_anonymous_record_bad_member;
4251 if (isa<TypeDecl>(Mem))
4252 DK = diag::err_anonymous_record_with_type;
4253 else if (isa<FunctionDecl>(Mem))
4254 DK = diag::err_anonymous_record_with_function;
4255 else if (isa<VarDecl>(Mem))
4256 DK = diag::err_anonymous_record_with_static;
4259 if (getLangOpts().MicrosoftExt &&
4260 DK == diag::err_anonymous_record_with_type)
4261 Diag(Mem->getLocation(), diag::ext_anonymous_record_with_type)
4264 Diag(Mem->getLocation(), DK) << Record->
isUnion();
4273 if (cast<CXXRecordDecl>(Record)->hasInClassInitializer() &&
4276 cast<CXXRecordDecl>(Record));
4281 << getLangOpts().CPlusPlus;
4288 assert(TInfo &&
"couldn't build declarator info for anonymous struct/union");
4292 if (
RecordDecl *OwningClass = dyn_cast<RecordDecl>(Owner)) {
4303 FieldCollector->Add(cast<FieldDecl>(Anon));
4325 ActOnUninitializedDecl(Anon,
false);
4341 Chain.push_back(Anon);
4347 if (
VarDecl *NewVD = dyn_cast<VarDecl>(Anon)) {
4348 if (getLangOpts().
CPlusPlus && NewVD->isStaticLocal()) {
4349 Decl *ManglingContextDecl;
4351 NewVD->getDeclContext(), ManglingContextDecl)) {
4353 NewVD, MCtx->getManglingNumber(
4381 assert(Record &&
"expected a record!");
4386 assert(TInfo &&
"couldn't build declarator info for anonymous struct");
4388 auto *ParentDecl = cast<RecordDecl>(CurContext);
4404 CurContext->addDecl(Anon);
4410 Chain.push_back(Anon);
4413 if (RequireCompleteType(Anon->
getLocation(), RecTy,
4414 diag::err_field_incomplete) ||
4418 ParentDecl->setInvalidDecl();
4427 return GetNameFromUnqualifiedId(D.
getName());
4528 llvm_unreachable(
"Unknown name kind");
4556 for (
unsigned Idx = 0; Idx < Declaration->
param_size(); ++Idx) {
4570 (DeclTyName && DeclTyName == DefTyName))
4571 Params.push_back(Idx);
4612 if (!TSI)
return true;
4657 if (OriginalLexicalContext && OriginalLexicalContext->isObjCContainer() &&
4677 Record = dyn_cast<CXXRecordDecl>(Record->
getParent());
4679 Diag(NameInfo.
getLoc(), diag::err_member_name_of_class) << Name;
4703 while (isa<LinkageSpecDecl>(Cur) || isa<CapturedDecl>(Cur))
4717 Diag(Loc, LangOpts.MicrosoftExt ? diag::warn_member_extra_qualification
4718 : diag::err_member_extra_qualification)
4722 Diag(Loc, diag::warn_namespace_member_extra_qualification) <<
Name;
4731 Diag(Loc, diag::err_member_qualification)
4733 else if (isa<TranslationUnitDecl>(DC))
4734 Diag(Loc, diag::err_invalid_declarator_global_scope)
4736 else if (isa<FunctionDecl>(Cur))
4737 Diag(Loc, diag::err_invalid_declarator_in_function)
4739 else if (isa<BlockDecl>(Cur))
4740 Diag(Loc, diag::err_invalid_declarator_in_block)
4743 Diag(Loc, diag::err_invalid_declarator_scope)
4744 << Name << cast<NamedDecl>(Cur) << cast<NamedDecl>(DC) << SS.
getRange();
4751 Diag(Loc, diag::err_member_qualification)
4771 while (SpecLoc.getPrefix())
4773 if (dyn_cast_or_null<DecltypeType>(
4774 SpecLoc.getNestedNameSpecifier()->getAsType()))
4775 Diag(Loc, diag::err_decltype_in_declarator)
4776 << SpecLoc.getTypeLoc().getSourceRange();
4792 diag::err_declarator_need_ident)
4795 }
else if (DiagnoseUnexpandedParameterPack(NameInfo, UPPC_DeclarationType))
4809 UPPC_DeclarationQualifier))
4814 if (!DC || isa<EnumDecl>(DC)) {
4820 diag::err_template_qualified_declarator_no_match)
4827 if (!IsDependentContext &&
4832 if (isa<CXXRecordDecl>(DC) && !cast<CXXRecordDecl>(DC)->
hasDefinition()) {
4834 diag::err_member_def_undefined_record)
4850 if (EnteringContext && IsDependentContext &&
4851 TemplateParamLists.size() != 0) {
4861 if (!R->
isFunctionType() && DiagnoseClassNameShadow(DC, NameInfo))
4869 UPPC_DeclarationType))
4877 bool IsLinkageLookup =
false;
4878 bool CreateBuiltins =
false;
4889 else if (CurContext->isFunctionOrMethod() &&
4892 IsLinkageLookup =
true;
4894 CurContext->getEnclosingNamespaceContext()->isTranslationUnit();
4895 }
else if (CurContext->getRedeclContext()->isTranslationUnit() &&
4897 CreateBuiltins =
true;
4899 if (IsLinkageLookup)
4900 Previous.
clear(LookupRedeclarationWithLinkage);
4902 LookupName(Previous, S, CreateBuiltins);
4904 LookupQualifiedName(Previous, DC);
4957 CheckExtraCXXDefaultArguments(D);
4963 if (!TemplateParamLists.size()) {
4965 diag:: err_concept_wrong_decl_kind);
4971 diag::err_concept_decls_may_only_appear_in_namespace_scope);
4978 bool AddToScope =
true;
4980 if (TemplateParamLists.size()) {
4985 New = ActOnTypedefDeclarator(S, D, DC, TInfo, Previous);
4987 New = ActOnFunctionDeclarator(S, D, DC, TInfo, Previous,
4991 New = ActOnVariableDeclarator(S, D, DC, TInfo, Previous, TemplateParamLists,
5006 PushOnScopeChains(New, S, AddToContext);
5008 CurContext->addHiddenDecl(New);
5019 bool &SizeIsNegative,
5020 llvm::APSInt &Oversized) {
5025 SizeIsNegative =
false;
5034 if (
const PointerType* PTy = dyn_cast<PointerType>(Ty)) {
5039 if (FixedType.
isNull())
return FixedType;
5041 return Qs.
apply(Context, FixedType);
5043 if (
const ParenType* PTy = dyn_cast<ParenType>(Ty)) {
5044 QualType Inner = PTy->getInnerType();
5048 if (FixedType.
isNull())
return FixedType;
5050 return Qs.
apply(Context, FixedType);
5066 if (Res.isSigned() && Res.isNegative()) {
5067 SizeIsNegative =
true;
5072 unsigned ActiveSizeBits
5106 TypeLoc DstElemTL = DstATL.getElementLoc();
5119 bool &SizeIsNegative,
5120 llvm::APSInt &Oversized) {
5123 SizeIsNegative, Oversized);
5160 diag::err_inline_non_function);
5164 diag::err_virtual_non_function);
5168 diag::err_explicit_non_function);
5172 diag::err_noreturn_non_function);
5195 diag::err_concept_wrong_decl_kind);
5204 if (!NewTD)
return nullptr;
5207 ProcessDeclAttributes(S, NewTD, D);
5209 CheckTypedefForVariablyModifiedType(S, NewTD);
5212 NamedDecl *ND = ActOnTypedefNameDecl(S, DC, NewTD, Previous, Redeclaration);
5226 getCurFunction()->setHasBranchProtectedScope();
5229 bool SizeIsNegative;
5230 llvm::APSInt Oversized;
5243 else if (Oversized.getBoolValue())
5245 << Oversized.toString(10);
5263 FilterLookupForScope(Previous, DC, S,
false,
5266 if (!Previous.
empty()) {
5267 Redeclaration =
true;
5268 MergeTypedefNameDecl(S, NewTD, Previous);
5275 if (II->isStr(
"FILE"))
5277 else if (II->isStr(
"jmp_buf"))
5279 else if (II->isStr(
"sigjmp_buf"))
5281 else if (II->isStr(
"ucontext_t"))
5339 if (!OuterContext->
Equals(PrevOuterContext))
5348 if (!SS.
isSet())
return;
5357 unsigned kind = -1U;
5358 if (
VarDecl *var = dyn_cast<VarDecl>(decl)) {
5359 if (var->hasAttr<BlocksAttr>())
5361 else if (!var->hasLocalStorage())
5363 }
else if (isa<ObjCIvarDecl>(decl)) {
5365 }
else if (isa<FieldDecl>(decl)) {
5383 if (
VarDecl *var = dyn_cast<VarDecl>(decl)) {
5386 var->getTLSKind()) {
5387 Diag(var->getLocation(), diag::err_arc_thread_ownership)
5408 if (WeakRefAttr *
Attr = ND.
getAttr<WeakRefAttr>()) {
5416 if (
auto *VD = dyn_cast<VarDecl>(&ND)) {
5417 if (VD->hasInit()) {
5418 if (
const auto *
Attr = VD->getAttr<AliasAttr>()) {
5419 assert(VD->isThisDeclarationADefinition() &&
5420 !VD->isExternallyVisible() &&
"Broken AliasAttr handled late!");
5422 VD->dropAttr<AliasAttr>();
5429 if (SelectAnyAttr *
Attr = ND.
getAttr<SelectAnyAttr>()) {
5432 diag::err_attribute_selectany_non_extern_data);
5440 auto *VD = dyn_cast<
VarDecl>(&ND);
5450 if (
auto *MD = dyn_cast<CXXMethodDecl>(&ND))
5451 if (MD->isVirtual()) {
5453 diag::err_invalid_attribute_on_virtual_function)
5461 bool IsSpecialization) {
5462 if (
TemplateDecl *OldTD = dyn_cast<TemplateDecl>(OldDecl))
5463 OldDecl = OldTD->getTemplatedDecl();
5464 if (
TemplateDecl *NewTD = dyn_cast<TemplateDecl>(NewDecl))
5465 NewDecl = NewTD->getTemplatedDecl();
5467 if (!OldDecl || !NewDecl)
5470 const DLLImportAttr *OldImportAttr = OldDecl->
getAttr<DLLImportAttr>();
5471 const DLLExportAttr *OldExportAttr = OldDecl->
getAttr<DLLExportAttr>();
5472 const DLLImportAttr *NewImportAttr = NewDecl->
getAttr<DLLImportAttr>();
5473 const DLLExportAttr *NewExportAttr = NewDecl->
getAttr<DLLExportAttr>();
5477 bool HasNewAttr = (NewImportAttr && !NewImportAttr->isInherited()) ||
5478 (NewExportAttr && !NewExportAttr->isInherited());
5484 bool AddsAttr = !(OldImportAttr || OldExportAttr) && HasNewAttr;
5486 if (AddsAttr && !IsSpecialization && !OldDecl->
isImplicit()) {
5488 bool JustWarn =
false;
5490 auto *VD = dyn_cast<
VarDecl>(OldDecl);
5491 if (VD && !VD->getDescribedVarTemplate())
5502 if (!isa<FunctionDecl>(OldDecl) || !NewImportAttr)
5505 unsigned DiagID = JustWarn ? diag::warn_attribute_dll_redeclaration
5506 : diag::err_attribute_dll_redeclaration;
5509 << (NewImportAttr ? (
const Attr *)NewImportAttr : NewExportAttr);
5521 bool IsInline =
false, IsStaticDataMember =
false, IsQualifiedFriend =
false;
5522 if (
const auto *VD = dyn_cast<VarDecl>(NewDecl))
5525 IsStaticDataMember = VD->isStaticDataMember();
5526 else if (
const auto *FD = dyn_cast<FunctionDecl>(NewDecl)) {
5527 IsInline = FD->isInlined();
5528 IsQualifiedFriend = FD->getQualifier() &&
5532 if (OldImportAttr && !HasNewAttr && !IsInline && !IsStaticDataMember &&
5535 diag::warn_redeclaration_without_attribute_prev_attribute_ignored)
5536 << NewDecl << OldImportAttr;
5538 S.
Diag(OldImportAttr->getLocation(), diag::note_previous_attribute);
5539 OldDecl->
dropAttr<DLLImportAttr>();
5540 NewDecl->
dropAttr<DLLImportAttr>();
5541 }
else if (IsInline && OldImportAttr &&
5544 OldDecl->
dropAttr<DLLImportAttr>();
5545 NewDecl->
dropAttr<DLLImportAttr>();
5547 diag::warn_dllimport_dropped_from_inline_function)
5548 << NewDecl << OldImportAttr;
5601 template<
typename T>
5605 if (!D->isInExternCContext() || D->template hasAttr<OverloadableAttr>())
5610 (D->template hasAttr<CUDADeviceAttr>() ||
5611 D->template hasAttr<CUDAHostAttr>()))
5614 return D->isExternC();
5625 llvm_unreachable(
"Unexpected context");
5634 llvm_unreachable(
"Unexpected context");
5640 if (L->getKind() ==
Kind)
5688 if (
const auto *FD = dyn_cast<FunctionDecl>(D))
5689 return FD->isExternC();
5690 if (
const auto *VD = dyn_cast<VarDecl>(D))
5691 return VD->isExternC();
5693 llvm_unreachable(
"Unknown type of decl!");
5715 bool IsLocalExternDecl = SC ==
SC_Extern &&
5716 adjustContextForLocalExternDecl(DC);
5718 if (getLangOpts().OpenCL) {
5730 if (!getOpenCLOptions().cl_khr_fp16) {
5749 !D.
getAsmLabel() && !getSourceManager().isInSystemMacro(
5755 getLangOpts().CPlusPlus1z ? diag::ext_register_storage_class
5756 : diag::warn_deprecated_register)
5779 if (getLangOpts().OpenCL) {
5805 bool IsExplicitSpecialization =
false;
5806 bool IsVariableTemplateSpecialization =
false;
5807 bool IsPartialSpecialization =
false;
5808 bool IsVariableTemplate =
false;
5818 ParsingInitForAutoVars.insert(NewVD);
5823 bool Invalid =
false;
5825 if (DC->
isRecord() && !CurContext->isRecord()) {
5832 diag::err_static_out_of_line)
5844 diag::err_storage_class_for_static_member)
5848 llvm_unreachable(
"C storage class in c++!");
5852 if (SC ==
SC_Static && CurContext->isRecord()) {
5853 if (
const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(DC)) {
5854 if (RD->isLocalClass())
5856 diag::err_static_data_member_not_allowed_in_local_class)
5857 << Name << RD->getDeclName();
5863 getLangOpts().CPlusPlus11
5864 ? diag::warn_cxx98_compat_static_data_member_in_union
5865 : diag::ext_static_data_member_in_union) << Name;
5867 else if (!RD->getDeclName())
5869 diag::err_static_data_member_not_allowed_in_anon_struct)
5870 << Name << RD->isUnion();
5876 TemplateParams = MatchTemplateParametersToScopeSpecifier(
5883 false, IsExplicitSpecialization, Invalid);
5885 if (TemplateParams) {
5886 if (!TemplateParams->
size() &&
5891 diag::err_template_variable_noparams)
5895 TemplateParams =
nullptr;
5900 IsVariableTemplateSpecialization =
true;
5901 IsPartialSpecialization = TemplateParams->
size() > 0;
5904 IsVariableTemplate =
true;
5907 if (CheckTemplateDeclScope(S, TemplateParams))
5912 getLangOpts().CPlusPlus14
5913 ? diag::warn_cxx11_compat_variable_template
5914 : diag::ext_variable_template);
5920 "should have a 'template<>' for this decl");
5923 if (IsVariableTemplateSpecialization) {
5925 TemplateParamLists.size() > 0
5926 ? TemplateParamLists[0]->getTemplateLoc()
5928 DeclResult Res = ActOnVarTemplateSpecialization(
5929 S, D, TInfo, TemplateKWLoc, TemplateParams, SC,
5930 IsPartialSpecialization);
5933 NewVD = cast<VarDecl>(Res.
get());
5940 if (IsVariableTemplate) {
5943 TemplateParams, NewVD);
5950 ParsingInitForAutoVars.insert(NewVD);
5962 unsigned VDTemplateParamLists = TemplateParams ? 1 : 0;
5963 if (TemplateParamLists.size() > VDTemplateParamLists)
5965 Context, TemplateParamLists.drop_back(VDTemplateParamLists));
5978 diag::err_concept_decl_invalid_specifiers)
5985 diag::err_concept_decl_invalid_specifiers)
5998 if (IsLocalExternDecl)
6001 bool EmitTLSUnsupportedError =
false;
6014 diag::err_thread_non_global)
6017 if (getLangOpts().CUDA) {
6021 EmitTLSUnsupportedError =
true;
6028 diag::err_thread_unsupported);
6047 diag::warn_static_local_in_extern_inline);
6048 MaybeSuggestAddingStaticToDecl(CurFD);
6053 if (IsVariableTemplateSpecialization)
6055 << (IsPartialSpecialization ? 1 : 0)
6058 else if (IsExplicitSpecialization)
6075 ProcessDeclAttributes(S, NewVD, D);
6077 if (getLangOpts().CUDA) {
6080 diag::err_thread_unsupported);
6084 (NewVD->
hasAttr<CUDASharedAttr>() ||
6085 NewVD->
hasAttr<CUDAConstantAttr>())) {
6093 assert(!NewVD->
hasAttr<DLLImportAttr>() ||
6094 NewVD->
getAttr<DLLImportAttr>()->isInherited() ||
6099 if (getLangOpts().ObjCAutoRefCount && inferObjCARCLifetime(NewVD))
6111 Diag(
E->getExprLoc(), diag::warn_asm_label_on_auto_decl) << Label;
6117 Diag(
E->getExprLoc(), diag::err_asm_unknown_register_name) << Label;
6128 bool HasSizeMismatch;
6130 if (!TI.isValidGCCRegisterName(Label))
6131 Diag(
E->getExprLoc(), diag::err_asm_unknown_register_name) << Label;
6132 else if (!TI.validateGlobalRegisterVariable(Label,
6135 Diag(
E->getExprLoc(), diag::err_asm_invalid_global_var_reg) << Label;
6136 else if (HasSizeMismatch)
6137 Diag(
E->getExprLoc(), diag::err_asm_register_size_mismatch) << Label;
6148 }
else if (!ExtnameUndeclaredIdentifiers.empty()) {
6151 if (I != ExtnameUndeclaredIdentifiers.end()) {
6154 ExtnameUndeclaredIdentifiers.erase(I);
6163 CheckShadow(S, NewVD, Previous);
6170 IsExplicitSpecialization ||
6171 IsVariableTemplateSpecialization);
6175 if (getLangOpts().CPlusPlus &&
6179 isDeclInScope(Previous.
getFoundDecl(), OriginalDC,
S,
false));
6181 if (!getLangOpts().CPlusPlus) {
6186 CheckMemberSpecialization(NewVD, Previous))
6190 if (!Previous.
empty()) {
6209 if (!IsVariableTemplateSpecialization)
6221 if (CheckTemplateParameterList(
6227 ? TPC_ClassTemplateMember
6233 if (PrevVarTemplate &&
6239 ProcessPragmaWeak(S, NewVD);
6245 RegisterLocallyScopedExternCDecl(NewVD, S);
6248 Decl *ManglingContextDecl;
6252 NewVD, MCtx->getManglingNumber(
6265 if (getLangOpts().CPlusPlus)
6277 IsExplicitSpecialization);
6283 ActOnDocumentableDecl(NewTemplate);
6301 if (Diags.isIgnored(diag::warn_decl_shadow, R.
getNameLoc()))
6315 if (!isa<VarDecl>(ShadowedDecl) && !isa<FieldDecl>(ShadowedDecl))
6319 if (isa<FieldDecl>(ShadowedDecl))
6324 if (
VarDecl *shadowedVar = dyn_cast<VarDecl>(ShadowedDecl))
6325 if (shadowedVar->isExternC()) {
6328 for (
auto I : shadowedVar->redecls())
6329 if (
I->isFileVarDecl()) {
6353 if (isa<RecordDecl>(OldDC)) {
6354 if (isa<FieldDecl>(ShadowedDecl))
6366 if (getSourceManager().isInSystemMacro(R.
getNameLoc()))
6368 Diag(R.
getNameLoc(), diag::warn_decl_shadow) << Name << Kind << OldDC;
6374 if (Diags.isIgnored(diag::warn_decl_shadow, D->
getLocation()))
6380 CheckShadow(S, D, R);
6385 template<
typename T>
6388 assert(S.
getLangOpts().CPlusPlus &&
"only C++ has extern \"C\"");
6409 if (!isa<VarDecl>(ND))
6419 if (isa<VarDecl>(*
I)) {
6429 if (isa<VarDecl>(*
I)) {
6447 assert(Prev &&
"should have found a previous declaration to diagnose");
6449 Prev = FD->getFirstDecl();
6451 Prev = cast<VarDecl>(Prev)->getFirstDecl();
6453 S.
Diag(ND->getLocation(), diag::err_extern_c_global_conflict)
6455 S.
Diag(Prev->getLocation(), diag::note_extern_c_global_conflict)
6468 template<
typename T>
6475 if (ND->getDeclContext()->getRedeclContext()->isTranslationUnit()) {
6487 if (ND->getDeclContext()->getRedeclContext()->isTranslationUnit())
6513 CheckAlignasUnderalignment(NewVD);
6526 if (!getLangOpts().OpenCL
6535 if (getLangOpts().OpenCLVersion == 120 &&
6536 !getOpenCLOptions().cl_clang_storage_class_specifiers &&
6548 if (getLangOpts().OpenCL) {
6553 getLangOpts().OpenCLVersion == 200))) {
6554 if (getLangOpts().OpenCLVersion == 200)
6555 Diag(NewVD->
getLocation(), diag::err_opencl_global_invalid_addr_space)
6556 <<
"global or constant";
6558 Diag(NewVD->
getLocation(), diag::err_opencl_global_invalid_addr_space)
6570 getLangOpts().OpenCLVersion == 200))) {
6571 if (getLangOpts().OpenCLVersion == 200)
6572 Diag(NewVD->
getLocation(), diag::err_opencl_global_invalid_addr_space)
6573 <<
"global or constant";
6575 Diag(NewVD->
getLocation(), diag::err_opencl_global_invalid_addr_space)
6585 if (FD && !FD->
hasAttr<OpenCLKernelAttr>()) {
6600 && !NewVD->
hasAttr<BlocksAttr>()) {
6604 assert(!getLangOpts().ObjCAutoRefCount);
6610 if (isVM || NewVD->
hasAttr<CleanupAttr>() ||
6612 getCurFunction()->setHasBranchProtectedScope();
6616 bool SizeIsNegative;
6617 llvm::APSInt Oversized;
6620 SizeIsNegative, Oversized);
6671 if (isVM && NewVD->
hasAttr<BlocksAttr>()) {
6679 diag::err_constexpr_var_non_literal)) {
6698 CheckVariableDeclarationType(NewVD);
6706 if (Previous.
empty() &&
6710 if (!Previous.
empty()) {
6711 MergeVarDecl(NewVD, Previous);
6718 struct FindOverriddenMethod {
6744 if (MD->isVirtual() && !
S->
IsOverload(Method, MD,
false))
6771 if ((OEK == OEK_All) ||
6772 (OEK == OEK_NonDeleted && !(*I)->isDeleted()) ||
6773 (OEK == OEK_Deleted && (*I)->isDeleted()))
6774 S.
Diag((*I)->getLocation(), diag::note_overridden_virtual_function);
6783 FindOverriddenMethod FOM;
6786 bool hasDeletedOverridenMethods =
false;
6787 bool hasNonDeletedOverridenMethods =
false;
6788 bool AddedAny =
false;
6793 if (!CheckOverridingFunctionReturnType(MD, OldMD) &&
6794 !CheckOverridingFunctionAttributes(MD, OldMD) &&
6795 !CheckOverridingFunctionExceptionSpec(MD, OldMD) &&
6796 !CheckIfOverriddenFunctionIsMarkedFinal(MD, OldMD)) {
6797 hasDeletedOverridenMethods |= OldMD->isDeleted();
6798 hasNonDeletedOverridenMethods |= !OldMD->isDeleted();
6805 if (hasDeletedOverridenMethods && !MD->
isDeleted()) {
6806 ReportOverrides(*
this, diag::err_non_deleted_override, MD, OEK_Deleted);
6808 if (hasNonDeletedOverridenMethods && MD->
isDeleted()) {
6809 ReportOverrides(*
this, diag::err_deleted_override, MD, OEK_NonDeleted);
6818 struct ActOnFDArgs {
6834 : Context(Context), OriginalFD(TypoFD),
6835 ExpectedParent(Parent ? Parent->getCanonicalDecl() : nullptr) {}
6837 bool ValidateCandidate(
const TypoCorrection &candidate)
override {
6843 CDeclEnd = candidate.
end();
6844 CDecl != CDeclEnd; ++CDecl) {
6853 }
else if (!ExpectedParent) {
6881 ActOnFDArgs &ExtraArgs,
bool IsLocalFriend,
Scope *
S) {
6887 bool IsDefinition = ExtraArgs.D.isFunctionDefinition();
6888 unsigned DiagMsg = IsLocalFriend ? diag::err_no_matching_local_friend
6889 : diag::err_member_decl_does_not_match;
6900 assert(!Prev.isAmbiguous() &&
6901 "Cannot have an ambiguity in previous-declaration lookup");
6903 if (!Prev.empty()) {
6905 Func != FuncEnd; ++Func) {
6912 MismatchedParams.empty() ? 0 : MismatchedParams.front() + 1;
6913 NearMatches.push_back(std::make_pair(FD, ParamNum));
6918 Prev.getLookupNameInfo(), Prev.getLookupKind(),
S,
6919 &ExtraArgs.D.getCXXScopeSpec(),
6920 llvm::make_unique<DifferentNameValidatorCCC>(
6925 ExtraArgs.D.getIdentifierLoc());
6929 CDeclEnd = Correction.
end();
6930 CDecl != CDeclEnd; ++CDecl) {
6937 bool wasRedeclaration = ExtraArgs.D.isRedeclaration();
6950 ExtraArgs.S, ExtraArgs.D,
6953 ExtraArgs.AddToScope);
6964 if ((*I)->getCanonicalDecl() == Canonical)
6969 SemaRef.
PDiag(IsLocalFriend
6970 ? diag::err_no_matching_local_friend_suggest
6971 : diag::err_member_decl_does_not_match_suggest)
6972 << Name << NewDC << IsDefinition);
6978 ExtraArgs.D.getIdentifierLoc());
6979 ExtraArgs.D.setRedeclaration(wasRedeclaration);
6985 << Name << NewDC << IsDefinition << NewFD->
getLocation();
6987 bool NewFDisConst =
false;
6989 NewFDisConst = NewMD->isConst();
6992 NearMatch = NearMatches.begin(), NearMatchEnd = NearMatches.end();
6993 NearMatch != NearMatchEnd; ++NearMatch) {
6996 bool FDisConst = MD && MD->
isConst();
6997 bool IsMember = MD || !IsLocalFriend;
7000 if (
unsigned Idx = NearMatch->second) {
7004 SemaRef.
Diag(Loc, IsMember ? diag::note_member_def_close_param_match
7005 : diag::note_local_decl_close_param_match)
7008 }
else if (FDisConst != NewFDisConst) {
7009 SemaRef.
Diag(FD->
getLocation(), diag::note_member_def_close_const_match)
7013 IsMember ? diag::note_member_def_close_match
7014 : diag::note_local_decl_close_match);
7021 default: llvm_unreachable(
"Unknown storage class!");
7026 diag::err_typecheck_sclass_func);
7042 diag::err_static_block_func);
7058 bool &IsVirtualOkay) {
7077 TInfo, SC, isInline,
7078 HasPrototype,
false);
7100 "Constructors can only be declared in a member context");
7105 R, TInfo, isExplicit, isInline,
7117 NameInfo, R, TInfo, isInline,
7129 IsVirtualOkay =
true;
7148 diag::err_conv_function_not_member);
7153 IsVirtualOkay =
true;
7156 R, TInfo, isInline, isExplicit,
7174 cast<CXXRecordDecl>(DC),
7176 TInfo, SC, isInline,
7191 NameInfo, R, TInfo, SC, isInline,
7239 llvm::SmallPtrSetImpl<const Type *> &ValidTypes) {
7260 S.
Diag(Param->
getLocation(), diag::err_opencl_private_ptr_kernel_param);
7293 HistoryStack.push_back(
nullptr);
7296 VisitStack.push_back(PD);
7298 assert(VisitStack.back() &&
"First decl null?");
7301 const Decl *
Next = VisitStack.pop_back_val();
7303 assert(!HistoryStack.empty());
7305 if (
const FieldDecl *Hist = HistoryStack.pop_back_val())
7306 ValidTypes.insert(Hist->getType().getTypePtr());
7314 if (
const FieldDecl *Field = dyn_cast<FieldDecl>(Next)) {
7315 HistoryStack.push_back(Field);
7316 RD = Field->getType()->castAs<
RecordType>()->getDecl();
7318 RD = cast<RecordDecl>(
Next);
7322 VisitStack.push_back(
nullptr);
7324 for (
const auto *FD : RD->
fields()) {
7335 VisitStack.push_back(FD);
7346 diag::err_record_with_pointers_kernel_param)
7359 I = HistoryStack.begin() + 1,
7360 E = HistoryStack.end();
7373 }
while (!VisitStack.empty());
7392 diag::err_invalid_thread)
7399 bool isFriend =
false;
7401 bool isExplicitSpecialization =
false;
7402 bool isFunctionTemplateSpecialization =
false;
7404 bool isDependentClassScopeExplicitSpecialization =
false;
7405 bool HasExplicitTemplateArgs =
false;
7408 bool isVirtualOkay =
false;
7411 bool IsLocalExternDecl = adjustContextForLocalExternDecl(DC);
7415 if (!NewFD)
return nullptr;
7417 if (OriginalLexicalContext && OriginalLexicalContext->isObjCContainer())
7425 if (IsLocalExternDecl)
7447 if (Parent->isInterface() && cast<CXXMethodDecl>(NewFD)->isUserProvided())
7452 if (isVirtual && Parent->isUnion())
7457 isExplicitSpecialization =
false;
7458 isFunctionTemplateSpecialization =
false;
7464 bool Invalid =
false;
7466 MatchTemplateParametersToScopeSpecifier(
7472 TemplateParamLists, isFriend, isExplicitSpecialization,
7474 if (TemplateParams->size() > 0) {
7478 if (CheckTemplateDeclScope(S, TemplateParams))
7492 if (RebuildTemplateParamsInCurrentInstantiation(TemplateParams))
7499 Name, TemplateParams,
7505 if (TemplateParamLists.size() > 1) {
7507 TemplateParamLists.drop_back(1));
7511 isFunctionTemplateSpecialization =
true;
7513 if (TemplateParamLists.size() > 0)
7519 SourceRange RemoveRange = TemplateParams->getSourceRange();
7529 InsertLoc = getLocForEndOfToken(InsertLoc);
7533 << Name << RemoveRange
7542 if (TemplateParamLists.size() > 0)
7549 if (FunctionTemplate)
7559 if (!isVirtualOkay) {
7561 diag::err_virtual_non_function);
7562 }
else if (!CurContext->isRecord()) {
7565 diag::err_virtual_out_of_class)
7571 diag::err_virtual_member_function_template)
7583 if (getLangOpts().CPlusPlus14 &&
7585 (isFriend && CurContext->isDependentContext())) &&
7605 if (CurContext->isFunctionOrMethod()) {
7608 diag::err_inline_declaration_block_scope) << Name
7618 if (!CurContext->isRecord()) {
7621 diag::err_explicit_out_of_class)
7623 }
else if (!isa<CXXConstructorDecl>(NewFD) &&
7624 !isa<CXXConversionDecl>(NewFD)) {
7628 diag::err_explicit_non_ctor_or_conv_function)
7641 if (isa<CXXDestructorDecl>(NewFD))
7650 diag::err_function_concept_not_defined);
7658 if (FPT->hasExceptionSpec()) {
7673 if (FPT->getNumParams() > 0 || FPT->isVariadic())
7686 diag::err_concept_decl_invalid_specifiers)
7693 diag::err_concept_decl_invalid_specifiers)
7700 diag::err_concept_decl_invalid_specifiers)
7708 if (isFunctionTemplateSpecialization) {
7711 Diag(ModulePrivateLoc, diag::err_module_private_specialization)
7716 if (FunctionTemplate)
7722 if (FunctionTemplate) {
7747 if (isa<CXXMethodDecl>(NewFD) && DC == CurContext &&
7755 if (SC ==
SC_Static && isa<CXXMethodDecl>(NewFD) &&
7756 !CurContext->isRecord()) {
7765 diag::err_static_out_of_line)
7784 isExplicitSpecialization ||
7785 isFunctionTemplateSpecialization);
7793 }
else if (!ExtnameUndeclaredIdentifiers.empty()) {
7796 if (I != ExtnameUndeclaredIdentifiers.end()) {
7799 ExtnameUndeclaredIdentifiers.erase(I);
7818 for (
unsigned i = 0, e = FTI.
NumParams; i != e; ++i) {
7822 Params.push_back(Param);
7840 for (
const auto &AI : FT->param_types()) {
7844 Params.push_back(Param);
7848 "Should not need args for typedef of non-prototype fn");
7852 NewFD->setParams(Params);
7861 DeclsInPrototypeScope.clear();
7878 !NewFD->
hasAttr<SectionAttr>()) {
7880 SectionAttr::CreateImplicit(
Context, SectionAttr::Declspec_allocate,
7881 CodeSegStack.CurrentValue->getString(),
7882 CodeSegStack.CurrentPragmaLocation));
7883 if (UnifySection(CodeSegStack.CurrentValue->getString(),
7891 ProcessDeclAttributes(S, NewFD, D);
7893 if (getLangOpts().OpenCL) {
7901 diag::err_opencl_return_value_with_address_space);
7908 bool isExplicitSpecialization=
false;
7913 CheckMSVCRTEntryPoint(NewFD);
7917 isExplicitSpecialization));
7918 else if (!Previous.
empty())
7923 "previous declaration set still overloaded");
7935 CC ==
CC_X86StdCall ? diag::warn_cconv_knr : diag::err_cconv_knr;
7952 diag::ext_operator_new_delete_declared_inline)
7963 translateTemplateArguments(TemplateArgsPtr,
7966 HasExplicitTemplateArgs =
true;
7969 HasExplicitTemplateArgs =
false;
7970 }
else if (FunctionTemplate) {
7975 HasExplicitTemplateArgs =
false;
7977 assert((isFunctionTemplateSpecialization ||
7979 "should have a 'template<>' for this decl");
7981 isFunctionTemplateSpecialization =
true;
7983 }
else if (isFriend && isFunctionTemplateSpecialization) {
7990 HasExplicitTemplateArgs =
true;
7999 bool InstantiationDependent =
false;
8000 if (isFunctionTemplateSpecialization && isFriend &&
8004 InstantiationDependent))) {
8005 assert(HasExplicitTemplateArgs &&
8006 "friend function specialization without template args");
8007 if (CheckDependentFunctionTemplateSpecialization(NewFD, TemplateArgs,
8010 }
else if (isFunctionTemplateSpecialization) {
8011 if (CurContext->isDependentContext() && CurContext->isRecord()
8013 isDependentClassScopeExplicitSpecialization =
true;
8015 diag::ext_function_specialization_in_class :
8016 diag::err_function_specialization_in_class)
8018 }
else if (CheckFunctionTemplateSpecialization(NewFD,
8019 (HasExplicitTemplateArgs ? &TemplateArgs
8032 diag::err_explicit_specialization_inconsistent_storage_class)
8039 diag::ext_explicit_specialization_storage_class)
8044 }
else if (isExplicitSpecialization && isa<CXXMethodDecl>(NewFD)) {
8045 if (CheckMemberSpecialization(NewFD, Previous))
8050 if (!isDependentClassScopeExplicitSpecialization) {
8055 CheckMSVCRTEntryPoint(NewFD);
8059 isExplicitSpecialization));
8060 else if (!Previous.
empty())
8067 "previous declaration set still overloaded");
8069 NamedDecl *PrincipalDecl = (FunctionTemplate
8070 ? cast<NamedDecl>(FunctionTemplate)
8079 if (FunctionTemplate) FunctionTemplate->
setAccess(Access);
8088 if (FunctionTemplate) {
8096 ? TPC_FriendFunctionTemplateDefinition
8097 : TPC_FriendFunctionTemplate)
8101 ? TPC_ClassTemplateMember
8102 : TPC_FunctionTemplate);
8108 struct ActOnFDArgs ExtraArgs = {
S, D, TemplateParamLists,
8126 (TemplateParamLists.size() ||
8128 CurContext->isDependentContext())) {
8147 *
this, Previous, NewFD, ExtraArgs,
false,
nullptr)) {
8148 AddToScope = ExtraArgs.AddToScope;
8155 }
else if (isFriend && cast<CXXRecordDecl>(CurContext)->isLocalClass()) {
8157 *
this, Previous, NewFD, ExtraArgs,
true, S)) {
8158 AddToScope = ExtraArgs.AddToScope;
8164 isa<CXXMethodDecl>(NewFD) && NewFD->
isOutOfLine() &&
8165 !isFriend && !isFunctionTemplateSpecialization &&
8166 !isExplicitSpecialization) {
8179 ProcessPragmaWeak(S, NewFD);
8182 AddKnownFunctionAttributes(NewFD);
8184 if (NewFD->
hasAttr<OverloadableAttr>() &&
8187 diag::err_attribute_overloadable_no_prototype)
8195 EPI.ExtInfo = FT->getExtInfo();
8204 AddPushedVisibilityAttribute(NewFD);
8208 AddCFAuditedAttribute(NewFD);
8213 AddRangeBasedOptnone(NewFD);
8219 RegisterLocallyScopedExternCDecl(NewFD, S);
8227 isExplicitSpecialization || isFunctionTemplateSpecialization);
8231 if (FunctionTemplate) {
8234 return FunctionTemplate;
8238 if (NewFD->
hasAttr<OpenCLKernelAttr>()) {
8240 if ((getLangOpts().OpenCLVersion >= 120)
8255 llvm::SmallPtrSet<const Type *, 16> ValidTypes;
8256 for (
auto Param : NewFD->
params())
8260 PE = NewFD->
param_end(); PI != PE; ++PI) {
8266 if (getLangOpts().OpenCLVersion >= 200) {
8268 QualType ElemTy = PipeTy->getElementType();
8277 MarkUnusedFileScopedDecl(NewFD);
8279 if (getLangOpts().CUDA)
8283 if (II->isStr(
"cudaConfigureCall")) {
8294 if (isDependentClassScopeExplicitSpecialization) {
8298 cast<CXXMethodDecl>(NewFD),
8299 HasExplicitTemplateArgs, TemplateArgs);
8300 CurContext->addDecl(NewSpec);
8325 bool IsExplicitSpecialization) {
8327 "Variably modified return types are not handled here");
8332 bool MergeTypeWithPrevious = !getLangOpts().CPlusPlus &&
8335 bool Redeclaration =
false;
8340 if (!Previous.
empty()) {
8347 if (shouldLinkPossiblyHiddenDecl(Candidate, NewFD)) {
8348 Redeclaration =
true;
8349 OldDecl = Candidate;
8352 switch (CheckOverload(S, NewFD, Previous, OldDecl,
8355 Redeclaration =
true;
8358 case Ovl_NonFunction:
8359 Redeclaration =
true;
8363 Redeclaration =
false;
8371 << Redeclaration << NewFD;
8374 OverloadedDecl = OldDecl;
8375 else if (!Previous.
empty())
8378 Diag(OverloadedDecl->getLocation(),
8379 diag::note_attribute_overloadable_prev_overload);
8386 if (!Redeclaration &&
8388 if (!Previous.
empty()) {
8391 Redeclaration =
true;
8393 MergeTypeWithPrevious =
false;
8396 if (OldDecl->
hasAttr<OverloadableAttr>()) {
8399 << Redeclaration << NewFD;
8401 diag::note_attribute_overloadable_prev_overload);
8404 if (IsOverload(NewFD, cast<FunctionDecl>(OldDecl),
false)) {
8405 Redeclaration =
false;
8422 if (!getLangOpts().CPlusPlus14 && MD && MD->
isConstexpr() &&
8423 !MD->
isStatic() && !isa<CXXConstructorDecl>(MD) &&
8427 OldMD = dyn_cast_or_null<CXXMethodDecl>(OldDecl->
getAsFunction());
8428 if (!OldMD || !OldMD->
isStatic()) {
8438 if (ActiveTemplateInstantiations.empty()) {
8442 AddConstLoc = getLocForEndOfToken(FTL.getRParenLoc());
8450 if (Redeclaration) {
8453 if (MergeFunctionDecl(NewFD, OldDecl, S, MergeTypeWithPrevious)) {
8455 return Redeclaration;
8462 = dyn_cast<FunctionTemplateDecl>(OldDecl)) {
8466 assert(NewTemplateDecl &&
"Template/non-template mismatch");
8469 Method->setAccess(OldTemplateDecl->getAccess());
8470 NewTemplateDecl->
setAccess(OldTemplateDecl->getAccess());
8475 if (IsExplicitSpecialization &&
8478 assert(OldTemplateDecl->isMemberSpecialization());
8485 if (isa<CXXMethodDecl>(NewFD))
8492 if (getLangOpts().CPlusPlus) {
8495 CheckConstructor(Constructor);
8497 dyn_cast<CXXDestructorDecl>(NewFD)) {
8510 return Redeclaration;
8514 = dyn_cast<CXXConversionDecl>(NewFD)) {
8515 ActOnConversionDeclarator(Conversion);
8519 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(NewFD)) {
8520 if (!Method->isFunctionTemplateSpecialization() &&
8521 !Method->getDescribedFunctionTemplate() &&
8522 Method->isCanonicalDecl()) {
8523 if (AddOverriddenMethods(Method->getParent(), Method)) {
8531 if (Method->isStatic())
8532 checkThisInStaticMemberFunctionType(Method);
8537 CheckOverloadedOperatorDeclaration(NewFD)) {
8539 return Redeclaration;
8544 CheckLiteralOperatorDeclaration(NewFD)) {
8546 return Redeclaration;
8552 if (!CurContext->isRecord())
8553 CheckCXXDefaultArguments(NewFD);
8579 Diag(NewFD->
getLocation(), diag::warn_return_value_udt) << NewFD << R;
8582 return Redeclaration;
8595 ? diag::err_static_main : diag::warn_static_main)
8602 SourceRange NoreturnRange(NoreturnLoc, getLocForEndOfToken(NoreturnLoc));
8603 Diag(NoreturnLoc, diag::ext_noreturn_main);
8604 Diag(NoreturnLoc, diag::note_main_remove_noreturn)
8613 if (getLangOpts().OpenCL) {
8615 << FD->
hasAttr<OpenCLKernelAttr>();
8621 assert(T->
isFunctionType() &&
"function decl is not of function type");
8624 if (getLangOpts().GNUMode && !getLangOpts().CPlusPlus) {
8635 if (RTRange.isValid())
8636 Diag(RTRange.getBegin(), diag::note_main_change_return_type)
8658 if (isa<FunctionNoProtoType>(FT))
return;
8664 bool HasExtraParameters = (nparams > 3);
8676 HasExtraParameters =
false;
8678 if (HasExtraParameters) {
8691 for (
unsigned i = 0; i < nparams; ++i) {
8694 bool mismatch =
true;
8698 else if (Expected[i] == CharPP) {
8711 mismatch = !qs.
empty();
8716 Diag(FD->
getLocation(), diag::err_main_arg_wrong) << i << Expected[i];
8734 assert(T->
isFunctionType() &&
"function decl is not of function type");
8739 if (FT->getReturnType()->isIntegralOrEnumerationType() ||
8740 FT->getReturnType()->isAnyPointerType() ||
8741 FT->getReturnType()->isNullPtrType())
8743 if (FD->
getName() !=
"DllMain")
8761 const Expr *Culprit;
8765 << Culprit->getSourceRange();
8772 class SelfReferenceChecker
8778 bool isReferenceType;
8786 S(S), OrigDecl(OrigDecl) {
8789 isReferenceType =
false;
8791 if (
ValueDecl *VD = dyn_cast<ValueDecl>(OrigDecl)) {
8792 isPODType = VD->getType().isPODType(S.
Context);
8794 isReferenceType = VD->getType()->isReferenceType();
8801 void CheckExpr(
Expr *
E) {
8810 InitFieldIndex.push_back(0);
8811 for (
auto Child : InitList->
children()) {
8812 CheckExpr(cast<Expr>(Child));
8813 ++InitFieldIndex.back();
8815 InitFieldIndex.pop_back();
8820 bool CheckInitListMemberExpr(
MemberExpr *E,
bool CheckReference) {
8823 bool ReferenceField =
false;
8826 while (
MemberExpr *ME = dyn_cast<MemberExpr>(Base)) {
8830 Fields.push_back(FD);
8832 ReferenceField =
true;
8838 if (!DRE || DRE->
getDecl() != OrigDecl)
8842 if (CheckReference && !ReferenceField)
8847 for (
const FieldDecl *
I : llvm::reverse(Fields))
8848 UsedFieldIndex.push_back(
I->getFieldIndex());
8853 for (
auto UsedIter = UsedFieldIndex.begin(),
8854 UsedEnd = UsedFieldIndex.end(),
8855 OrigIter = InitFieldIndex.begin(),
8856 OrigEnd = InitFieldIndex.end();
8857 UsedIter != UsedEnd && OrigIter != OrigEnd; ++UsedIter, ++OrigIter) {
8858 if (*UsedIter < *OrigIter)
8860 if (*UsedIter > *OrigIter)
8865 HandleDeclRefExpr(DRE);
8872 void HandleValue(
Expr *E) {
8874 if (
DeclRefExpr* DRE = dyn_cast<DeclRefExpr>(E)) {
8875 HandleDeclRefExpr(DRE);
8880 Visit(CO->getCond());
8881 HandleValue(CO->getTrueExpr());
8882 HandleValue(CO->getFalseExpr());
8887 dyn_cast<BinaryConditionalOperator>(E)) {
8888 Visit(BCO->getCond());
8889 HandleValue(BCO->getFalseExpr());
8894 HandleValue(OVE->getSourceExpr());
8900 Visit(BO->getLHS());
8901 HandleValue(BO->getRHS());
8906 if (isa<MemberExpr>(E)) {
8908 if (CheckInitListMemberExpr(cast<MemberExpr>(E),
8914 while (
MemberExpr *ME = dyn_cast<MemberExpr>(Base)) {
8916 if (!isa<FieldDecl>(ME->getMemberDecl()))
8920 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Base))
8921 HandleDeclRefExpr(DRE);
8931 if (isReferenceType)
8932 HandleDeclRefExpr(E);
8941 Inherited::VisitImplicitCastExpr(E);
8946 if (CheckInitListMemberExpr(E,
true ))
8956 bool Warn = (MD && !MD->
isStatic());
8958 while (
MemberExpr *ME = dyn_cast<MemberExpr>(Base)) {
8959 if (!isa<FieldDecl>(ME->getMemberDecl()))
8964 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(Base)) {
8966 HandleDeclRefExpr(DRE);
8978 if (isa<UnresolvedLookupExpr>(Callee))
8979 return Inherited::VisitCXXOperatorCallExpr(E);
8983 HandleValue(Arg->IgnoreParenImpCasts());
9000 Inherited::VisitUnaryOperator(E);
9008 if (
InitListExpr *ILE = dyn_cast<InitListExpr>(ArgExpr))
9009 if (ILE->getNumInits() == 1)
9010 ArgExpr = ILE->getInit(0);
9012 if (ICE->getCastKind() ==
CK_NoOp)
9013 ArgExpr = ICE->getSubExpr();
9014 HandleValue(ArgExpr);
9017 Inherited::VisitCXXConstructExpr(E);
9026 HandleValue(E->
getArg(0));
9032 Inherited::VisitCallExpr(E);
9037 HandleValue(E->
getLHS());
9042 Inherited::VisitBinaryOperator(E);
9055 if (OrigDecl != ReferenceDecl)
return;
9057 if (isReferenceType) {
9058 diag = diag::warn_uninit_self_reference_in_reference_init;
9059 }
else if (cast<VarDecl>(OrigDecl)->isStaticLocal()) {
9060 diag = diag::warn_static_self_reference_in_init;
9061 }
else if (isa<TranslationUnitDecl>(OrigDecl->
getDeclContext()) ||
9064 diag = diag::warn_uninit_self_reference_in_init;
9074 << DRE->getSourceRange());
9079 static void CheckSelfReference(
Sema &S,
Decl* OrigDecl,
Expr *E,
9083 if (isa<ParmVarDecl>(OrigDecl))
9090 if (!DirectInit && !cast<VarDecl>(OrigDecl)->getType()->
isRecordType())
9093 if (
DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(ICE->getSubExpr()))
9094 if (DRE->
getDecl() == OrigDecl)
9097 SelfReferenceChecker(S, OrigDecl).CheckExpr(E);
9106 bool IsInitCapture = !VDecl;
9108 "init captures are expected to be deduced prior to initialization");
9112 if (
auto *PL = dyn_cast<ParenListExpr>(Init))
9113 DeduceInits = PL->exprs();
9114 else if (
auto *IL = dyn_cast<InitListExpr>(Init))
9115 DeduceInits = IL->inits();
9119 if (DeduceInits.empty()) {
9122 Diag(Init->getLocStart(), IsInitCapture
9123 ? diag::err_init_capture_no_expression
9124 : diag::err_auto_var_init_no_expression)
9125 << Name << Type << Range;
9129 if (DeduceInits.size() > 1) {
9130 Diag(DeduceInits[1]->getLocStart(),
9131 IsInitCapture ? diag::err_init_capture_multiple_expressions
9132 : diag::err_auto_var_init_multiple_expressions)
9133 << Name << Type << Range;
9137 Expr *DeduceInit = DeduceInits[0];
9138 if (DirectInit && isa<InitListExpr>(DeduceInit)) {
9139 Diag(Init->getLocStart(), IsInitCapture
9140 ? diag::err_init_capture_paren_braces
9141 : diag::err_auto_var_init_paren_braces)
9142 << isa<InitListExpr>(Init) << Name << Type << Range;
9147 bool DefaultedAnyToId =
false;
9148 if (getLangOpts().DebuggerCastResultToId &&
9154 Init = Result.
get();
9155 DefaultedAnyToId =
true;
9159 if (DeduceAutoType(TSI, DeduceInit, DeducedType) == DAR_Failed) {
9161 DiagnoseAutoDeductionFailure(VDecl, DeduceInit);
9162 else if (isa<InitListExpr>(Init))
9164 diag::err_init_capture_deduction_failure_from_init_list)
9168 << DeduceInit->getSourceRange();
9170 Diag(Range.
getBegin(), diag::err_init_capture_deduction_failure)
9174 << DeduceInit->getSourceRange();
9182 if (ActiveTemplateInstantiations.empty() && !DefaultedAnyToId &&
9185 Diag(Loc, diag::warn_auto_var_is_id) << Name << Range;
9195 bool DirectInit,
bool TypeMayContainAuto) {
9199 CorrectDelayedTyposInExpr(Init, dyn_cast_or_null<VarDecl>(RealDecl));
9203 if (
CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(RealDecl)) {
9205 Diag(Method->getLocation(), diag::err_member_function_initialization)
9206 << Method->getDeclName() << Init->getSourceRange();
9207 Method->setInvalidDecl();
9213 assert(!isa<FieldDecl>(RealDecl) &&
"field init shouldn't get here");
9224 ExprResult Res = CorrectDelayedTyposInExpr(Init, VDecl);
9231 QualType DeducedType = deduceVarTypeFromInitializer(
9234 if (DeducedType.
isNull()) {
9243 if (getLangOpts().ObjCAutoRefCount && inferObjCARCLifetime(VDecl))
9251 MergeVarDeclTypes(VDecl, Old,
false);
9255 CheckVariableDeclarationType(VDecl);
9262 Diag(VDecl->
getLocation(), diag::err_attribute_dllimport_data_definition);
9280 BaseDeclType = Array->getElementType();
9281 if (RequireCompleteType(VDecl->
getLocation(), BaseDeclType,
9282 diag::err_typecheck_decl_incomplete_type)) {
9289 diag::err_abstract_type_in_decl,
9290 AbstractVariableType))
9297 if (!hasVisibleDefinition(Def, &Hidden) &&
9327 Diag(Init->
getExprLoc(), diag::err_static_data_member_reinitialization)
9330 diag::note_previous_initializer)
9336 getCurFunction()->setHasBranchProtectedScope();
9338 if (DiagnoseUnexpandedParameterPack(Init, UPPC_Initializer)) {
9365 Init = Result.
get();
9376 Init->getLocStart(),
9380 Init->getLocStart());
9388 for (
size_t Idx = 0; Idx < Args.size(); ++Idx) {
9390 Args[Idx], VDecl, [
this, Entity, Kind](
Expr *E) {
9396 }
else if (Res.
get() != Args[Idx]) {
9397 Args[Idx] = Res.
get();
9418 CheckSelfReference(*
this, RealDecl, Init, DirectInit);
9431 if (VDecl->
hasAttr<BlocksAttr>())
9432 checkRetainCycles(VDecl, Init);
9442 !Diags.isIgnored(diag::warn_arc_repeated_use_of_weak,
9443 Init->getLocStart()))
9444 getCurFunction()->markSafeWeakUse(Init);
9465 Init = Result.
get();
9475 const Expr *Culprit;
9477 CheckForConstantInitializer(Init, DclT);
9483 isa<InitListExpr>(Init) &&
9486 diag::ext_aggregate_init_not_constant)
9487 << Culprit->getSourceRange();
9523 << Init->getSourceRange();
9541 Diag(Loc, diag::ext_in_class_initializer_non_constant)
9542 << Init->getSourceRange();
9546 Diag(Loc, diag::err_in_class_initializer_non_constant)
9547 << Init->getSourceRange();
9555 if (getLangOpts().CPlusPlus11) {
9557 diag::ext_in_class_initializer_float_type_cxx11)
9558 << DclT << Init->getSourceRange();
9560 diag::note_in_class_initializer_float_type_cxx11)
9564 << DclT << Init->getSourceRange();
9567 Diag(Init->
getExprLoc(), diag::err_in_class_initializer_non_constant)
9568 << Init->getSourceRange();
9575 Diag(VDecl->
getLocation(), diag::err_in_class_initializer_literal_type)
9576 << DclT << Init->getSourceRange()
9582 << DclT << Init->getSourceRange();
9587 (!getLangOpts().CPlusPlus ||
9595 CheckForConstantInitializer(Init, DclT);
9612 if (CXXDirectInit) {
9613 assert(DirectInit &&
"Call-style initializer must be direct init.");
9615 }
else if (DirectInit) {
9620 CheckCompleteVariableDeclaration(VDecl);
9635 if (ParsingInitForAutoVars.count(D)) {
9646 diag::err_typecheck_decl_incomplete_type)) {
9653 diag::err_abstract_type_in_decl,
9654 AbstractVariableType)) {
9664 bool TypeMayContainAuto) {
9669 if (
VarDecl *Var = dyn_cast<VarDecl>(RealDecl)) {
9674 Diag(Var->getLocation(), diag::err_auto_var_requires_init)
9675 << Var->getDeclName() << Type;
9676 Var->setInvalidDecl();
9686 if (Var->isConstexpr() && !Var->isThisDeclarationADefinition()) {
9687 if (Var->isStaticDataMember())
9688 Diag(Var->getLocation(),
9689 diag::err_constexpr_static_mem_var_requires_init)
9690 << Var->getDeclName();
9692 Diag(Var->getLocation(), diag::err_invalid_constexpr_var_decl);
9693 Var->setInvalidDecl();
9700 if (Var->isConcept()) {
9701 Diag(Var->getLocation(), diag::err_var_concept_not_initialized);
9702 Var->setInvalidDecl();
9708 if (!Var->isInvalidDecl() &&
9710 Var->getStorageClass() !=
SC_Extern && !Var->getInit()) {
9711 Diag(Var->getLocation(), diag::err_opencl_constant_no_init);
9712 Var->setInvalidDecl();
9716 switch (Var->isThisDeclarationADefinition()) {
9718 if (!Var->isStaticDataMember() || !Var->getAnyInitializer())
9734 !Var->hasLinkage() && !Var->isInvalidDecl() &&
9735 RequireCompleteType(Var->getLocation(), Type,
9736 diag::err_typecheck_decl_incomplete_type))
9737 Var->setInvalidDecl();
9741 RequireNonAbstractType(Var->getLocation(), Type,
9742 diag::err_abstract_type_in_decl,
9743 AbstractVariableType))
9744 Var->setInvalidDecl();
9747 Diag(Var->getLocation(), diag::warn_private_extern);
9748 Diag(Var->getLocation(), diag::note_private_extern);
9759 if (!Var->isInvalidDecl()) {
9762 if (RequireCompleteType(Var->getLocation(),
9763 ArrayT->getElementType(),
9764 diag::err_illegal_decl_array_incomplete_type))
9765 Var->setInvalidDecl();
9766 }
else if (Var->getStorageClass() ==
SC_Static) {
9776 if (Var->isFirstDecl())
9777 RequireCompleteType(Var->getLocation(), Type,
9778 diag::ext_typecheck_decl_incomplete_type);
9783 if (!Var->isInvalidDecl())
9784 TentativeDefinitions.push_back(Var);
9791 Diag(Var->getLocation(),
9792 diag::err_typecheck_incomplete_array_needs_initializer);
9793 Var->setInvalidDecl();
9800 Diag(Var->getLocation(), diag::err_reference_var_requires_init)
9801 << Var->getDeclName()
9802 <<
SourceRange(Var->getLocation(), Var->getLocation());
9803 Var->setInvalidDecl();
9812 if (Var->isInvalidDecl())
9815 if (!Var->hasAttr<AliasAttr>()) {
9816 if (RequireCompleteType(Var->getLocation(),
9818 diag::err_typecheck_decl_incomplete_type)) {
9819 Var->setInvalidDecl();
9827 if (RequireNonAbstractType(Var->getLocation(), Type,
9828 diag::err_abstract_type_in_decl,
9829 AbstractVariableType)) {
9830 Var->setInvalidDecl();
9844 if (getLangOpts().
CPlusPlus && Var->hasLocalStorage()) {
9847 CXXRecordDecl *CXXRecord = cast<CXXRecordDecl>(Record->getDecl());
9851 if (!CXXRecord->
isPOD())
9852 getCurFunction()->setHasBranchProtectedScope();
9877 Var->setInvalidDecl();
9878 else if (Init.
get()) {
9879 Var->setInit(MaybeCreateExprWithCleanups(Init.
get()));
9884 CheckCompleteVariableDeclaration(Var);
9938 const char *PrevSpec;
9941 getPrintingPolicy());
9949 EmptyAttrs, IdentLoc);
9950 Decl *Var = ActOnDeclarator(S, D);
9951 cast<VarDecl>(Var)->setCXXForRangeDecl(
true);
9952 FinalizeDeclaration(Var);
9953 return ActOnDeclStmt(FinalizeDeclaratorGroup(S, DS, Var), IdentLoc,
9954 AttrEnd.
isValid() ? AttrEnd : IdentLoc);
9962 if (getLangOpts().ObjC1 &&
9972 getCurFunction()->setHasBranchProtectedScope();
9985 !getDiagnostics().isIgnored(diag::warn_missing_variable_declarations,
9993 Diag(var->
getLocation(), diag::warn_missing_variable_declarations) << var;
9997 const Expr *Culprit;
10003 if (getLangOpts().CPlusPlus11)
10005 }
else if (getLangOpts().CPlusPlus && var->
hasInit() &&
10013 << Culprit->getSourceRange();
10023 ActiveTemplateInstantiations.empty()) {
10027 Stack = &ConstSegStack;
10029 Stack = &BSSSegStack;
10032 Stack = &DataSegStack;
10036 var->
addAttr(SectionAttr::CreateImplicit(
10037 Context, SectionAttr::Declspec_allocate,
10040 if (
const SectionAttr *SA = var->
getAttr<SectionAttr>())
10041 if (UnifySection(SA->getName(), SectionFlags, var))
10047 if (CurInitSeg && var->
getInit())
10048 var->
addAttr(InitSegAttr::CreateImplicit(
Context, CurInitSeg->getString(),
10053 if (!getLangOpts().CPlusPlus)
return;
10059 if (var->
hasAttr<BlocksAttr>()) {
10070 = PerformMoveOrCopyInitialization(
10072 var, var->
getType(), varRef,
true);
10074 result = MaybeCreateExprWithCleanups(result);
10088 !getDiagnostics().isIgnored(diag::warn_global_constructor,
10097 << Init->getSourceRange();
10106 if (Notes.size() == 1 && Notes[0].second.getDiagID() ==
10107 diag::note_invalid_subexpr_in_const_expr) {
10108 DiagLoc = Notes[0].first;
10111 Diag(DiagLoc, diag::err_constexpr_var_requires_const_init)
10112 << var << Init->getSourceRange();
10113 for (
unsigned I = 0, N = Notes.size();
I != N; ++
I)
10114 Diag(Notes[
I].first, Notes[
I].second);
10126 FinalizeVarWithDestructor(var, recordType);
10134 if (
I->isAlignmentDependent())
10144 ParsingInitForAutoVars.erase(ThisDecl);
10146 VarDecl *VD = dyn_cast_or_null<VarDecl>(ThisDecl);
10173 auto *NewAttr = cast<InheritableAttr>(A->clone(getASTContext()));
10174 NewAttr->setInherited(
true);
10184 if (
const auto *IA = dyn_cast_or_null<DLLImportAttr>(DLLAttr)) {
10191 bool IsClassTemplateMember =
10192 isa<ClassTemplatePartialSpecializationDecl>(
Context) ||
10196 IsClassTemplateMember
10197 ? diag::warn_attribute_dllimport_static_field_definition
10198 : diag::err_attribute_dllimport_static_field_definition);
10199 Diag(IA->getLocation(), diag::note_attribute);
10200 if (!IsClassTemplateMember)
10232 AddPushedVisibilityAttribute(VD);
10236 !isa<VarTemplatePartialSpecializationDecl>(VD))
10237 MarkUnusedFileScopedDecl(VD);
10241 if (!VD->
hasAttr<TypeTagForDatatypeAttr>() ||
10245 for (
const auto *
I : ThisDecl->
specific_attrs<TypeTagForDatatypeAttr>()) {
10247 if (!MagicValueExpr) {
10250 llvm::APSInt MagicValueInt;
10252 Diag(
I->getRange().getBegin(),
10253 diag::err_type_tag_for_datatype_not_ice)
10254 << LangOpts.CPlusPlus << MagicValueExpr->getSourceRange();
10257 if (MagicValueInt.getActiveBits() > 64) {
10258 Diag(
I->getRange().getBegin(),
10259 diag::err_type_tag_for_datatype_too_large)
10260 << LangOpts.CPlusPlus << MagicValueExpr->getSourceRange();
10263 uint64_t MagicValue = MagicValueInt.getZExtValue();
10264 RegisterTypeTagForDatatype(
I->getArgumentKind(),
10266 I->getMatchingCType(),
10267 I->getLayoutCompatible(),
10268 I->getMustBeNull());
10280 for (
unsigned i = 0, e = Group.size(); i != e; ++i)
10281 if (
Decl *D = Group[i]) {
10283 if (!FirstDeclaratorInGroup)
10284 FirstDeclaratorInGroup = DD;
10285 Decls.push_back(D);
10290 handleTagNumbering(Tag, S);
10291 if (FirstDeclaratorInGroup && !Tag->hasNameForLinkage() &&
10292 getLangOpts().CPlusPlus)
10304 bool TypeMayContainAuto) {
10312 if (TypeMayContainAuto && Group.size() > 1) {
10315 VarDecl *DeducedDecl =
nullptr;
10316 for (
unsigned i = 0, e = Group.size(); i != e; ++i) {
10317 if (
VarDecl *D = dyn_cast<VarDecl>(Group[i])) {
10318 AutoType *AT = D->getType()->getContainedAutoType();
10327 DeducedCanon = UCanon;
10329 }
else if (DeducedCanon != UCanon) {
10330 Diag(D->getTypeSourceInfo()->getTypeLoc().getBeginLoc(),
10331 diag::err_auto_different_deductions)
10335 << DeducedDecl->
getInit()->getSourceRange()
10345 ActOnDocumentableDecls(Group);
10347 return DeclGroupPtrTy::make(
10352 ActOnDocumentableDecls(D);
10357 if (Group.empty() || !Group[0])
10360 if (Diags.isIgnored(diag::warn_doc_param_not_found,
10361 Group[0]->getLocation()) &&
10362 Diags.isIgnored(diag::warn_unknown_comment_command_name,
10363 Group[0]->getLocation()))
10366 if (Group.size() >= 2) {
10374 Decl *MaybeTagDecl = Group[0];
10375 if (MaybeTagDecl && isa<TagDecl>(MaybeTagDecl)) {
10376 Group = Group.slice(1);
10382 if (!Comments.empty() &&
10383 !Comments.back()->isAttached()) {
10391 for (
unsigned i = 0, e = Group.size(); i != e; ++i)
10407 }
else if (getLangOpts().CPlusPlus &&
10412 diag::err_invalid_storage_class_in_func_decl);
10425 DiagnoseFunctionSpecifiers(DS);
10433 CheckExtraCXXDefaultArguments(D);
10449 << GetNameForDeclarator(D).getName();
10459 if (R.isSingleResult()) {
10460 NamedDecl *PrevDecl = R.getFoundDecl();
10465 PrevDecl =
nullptr;
10484 parmDeclType, TInfo,
10498 IdResolver.AddDecl(New);
10500 ProcessDeclAttributes(S, New, D);
10508 if (New->
hasAttr<BlocksAttr>()) {
10533 if (!ActiveTemplateInstantiations.empty())
10536 for (; Param != ParamEnd; ++Param) {
10537 if (!(*Param)->isReferenced() && (*Param)->getDeclName() &&
10538 !(*Param)->hasAttr<UnusedAttr>()) {
10539 Diag((*Param)->getLocation(), diag::warn_unused_parameter)
10540 << (*Param)->getDeclName();
10549 if (LangOpts.NumLargeByValueCopy == 0)
10556 if (Size > LangOpts.NumLargeByValueCopy)
10563 for (; Param != ParamEnd; ++Param) {
10568 if (Size > LangOpts.NumLargeByValueCopy)
10569 Diag((*Param)->getLocation(), diag::warn_parameter_size)
10570 << (*Param)->getDeclName() << Size;
10579 if (getLangOpts().ObjCAutoRefCount &&
10592 NameLoc, diag::err_arc_array_param_no_ownership, T,
false));
10603 TSInfo, SC,
nullptr);
10608 if (!CurContext->isRecord() &&
10609 RequireNonAbstractType(NameLoc, T, diag::err_abstract_type_in_decl,
10610 AbstractParamType))
10618 diag::err_object_cannot_be_passed_returned_by_value) << 1 << T
10631 if (!(getLangOpts().OpenCL && T->
isArrayType())) {
10632 Diag(NameLoc, diag::err_arg_with_address_space);
10647 for (
int i = FTI.
NumParams; i != 0; ) {
10651 llvm::raw_svector_ostream(Code)
10661 const char* PrevSpec;
10670 FTI.
Params[i].
Param = ActOnParamDeclarator(S, ParamD);
10680 assert(getCurFunctionDecl() ==
nullptr &&
"Function parsing confused");
10685 Decl *DP = HandleDeclarator(ParentScope, D, TemplateParameterLists);
10686 return ActOnStartOfFunctionDef(FnBodyScope, DP, SkipBody);
10690 Consumer.HandleInlineMethodDefinition(D);
10704 if (isa<CXXMethodDecl>(FD))
10724 if (FD->
hasAttr<OpenCLKernelAttr>())
10731 bool MissingPrototype =
true;
10736 if (Prev->getLexicalDeclContext()->isFunctionOrMethod())
10739 MissingPrototype = !Prev->getType()->isFunctionProtoType();
10741 PossibleZeroParamPrototype = Prev;
10745 return MissingPrototype;
10764 if (SkipBody && !hasVisibleDefinition(Definition) &&
10771 makeMergedDefinitionVisible(TD, FD->
getLocation());
10773 makeMergedDefinitionVisible(const_cast<FunctionDecl*>(Definition),
10796 LSI->
Lambda = LambdaClass;
10814 for (
const auto &
C : LambdaClass->
captures()) {
10815 if (
C.capturesVariable()) {
10820 const bool ByRef =
C.getCaptureKind() ==
LCK_ByRef;
10822 true,
C.getLocation(),
10823 C.isPackExpansion()
10825 CaptureType,
nullptr);
10827 }
else if (
C.capturesThis()) {
10847 FD = FunTmpl->getTemplatedDecl();
10849 FD = cast<FunctionDecl>(D);
10853 CheckForFunctionRedefinition(FD,
nullptr, SkipBody);
10870 assert(ActiveTemplateInstantiations.size() &&
10871 "There should be an active template instantiation on the stack "
10872 "when instantiating a generic lambda!");
10877 PushFunctionScope();
10893 RequireCompleteType(FD->
getLocation(), ResultType,
10894 diag::err_func_def_incomplete_result))
10898 PushDeclContext(FnBodyScope, FD);
10905 for (
auto Param : FD->
params()) {
10906 Param->setOwningFunction(FD);
10909 if (Param->getIdentifier() && FnBodyScope) {
10910 CheckShadow(FnBodyScope, Param);
10912 PushOnScopeChains(Param, FnBodyScope);
10938 PushOnScopeChains(D, FnBodyScope,
false);
10942 if (
auto *ED = dyn_cast<EnumDecl>(D)) {
10943 for (
auto *EI : ED->enumerators())
10944 PushOnScopeChains(EI, FnBodyScope,
false);
10956 assert(!FD->
hasAttr<DLLExportAttr>());
10957 Diag(FD->
getLocation(), diag::err_attribute_dllimport_function_definition);
10963 ActOnDocumentableDecl(D);
10964 if (getCurLexicalContext()->isObjCContainer() &&
10965 getCurLexicalContext()->getDeclKind() != Decl::ObjCCategoryImpl &&
10966 getCurLexicalContext()->getDeclKind() != Decl::ObjCImplementation)
10987 for (
unsigned I = 0, E = Scope->
Returns.size();
I !=
E; ++
I) {
10988 if (
const VarDecl *NRVOCandidate = Returns[
I]->getNRVOCandidate()) {
10989 if (!NRVOCandidate->isNRVOVariable())
10990 Returns[
I]->setNRVOCandidate(
nullptr);
11008 Outer.Fun.hasTrailingReturnType()) {
11009 QualType Ty = GetTypeFromParser(Outer.Fun.getTrailingReturnType());
11026 if (FD->isConstexpr() || FD->getReturnType()->isUndeducedType())
11028 return Consumer.shouldSkipFunctionBody(D);
11032 if (
FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(Decl))
11033 FD->setHasSkippedBody();
11034 else if (
ObjCMethodDecl *MD = dyn_cast_or_null<ObjCMethodDecl>(Decl))
11036 return ActOnFinishFunctionBody(Decl,
nullptr);
11040 return ActOnFinishFunctionBody(D, BodyArg,
false);
11044 bool IsInstantiation) {
11050 if (getLangOpts().Coroutines && !getCurFunction()->CoroutineStmts.empty())
11051 CheckCompletedCoroutineBody(FD, Body);
11067 TypeLoc ResultType = getReturnTypeLoc(FD);
11072 auto *LSI = getCurLambda();
11073 if (LSI->HasImplicitReturnType) {
11074 deduceClosureReturnType(*LSI);
11080 LSI->ReturnType.isNull() ?
Context.
VoidTy : LSI->ReturnType;
11095 UndefinedButUsed.erase(FD);
11097 !LangOpts.GNUInline &&
11099 UndefinedButUsed.erase(FD);
11121 MarkVTableUsed(FD->
getLocation(), Constructor->getParent());
11123 MarkVTableUsed(FD->
getLocation(), Destructor->getParent());
11130 computeNRVO(Body, getCurFunction());
11138 const FunctionDecl *PossibleZeroParamPrototype =
nullptr;
11142 if (PossibleZeroParamPrototype) {
11147 TypeLoc TL = TI->getTypeLoc();
11150 diag::note_declaration_not_a_prototype)
11151 << PossibleZeroParamPrototype
11157 if (
auto *MD = dyn_cast<CXXMethodDecl>(FD)) {
11172 if (KeyFunction && KeyFunction->
isDefined(Definition))
11181 assert((FD == getCurFunctionDecl() || getCurLambda()->CallOperator == FD) &&
11182 "Function parsing confused");
11183 }
else if (
ObjCMethodDecl *MD = dyn_cast_or_null<ObjCMethodDecl>(dcl)) {
11184 assert(MD == getCurMethodDecl() &&
"Method parsing confused");
11192 computeNRVO(Body, getCurFunction());
11194 if (getCurFunction()->ObjCShouldCallSuper) {
11196 << MD->getSelector().getAsString();
11197 getCurFunction()->ObjCShouldCallSuper =
false;
11199 if (getCurFunction()->ObjCWarnForNoDesignatedInitChain) {
11201 bool isDesignated =
11202 MD->isDesignatedInitializerForTheInterface(&InitMethod);
11203 assert(isDesignated && InitMethod);
11204 (void)isDesignated;
11207 auto IFace = MD->getClassInterface();
11210 auto SuperD = IFace->getSuperClass();
11220 diag::warn_objc_designated_init_missing_super_call);
11222 diag::note_objc_designated_init_marked_here);
11224 getCurFunction()->ObjCWarnForNoDesignatedInitChain =
false;
11226 if (getCurFunction()->ObjCWarnForNoInitDelegation) {
11230 diag::warn_objc_secondary_init_missing_init_call);
11231 getCurFunction()->ObjCWarnForNoInitDelegation =
false;
11237 assert(!getCurFunction()->ObjCShouldCallSuper &&
11238 "This should only be set for ObjC methods, which should have been "
11239 "handled in the block above.");
11246 if (FD && isa<CXXConstructorDecl>(FD) && isa<CXXTryStmt>(Body))
11247 DiagnoseReturnInConstructorExceptionHandler(cast<CXXTryStmt>(Body));
11250 if (getCurFunction()->NeedsScopeChecking() &&
11251 !PP.isCodeCompletionEnabled())
11252 DiagnoseInvalidJumps(Body);
11255 if (!Destructor->getParent()->isDependentType())
11256 CheckDestructor(Destructor);
11258 MarkBaseAndMemberDestructorsReferenced(Destructor->getLocation(),
11259 Destructor->getParent());
11265 if (getDiagnostics().hasErrorOccurred() ||
11266 getDiagnostics().getSuppressAllDiagnostics()) {
11267 DiscardCleanupsInEvaluationContext();
11269 if (!getDiagnostics().hasUncompilableErrorOccurred() &&
11270 !isa<FunctionTemplateDecl>(dcl)) {
11273 ActivePolicy = &WP;
11277 (!CheckConstexprFunctionDecl(FD) ||
11278 !CheckConstexprFunctionBody(FD, Body)))
11281 if (FD && FD->
hasAttr<NakedAttr>()) {
11282 for (
const Stmt *S : Body->children()) {
11283 if (!isa<AsmStmt>(S) && !isa<NullStmt>(
S)) {
11284 Diag(S->getLocStart(), diag::err_non_asm_stmt_in_naked_function);
11285 Diag(FD->
getAttr<NakedAttr>()->getLocation(), diag::note_attribute);
11292 assert(ExprCleanupObjects.size() ==
11293 ExprEvalContexts.back().NumCleanupObjects &&
11294 "Leftover temporaries in function");
11295 assert(!ExprNeedsCleanups &&
"Unaccounted cleanups in function");
11296 assert(MaybeODRUseExprs.empty() &&
11297 "Leftover expressions for odr-use checking");
11300 if (!IsInstantiation)
11303 PopFunctionScopeInfo(ActivePolicy, dcl);
11307 if (getDiagnostics().hasErrorOccurred()) {
11308 DiscardCleanupsInEvaluationContext();
11321 D = TD->getTemplatedDecl();
11322 ProcessDeclAttributeList(S, D, Attrs.
getList());
11324 if (
CXXMethodDecl *Method = dyn_cast_or_null<CXXMethodDecl>(D))
11325 if (Method->isStatic())
11326 checkThisInStaticMemberFunctionAttributes(Method);
11338 if (
NamedDecl *ExternCPrev = findLocallyScopedExternCDecl(&II)) {
11339 Diag(Loc, diag::warn_use_out_of_scope_declaration) << ExternCPrev;
11340 Diag(ExternCPrev->getLocation(), diag::note_previous_declaration);
11341 return ExternCPrev;
11346 if (II.
getName().startswith(
"__builtin_"))
11347 diag_id = diag::warn_builtin_unknown;
11348 else if (getLangOpts().C99)
11349 diag_id = diag::ext_implicit_function_decl;
11351 diag_id = diag::warn_implicit_function_decl;
11352 Diag(Loc, diag_id) << &II;
11359 (Corrected = CorrectTypo(
11362 diagnoseTypo(Corrected, PDiag(diag::note_function_suggestion),
11374 assert(!Error &&
"Error setting up implicit decl!");
11408 FunctionDecl *FD = cast<FunctionDecl>(ActOnDeclarator(TUScope, D));
11411 CurContext = PrevDC;
11413 AddKnownFunctionAttributes(FD);
11435 unsigned FormatIdx;
11438 if (!FD->
hasAttr<FormatAttr>()) {
11439 const char *fmt =
"printf";
11441 if (FormatIdx < NumParams &&
11447 HasVAListArg ? 0 : FormatIdx+2,
11453 if (!FD->
hasAttr<FormatAttr>())
11457 HasVAListArg ? 0 : FormatIdx+2,
11464 if (!getLangOpts().MathErrno &&
11466 if (!FD->
hasAttr<ConstAttr>())
11471 !FD->
hasAttr<ReturnsTwiceAttr>())
11478 if (getLangOpts().CUDA && getLangOpts().CUDATargetOverloads &&
11480 !FD->
hasAttr<CUDADeviceAttr>() && !FD->
hasAttr<CUDAHostAttr>()) {
11484 if (getLangOpts().CUDAIsDevice !=
11505 if (Name->
isStr(
"asprintf") || Name->
isStr(
"vasprintf")) {
11508 if (!FD->
hasAttr<FormatAttr>())
11511 Name->
isStr(
"vasprintf") ? 0 : 3,
11515 if (Name->
isStr(
"__CFStringMakeConstantString")) {
11518 if (!FD->
hasAttr<FormatArgAttr>())
11526 assert(D.
getIdentifier() &&
"Wrong callback for declspec without declarator");
11527 assert(!T.
isNull() &&
"GetTypeForDeclarator() returned null type");
11530 assert(D.
isInvalidType() &&
"no declarator info for valid type");
11548 if (CurContext->isFunctionOrMethod())
11570 setTagNameForLinkagePurposes(tagFromDeclSpec, NewTD);
11591 if (BT->isInteger())
11594 Diag(UnderlyingLoc, diag::err_enum_invalid_underlying) << T;
11602 bool EnumUnderlyingIsImplicit,
const EnumDecl *Prev) {
11603 bool IsFixed = !EnumUnderlyingTy.
isNull();
11605 if (IsScoped != Prev->
isScoped()) {
11606 Diag(EnumLoc, diag::err_enum_redeclare_scoped_mismatch)
11612 if (IsFixed && Prev->
isFixed()) {
11618 Diag(EnumLoc, diag::err_enum_redeclare_type_mismatch)
11624 }
else if (IsFixed && !Prev->
isFixed() && EnumUnderlyingIsImplicit) {
11628 }
else if (IsFixed != Prev->
isFixed()) {
11629 Diag(EnumLoc, diag::err_enum_redeclare_fixed_mismatch)
11648 default: llvm_unreachable(
"Invalid tag kind for redecl diagnostic!");
11684 if (OldTag == NewTag)
11690 if (
const CXXRecordDecl *Record = dyn_cast<CXXRecordDecl>(Previous))
11691 isTemplate = Record->getDescribedClassTemplate();
11693 if (!ActiveTemplateInstantiations.empty()) {
11696 Diag(NewTagLoc, diag::warn_struct_class_tag_mismatch)
11702 if (isDefinition) {
11710 bool previousMismatch =
false;
11711 for (
auto I : Previous->
redecls()) {
11712 if (
I->getTagKind() != NewTag) {
11713 if (!previousMismatch) {
11714 previousMismatch =
true;
11715 Diag(NewTagLoc, diag::warn_struct_class_previous_tag_mismatch)
11719 Diag(
I->getInnerLocStart(), diag::note_struct_class_suggestion)
11737 Diag(NewTagLoc, diag::warn_struct_class_tag_mismatch)
11744 Diag(NewTagLoc, diag::note_struct_class_suggestion)
11778 Namespaces.push_back(II);
11781 if (Lookup == Namespace)
11788 llvm::raw_svector_ostream OS(Insertion);
11791 std::reverse(Namespaces.begin(), Namespaces.end());
11792 for (
auto *II : Namespaces)
11793 OS << II->getName() <<
"::";
11806 if (OldDC->
Equals(NewDC))
11832 (LangOpts.CPlusPlus &&
11856 bool &OwnedDecl,
bool &IsDependent,
11858 bool ScopedEnumUsesClassTag,
11863 assert((Name !=
nullptr || TUK == TUK_Definition) &&
11864 "Nameless record must be a definition!");
11865 assert(TemplateParameterLists.size() == 0 || TUK != TUK_Reference);
11869 bool ScopedEnum = ScopedEnumKWLoc.
isValid();
11872 bool isExplicitSpecialization =
false;
11873 bool Invalid =
false;
11878 if (TemplateParameterLists.size() > 0 ||
11879 (SS.
isNotEmpty() && TUK != TUK_Reference)) {
11881 MatchTemplateParametersToScopeSpecifier(
11882 KWLoc, NameLoc, SS,
nullptr, TemplateParameterLists,
11883 TUK == TUK_Friend, isExplicitSpecialization, Invalid)) {
11885 Diag(KWLoc, diag::err_enum_template);
11889 if (TemplateParams->size() > 0) {
11898 SS, Name, NameLoc, Attr,
11899 TemplateParams, AS,
11902 TemplateParameterLists.size()-1,
11903 TemplateParameterLists.data(),
11905 return Result.
get();
11908 Diag(TemplateParams->getTemplateLoc(), diag::err_template_tag_noparams)
11910 isExplicitSpecialization =
true;
11918 llvm::PointerUnion<const Type*, TypeSourceInfo*> EnumUnderlying;
11919 bool EnumUnderlyingIsImplicit =
false;
11922 if (UnderlyingType.
isInvalid() || (!UnderlyingType.
get() && ScopedEnum))
11926 else if (UnderlyingType.
get()) {
11930 GetTypeFromParser(UnderlyingType.
get(), &TI);
11931 EnumUnderlying = TI;
11933 if (CheckEnumUnderlyingType(TI))
11938 UPPC_FixedUnderlyingType))
11942 if (getLangOpts().MSVCCompat || TUK == TUK_Definition) {
11945 EnumUnderlyingIsImplicit =
true;
11952 bool isStdBadAlloc =
false;
11955 if (TUK == TUK_Friend || TUK == TUK_Reference)
11956 Redecl = NotForRedeclaration;
11965 goto CreateNewDecl;
11970 if (TUK == TUK_Friend || TUK == TUK_Reference) {
11971 DC = computeDeclContext(SS,
false);
11973 IsDependent =
true;
11977 DC = computeDeclContext(SS,
true);
11985 if (RequireCompleteDeclContext(SS, DC))
11990 LookupQualifiedName(Previous, DC);
11995 if (Previous.
empty()) {
12003 (TUK == TUK_Reference || TUK == TUK_Friend)) {
12004 IsDependent =
true;
12009 Diag(NameLoc, diag::err_not_tag_in_scope)
12010 << Kind << Name << DC << SS.
getRange();
12013 goto CreateNewDecl;
12020 if (TUK != TUK_Reference && TUK != TUK_Friend &&
12029 LookupName(Previous, S);
12034 (TUK == TUK_Definition || TUK == TUK_Declaration)) {
12057 if (!Previous.
empty() && TUK == TUK_Friend) {
12060 bool FriendSawTagOutsideEnclosingNamespace =
false;
12066 if (getLangOpts().MSVCCompat)
12067 FriendSawTagOutsideEnclosingNamespace =
true;
12076 if (Previous.
isSingleResult() && FriendSawTagOutsideEnclosingNamespace) {
12078 Diag(NameLoc, diag::ext_friend_tag_redecl_outside_namespace)
12087 if (!getLangOpts().CPlusPlus && TUK != TUK_Reference) {
12092 while (isa<RecordDecl>(SearchDC) || isa<EnumDecl>(SearchDC))
12100 DiagnoseTemplateParameterShadow(NameLoc, Previous.
getFoundDecl());
12105 if (getLangOpts().
CPlusPlus && Name && DC && StdNamespace &&
12106 DC->
Equals(getStdNamespace()) && Name->
isStr(
"bad_alloc")) {
12108 isStdBadAlloc =
true;
12110 if (Previous.
empty() && StdBadAlloc) {
12114 Previous.
addDecl(getStdBadAlloc());
12122 if (Name && Previous.
empty() &&
12123 (TUK == TUK_Reference || TUK == TUK_Friend)) {
12124 if (Invalid)
goto CreateNewDecl;
12127 if (TUK == TUK_Reference) {
12161 assert(TUK == TUK_Friend);
12177 LookupQualifiedName(Previous, SearchDC);
12180 LookupName(Previous, S);
12188 if (!Previous.
empty()) {
12204 TagDecl *Tag = TT->getDecl();
12207 ->
Equals(TD->getDeclContext()->getRedeclContext())) {
12220 if (
auto *Shadow = dyn_cast<UsingShadowDecl>(DirectPrevDecl)) {
12221 auto *OldTag = dyn_cast<
TagDecl>(PrevDecl);
12222 if (SS.
isEmpty() && TUK != TUK_Reference && TUK != TUK_Friend &&
12223 isDeclInScope(Shadow, SearchDC, S, isExplicitSpecialization) &&
12225 *
this, OldTag->getDeclContext(), SearchDC))) {
12226 Diag(KWLoc, diag::err_using_decl_conflict_reverse);
12227 Diag(Shadow->getTargetDecl()->getLocation(),
12228 diag::note_using_decl_target);
12229 Diag(Shadow->getUsingDecl()->getLocation(), diag::note_using_decl)
12233 goto CreateNewDecl;
12237 if (
TagDecl *PrevTagDecl = dyn_cast<TagDecl>(PrevDecl)) {
12241 if (TUK == TUK_Reference || TUK == TUK_Friend ||
12242 isDeclInScope(DirectPrevDecl, SearchDC, S,
12243 SS.
isNotEmpty() || isExplicitSpecialization)) {
12246 if (!isAcceptableTagRedeclaration(PrevTagDecl, Kind,
12247 TUK == TUK_Definition, KWLoc,
12249 bool SafeToContinue
12250 = (PrevTagDecl->getTagKind() !=
TTK_Enum &&
12252 if (SafeToContinue)
12253 Diag(KWLoc, diag::err_use_with_wrong_tag)
12256 PrevTagDecl->getKindName());
12258 Diag(KWLoc, diag::err_use_with_wrong_tag) <<
Name;
12259 Diag(PrevTagDecl->getLocation(), diag::note_previous_use);
12261 if (SafeToContinue)
12262 Kind = PrevTagDecl->getTagKind();
12272 const EnumDecl *PrevEnum = cast<EnumDecl>(PrevTagDecl);
12276 if (TUK == TUK_Reference || TUK == TUK_Friend) {
12278 Diag(ScopedEnumKWLoc, diag::err_enum_class_reference)
12281 return PrevTagDecl;
12286 EnumUnderlyingTy = TI->getType().getUnqualifiedType();
12287 else if (
const Type *T = EnumUnderlying.dyn_cast<
const Type*>())
12288 EnumUnderlyingTy =
QualType(T, 0);
12293 if (CheckEnumRedeclaration(NameLoc.
isValid() ? NameLoc : KWLoc,
12294 ScopedEnum, EnumUnderlyingTy,
12295 EnumUnderlyingIsImplicit, PrevEnum))
12296 return TUK == TUK_Declaration ? PrevTagDecl :
nullptr;
12305 Diag(NameLoc, diag::ext_member_redeclared);
12306 Diag(PrevTagDecl->getLocation(), diag::note_previous_declaration);
12312 if (TUK == TUK_Reference || TUK == TUK_Friend) {
12316 }
else if (TUK == TUK_Reference &&
12317 (PrevTagDecl->getFriendObjectKind() ==
12319 PP.getModuleContainingLocation(
12321 PP.getModuleContainingLocation(KWLoc)) &&
12332 return PrevTagDecl;
12337 return PrevTagDecl;
12342 if (TUK == TUK_Definition) {
12343 if (
NamedDecl *Def = PrevTagDecl->getDefinition()) {
12347 bool IsExplicitSpecializationAfterInstantiation =
false;
12348 if (isExplicitSpecialization) {
12350 IsExplicitSpecializationAfterInstantiation =
12351 RD->getTemplateSpecializationKind() !=
12353 else if (
EnumDecl *ED = dyn_cast<EnumDecl>(Def))
12354 IsExplicitSpecializationAfterInstantiation =
12355 ED->getTemplateSpecializationKind() !=
12360 if (SkipBody && getLangOpts().
CPlusPlus &&
12361 !hasVisibleDefinition(Def, &Hidden)) {
12368 makeMergedDefinitionVisible(Hidden, KWLoc);
12370 }
else if (!IsExplicitSpecializationAfterInstantiation) {
12374 Diag(NameLoc, diag::warn_redefinition_in_param_list) <<
Name;
12376 Diag(NameLoc, diag::err_redefinition) <<
Name;
12377 Diag(Def->getLocation(), diag::note_previous_definition);
12389 if (TD->isBeingDefined()) {
12390 Diag(NameLoc, diag::err_nested_redefinition) <<
Name;
12391 Diag(PrevTagDecl->getLocation(),
12392 diag::note_previous_definition);
12406 if (TUK == TUK_Friend || TUK == TUK_Reference) {
12407 SearchDC = PrevTagDecl->getDeclContext();
12433 if ((TUK == TUK_Reference || TUK == TUK_Friend) &&
12436 if (isa<TypedefDecl>(PrevDecl)) Kind = 1;
12437 else if (isa<TypeAliasDecl>(PrevDecl)) Kind = 2;
12438 else if (isa<ClassTemplateDecl>(PrevDecl)) Kind = 3;
12439 Diag(NameLoc, diag::err_tag_reference_non_tag) <<
Kind;
12444 }
else if (!isDeclInScope(DirectPrevDecl, SearchDC, S,
12445 SS.
isNotEmpty() || isExplicitSpecialization)) {
12449 }
else if (TUK == TUK_Reference || TUK == TUK_Friend) {
12451 if (isa<TypedefDecl>(PrevDecl)) Kind = 1;
12452 else if (isa<TypeAliasDecl>(PrevDecl)) Kind = 2;
12453 else if (isa<ClassTemplateDecl>(PrevDecl)) Kind = 3;
12454 Diag(NameLoc, diag::err_tag_reference_conflict) <<
Kind;
12460 }
else if (
TypedefNameDecl *TND = dyn_cast<TypedefNameDecl>(PrevDecl)) {
12462 if (isa<TypeAliasDecl>(PrevDecl)) Kind = 1;
12463 Diag(NameLoc, diag::err_tag_definition_of_typedef)
12464 << Name << Kind << TND->getUnderlyingType();
12472 Diag(NameLoc, diag::err_redefinition_different_kind) <<
Name;
12500 bool IsForwardReference =
false;
12505 cast_or_null<EnumDecl>(PrevDecl), ScopedEnum,
12506 ScopedEnumUsesClassTag, !EnumUnderlying.isNull());
12508 if (TUK != TUK_Definition && !Invalid) {
12510 if ((getLangOpts().
CPlusPlus11 || getLangOpts().ObjC2) &&
12511 cast<EnumDecl>(New)->isFixed()) {
12515 else if (PrevDecl && (Def = cast<EnumDecl>(PrevDecl)->
getDefinition())) {
12516 Diag(Loc, diag::ext_forward_ref_enum_def)
12520 unsigned DiagID = diag::ext_forward_ref_enum;
12521 if (getLangOpts().MSVCCompat)
12522 DiagID = diag::ext_ms_forward_ref_enum;
12523 else if (getLangOpts().CPlusPlus)
12524 DiagID = diag::err_forward_ref_enum;
12530 if (TUK == TUK_Reference)
12531 IsForwardReference =
true;
12535 if (EnumUnderlying) {
12536 EnumDecl *ED = cast<EnumDecl>(New);
12549 if (getLangOpts().CPlusPlus) {
12552 cast_or_null<CXXRecordDecl>(PrevDecl));
12554 if (isStdBadAlloc && (!StdBadAlloc || getStdBadAlloc()->isImplicit()))
12555 StdBadAlloc = cast<CXXRecordDecl>(New);
12558 cast_or_null<RecordDecl>(PrevDecl));
12563 if (getLangOpts().
CPlusPlus && IsTypeSpecifier && TUK == TUK_Definition) {
12577 if (!isExplicitSpecialization &&
12578 (TUK == TUK_Definition || TUK == TUK_Declaration) &&
12579 diagnoseQualifiedDeclaration(SS, DC, OrigName, Loc))
12583 if (TemplateParameterLists.size() > 0) {
12591 if (
RecordDecl *RD = dyn_cast<RecordDecl>(New)) {
12601 if (TUK == TUK_Definition) {
12602 AddAlignmentAttributesForRecord(RD);
12603 AddMsStructLayoutForRecord(RD);
12607 if (ModulePrivateLoc.
isValid()) {
12608 if (isExplicitSpecialization)
12621 if (isExplicitSpecialization && CheckMemberSpecialization(New, Previous))
12628 getNonFieldDeclScope(S)->isFunctionPrototypeScope()) {
12632 if (TUK == TUK_Definition && !IsTypeSpecifier) {
12633 Diag(Loc, diag::err_type_defined_in_param_type)
12637 }
else if (!PrevDecl) {
12640 DeclsInPrototypeScope.push_back(New);
12647 ProcessDeclAttributeList(S, New, Attr);
12657 if (TUK == TUK_Friend)
12661 if (!Invalid && SearchDC->
isRecord())
12662 SetMemberAccessSpecifier(New, PrevDecl, AS);
12664 if (TUK == TUK_Definition)
12668 if (TUK == TUK_Friend) {
12677 if (
Scope *EnclosingScope = getScopeForDeclContext(S, DC))
12678 PushOnScopeChains(New, EnclosingScope,
false);
12680 S = getNonFieldDeclScope(S);
12681 PushOnScopeChains(New, S, !IsForwardReference);
12682 if (IsForwardReference)
12686 CurContext->addDecl(New);
12697 mergeDeclAttributes(New, PrevDecl);
12701 AddPushedVisibilityAttribute(New);
12706 return (Invalid && getLangOpts().
CPlusPlus) ?
nullptr : New;
12710 AdjustDeclIfTemplate(TagD);
12711 TagDecl *Tag = cast<TagDecl>(TagD);
12714 PushDeclContext(S, Tag);
12716 ActOnDocumentableDecl(TagD);
12720 AddPushedVisibilityAttribute(Tag);
12724 assert(isa<ObjCContainerDecl>(IDecl) &&
12725 "ActOnObjCContainerStartDefinition - Not ObjCContainerDecl");
12727 assert(getContainingDC(OCD) == CurContext &&
12728 "The next DeclContext should be lexically contained in the current one.");
12735 bool IsFinalSpelledSealed,
12737 AdjustDeclIfTemplate(TagD);
12740 FieldCollector->StartClass();
12747 FinalAttr(FinalLoc,
Context, IsFinalSpelledSealed));
12765 PushOnScopeChains(InjectedClassName, S);
12767 "Broken injected-class-name");
12772 AdjustDeclIfTemplate(TagD);
12773 TagDecl *Tag = cast<TagDecl>(TagD);
12778 assert(Tag->
isInvalidDecl() &&
"We should already have completed it");
12779 if (
RecordDecl *RD = dyn_cast<RecordDecl>(Tag))
12780 RD->completeDefinition();
12783 if (isa<CXXRecordDecl>(Tag))
12784 FieldCollector->FinishClass();
12789 if (getCurLexicalContext()->isObjCContainer() &&
12795 Consumer.HandleTagDeclDefinition(Tag);
12804 assert(DC == CurContext &&
"Mismatch of container contexts");
12805 OriginalLexicalContext = DC;
12806 ActOnObjCContainerFinishDefinition();
12810 ActOnObjCContainerStartDefinition(cast<Decl>(DC));
12811 OriginalLexicalContext =
nullptr;
12815 AdjustDeclIfTemplate(TagD);
12816 TagDecl *Tag = cast<TagDecl>(TagD);
12821 if (
RecordDecl *RD = dyn_cast<RecordDecl>(Tag))
12822 RD->completeDefinition();
12835 QualType FieldTy,
bool IsMsStruct,
12836 Expr *BitWidth,
bool *ZeroWidth) {
12845 if (RequireCompleteType(FieldLoc, FieldTy, diag::err_field_incomplete))
12848 return Diag(FieldLoc, diag::err_not_integral_type_bitfield)
12849 << FieldName << FieldTy << BitWidth->getSourceRange();
12850 return Diag(FieldLoc, diag::err_not_integral_type_anon_bitfield)
12851 << FieldTy << BitWidth->getSourceRange();
12852 }
else if (DiagnoseUnexpandedParameterPack(const_cast<Expr *>(BitWidth),
12853 UPPC_BitFieldWidth))
12861 llvm::APSInt
Value;
12862 ExprResult ICE = VerifyIntegerConstantExpression(BitWidth, &Value);
12865 BitWidth = ICE.
get();
12867 if (Value != 0 && ZeroWidth)
12868 *ZeroWidth =
false;
12871 if (Value == 0 && FieldName)
12872 return Diag(FieldLoc, diag::err_bitfield_has_zero_width) << FieldName;
12874 if (Value.isSigned() && Value.isNegative()) {
12876 return Diag(FieldLoc, diag::err_bitfield_has_negative_width)
12877 << FieldName << Value.toString(10);
12878 return Diag(FieldLoc, diag::err_anon_bitfield_has_negative_width)
12879 << Value.toString(10);
12885 bool BitfieldIsOverwide = Value.ugt(TypeWidth);
12889 bool CStdConstraintViolation =
12890 BitfieldIsOverwide && !getLangOpts().CPlusPlus;
12891 bool MSBitfieldViolation =
12892 Value.ugt(TypeStorageSize) &&
12894 if (CStdConstraintViolation || MSBitfieldViolation) {
12895 unsigned DiagWidth =
12896 CStdConstraintViolation ? TypeWidth : TypeStorageSize;
12898 return Diag(FieldLoc, diag::err_bitfield_width_exceeds_type_width)
12899 << FieldName << (
unsigned)Value.getZExtValue()
12900 << !CStdConstraintViolation << DiagWidth;
12902 return Diag(FieldLoc, diag::err_anon_bitfield_width_exceeds_type_width)
12903 << (
unsigned)Value.getZExtValue() << !CStdConstraintViolation
12912 Diag(FieldLoc, diag::warn_bitfield_width_exceeds_type_width)
12913 << FieldName << (
unsigned)Value.getZExtValue()
12916 Diag(FieldLoc, diag::warn_anon_bitfield_width_exceeds_type_width)
12928 FieldDecl *Res = HandleField(S, cast_or_null<RecordDecl>(TagD),
12929 DeclStart, D, static_cast<Expr*>(BitfieldWidth),
12948 CheckExtraCXXDefaultArguments(D);
12951 UPPC_DataMemberType)) {
12960 Diag(Loc, diag::err_field_with_address_space);
12966 if (LangOpts.OpenCL && T->
isEventT()) {
12967 Diag(Loc, diag::err_event_t_struct_field);
12975 diag::err_invalid_thread)
12981 LookupName(Previous, S);
13003 PrevDecl =
nullptr;
13006 if (PrevDecl && !isDeclInScope(PrevDecl, Record, S))
13007 PrevDecl =
nullptr;
13013 = CheckFieldDecl(II, T, TInfo, Record, Loc, Mutable, BitWidth, InitStyle,
13014 TSSL, AS, PrevDecl, &D);
13026 PushOnScopeChains(NewFD, S);
13046 bool Mutable,
Expr *BitWidth,
13052 bool InvalidDecl =
false;
13058 InvalidDecl =
true;
13064 if (RequireCompleteType(Loc, EltTy, diag::err_field_incomplete)) {
13067 InvalidDecl =
true;
13073 InvalidDecl =
true;
13079 if (BitWidth && getLangOpts().OpenCL) {
13080 Diag(Loc, diag::err_opencl_bitfields);
13081 InvalidDecl =
true;
13087 bool SizeIsNegative;
13088 llvm::APSInt Oversized;
13095 Diag(Loc, diag::warn_illegal_constant_array_size);
13096 TInfo = FixedTInfo;
13099 if (SizeIsNegative)
13100 Diag(Loc, diag::err_typecheck_negative_array_size);
13101 else if (Oversized.getBoolValue())
13102 Diag(Loc, diag::err_array_too_large)
13103 << Oversized.toString(10);
13105 Diag(Loc, diag::err_typecheck_field_variable_size);
13106 InvalidDecl =
true;
13111 if (!InvalidDecl && RequireNonAbstractType(Loc, T,
13112 diag::err_abstract_type_in_decl,
13113 AbstractFieldType))
13114 InvalidDecl =
true;
13116 bool ZeroWidth =
false;
13118 BitWidth =
nullptr;
13124 InvalidDecl =
true;
13125 BitWidth =
nullptr;
13131 if (!InvalidDecl && Mutable) {
13132 unsigned DiagID = 0;
13134 DiagID = getLangOpts().MSVCCompat ? diag::ext_mutable_reference
13135 : diag::err_mutable_reference;
13137 DiagID = diag::err_mutable_const;
13143 Diag(ErrLoc, DiagID);
13144 if (DiagID != diag::ext_mutable_reference) {
13146 InvalidDecl =
true;
13158 BitWidth, Mutable, InitStyle);
13162 if (PrevDecl && !isa<TagDecl>(PrevDecl)) {
13163 Diag(Loc, diag::err_duplicate_member) << II;
13168 if (!InvalidDecl && getLangOpts().
CPlusPlus) {
13178 if (CheckNontrivialField(NewFD))
13188 diag::ext_union_member_of_reference_type :
13189 diag::err_union_member_of_reference_type)
13191 if (!getLangOpts().MicrosoftExt)
13201 ProcessDeclAttributes(getCurScope(), NewFD, *D);
13204 CheckAlignasUnderalignment(NewFD);
13209 if (getLangOpts().ObjCAutoRefCount && inferObjCARCLifetime(NewFD))
13213 Diag(Loc, diag::warn_attribute_weak_on_field);
13221 assert(getLangOpts().
CPlusPlus &&
"valid check only for C++");
13241 member = CXXCopyConstructor;
13243 member = CXXDefaultConstructor;
13245 member = CXXCopyAssignment;
13247 member = CXXDestructor;
13249 if (member != CXXInvalid) {
13250 if (!getLangOpts().CPlusPlus11 &&
13258 if (getSourceManager().isInSystemHeader(Loc)) {
13259 if (!FD->
hasAttr<UnavailableAttr>())
13261 UnavailableAttr::IR_ARCFieldWithOwnership, Loc));
13267 diag::warn_cxx98_compat_nontrivial_union_or_anon_struct_member :
13268 diag::err_illegal_union_or_anon_struct_member)
13270 DiagnoseNontrivial(RDecl, member);
13271 return !getLangOpts().CPlusPlus11;
13283 switch (ivarVisibility) {
13284 default: llvm_unreachable(
"Unknown visitibility kind");
13300 Expr *BitWidth = (
Expr*)BitfieldWidth;
13312 BitWidth = VerifyBitField(Loc, II, T,
false, BitWidth).get();
13322 Diag(Loc, diag::err_ivar_reference_type);
13328 Diag(Loc, diag::err_typecheck_ivar_variable_size);
13342 dyn_cast<ObjCImplementationDecl>(EnclosingDecl)) {
13343 if (LangOpts.ObjCRuntime.isFragile()) {
13345 EnclosingContext = IMPDecl->getClassInterface();
13346 assert(EnclosingContext &&
"Implementation has no class interface!");
13349 EnclosingContext = EnclosingDecl;
13352 dyn_cast<ObjCCategoryDecl>(EnclosingDecl)) {
13353 if (LangOpts.ObjCRuntime.isFragile() || !CDecl->IsClassExtension()) {
13354 Diag(Loc, diag::err_misplaced_ivar) << CDecl->IsClassExtension();
13358 EnclosingContext = EnclosingDecl;
13363 DeclStart, Loc, II, T,
13364 TInfo, ac, (
Expr *)BitfieldWidth);
13367 NamedDecl *PrevDecl = LookupSingleName(S, II, Loc, LookupMemberName,
13369 if (PrevDecl && isDeclInScope(PrevDecl, EnclosingContext, S)
13370 && !isa<TagDecl>(PrevDecl)) {
13371 Diag(Loc, diag::err_duplicate_member) << II;
13378 ProcessDeclAttributes(S, NewID, D);
13384 if (getLangOpts().ObjCAutoRefCount && inferObjCARCLifetime(NewID))
13394 IdResolver.AddDecl(NewID);
13397 if (LangOpts.ObjCRuntime.isNonFragile() &&
13398 !NewID->
isInvalidDecl() && isa<ObjCInterfaceDecl>(EnclosingDecl))
13399 Diag(Loc, diag::warn_ivars_in_interface);
13410 if (LangOpts.ObjCRuntime.isFragile() || AllIvarDecls.empty())
13413 Decl *ivarDecl = AllIvarDecls[AllIvarDecls.size()-1];
13421 if (!CD->IsClassExtension())
13433 DeclLoc, DeclLoc,
nullptr,
13439 AllIvarDecls.push_back(Ivar);
13445 assert(EnclosingDecl &&
"missing record or interface decl");
13450 if (!Fields.empty() && isa<ObjCContainerDecl>(EnclosingDecl)) {
13454 case Decl::ObjCCategory:
13457 case Decl::ObjCImplementation:
13459 ResetObjCLayout(cast<ObjCImplementationDecl>(DC)->getClassInterface());
13468 unsigned NumNamedMembers = 0;
13470 for (
const auto *
I : Record->
decls()) {
13471 if (
const auto *IFD = dyn_cast<IndirectFieldDecl>(
I))
13472 if (IFD->getDeclName())
13480 bool ARCErrReported =
false;
13490 RecFields.push_back(FD);
13518 ((i + 1 == Fields.end() && !Record->
isUnion()) ||
13519 ((getLangOpts().MicrosoftExt ||
13521 (i + 1 == Fields.end() || Record->
isUnion())))) {
13526 unsigned DiagID = 0;
13528 DiagID = getLangOpts().MicrosoftExt
13529 ? diag::ext_flexible_array_union_ms
13530 : getLangOpts().CPlusPlus
13531 ? diag::ext_flexible_array_union_gnu
13532 : diag::err_flexible_array_union;
13533 else if (Fields.size() == 1)
13534 DiagID = getLangOpts().MicrosoftExt
13535 ? diag::ext_flexible_array_empty_aggregate_ms
13536 : getLangOpts().CPlusPlus
13537 ? diag::ext_flexible_array_empty_aggregate_gnu
13538 : NumNamedMembers < 1
13539 ? diag::err_flexible_array_empty_aggregate
13551 if (RD->getNumVBases() != 0)
13554 if (!getLangOpts().
C99)
13565 Diag(FD->
getLocation(), diag::err_flexible_array_has_nontrivial_dtor)
13575 diag::err_field_incomplete)) {
13589 if (i + 1 != Fields.end())
13600 if (isa<ObjCContainerDecl>(EnclosingDecl) &&
13602 diag::err_abstract_type_in_decl,
13603 AbstractIvarType)) {
13617 }
else if (getLangOpts().ObjCAutoRefCount && Record && !ARCErrReported &&
13628 if (getSourceManager().isInSystemHeader(loc)) {
13629 if (!FD->
hasAttr<UnavailableAttr>()) {
13631 UnavailableAttr::IR_ARCFieldWithOwnership, loc));
13637 ARCErrReported =
true;
13639 }
else if (getLangOpts().ObjC1 &&
13664 bool Completed =
false;
13665 if (
CXXRecordDecl *CXXRecord = dyn_cast<CXXRecordDecl>(Record)) {
13666 if (!CXXRecord->isInvalidDecl()) {
13669 I = CXXRecord->conversion_begin(),
13670 E = CXXRecord->conversion_end();
I !=
E; ++
I)
13671 I.setAccess((*I)->getAccess());
13673 if (!CXXRecord->isDependentType()) {
13674 if (CXXRecord->hasUserDeclaredDestructor()) {
13676 if (getLangOpts().CPlusPlus11)
13677 AdjustDestructorExceptionSpec(CXXRecord,
13678 CXXRecord->getDestructor());
13682 AddImplicitlyDeclaredMembersToClass(CXXRecord);
13687 if (CXXRecord->getNumVBases()) {
13689 CXXRecord->getFinalOverriders(FinalOverriders);
13692 MEnd = FinalOverriders.end();
13695 SOEnd = M->second.end();
13696 SO != SOEnd; ++SO) {
13697 assert(SO->second.size() > 0 &&
13698 "Virtual function without overridding functions?");
13699 if (SO->second.size() == 1)
13707 << (
const NamedDecl *)M->first << Record;
13708 Diag(M->first->getLocation(),
13709 diag::note_overridden_virtual_function);
13711 OM = SO->second.begin(),
13712 OMEnd = SO->second.end();
13714 Diag(OM->Method->getLocation(), diag::note_final_overrider)
13715 << (
const NamedDecl *)M->first << OM->Method->getParent();
13720 CXXRecord->completeDefinition(&FinalOverriders);
13731 CheckAlignasUnderalignment(Record);
13733 if (
const MSInheritanceAttr *IA = Record->
getAttr<MSInheritanceAttr>())
13734 checkMSInheritanceAttrOnDefinition(cast<CXXRecordDecl>(Record),
13735 IA->getRange(), IA->getBestCase(),
13736 IA->getSemanticSpelling());
13742 bool CheckForZeroSize;
13743 if (!getLangOpts().CPlusPlus) {
13744 CheckForZeroSize =
true;
13753 if (CheckForZeroSize) {
13754 bool ZeroSize =
true;
13755 bool IsEmpty =
true;
13756 unsigned NonBitFields = 0;
13759 (NonBitFields == 0 || ZeroSize) &&
I != E; ++
I) {
13761 if (
I->isUnnamedBitfield()) {
13762 if (
I->getBitWidthValue(
Context) > 0)
13778 diag::warn_zero_size_struct_union_in_extern_c :
13779 diag::warn_zero_size_struct_union_compat)
13780 << IsEmpty << Record->
isUnion() << (NonBitFields > 1);
13785 if (NonBitFields == 0 && !getLangOpts().CPlusPlus) {
13786 Diag(RecLoc, IsEmpty ? diag::ext_empty_struct_union :
13787 diag::ext_no_named_members_in_struct_union)
13795 ID->setEndOfDefinitionLoc(RBrac);
13797 for (
unsigned i = 0, e = RecFields.size(); i != e; ++i) {
13799 ID->addDecl(ClsFields[i]);
13803 if (
ID->getSuperClass())
13804 DiagnoseDuplicateIvars(
ID,
ID->getSuperClass());
13806 dyn_cast<ObjCImplementationDecl>(EnclosingDecl)) {
13807 assert(IMPDecl &&
"ActOnFields - missing ObjCImplementationDecl");
13808 for (
unsigned I = 0, N = RecFields.size();
I != N; ++
I)
13811 ClsFields[
I]->setLexicalDeclContext(IMPDecl);
13812 CheckImplementationIvars(IMPDecl, ClsFields, RecFields.size(), RBrac);
13813 IMPDecl->setIvarLBraceLoc(LBrac);
13814 IMPDecl->setIvarRBraceLoc(RBrac);
13816 dyn_cast<ObjCCategoryDecl>(EnclosingDecl)) {
13824 for (
unsigned i = 0, e = RecFields.size(); i != e; ++i) {
13828 Diag(ClsFields[i]->getLocation(),
13829 diag::err_duplicate_ivar_declaration);
13830 Diag(ClsIvar->getLocation(), diag::note_previous_definition);
13836 Diag(ClsFields[i]->getLocation(),
13837 diag::err_duplicate_ivar_declaration);
13838 Diag(ClsExtIvar->getLocation(), diag::note_previous_definition);
13844 CDecl->addDecl(ClsFields[i]);
13846 CDecl->setIvarLBraceLoc(LBrac);
13847 CDecl->setIvarRBraceLoc(RBrac);
13852 ProcessDeclAttributeList(S, Record, Attr);
13858 llvm::APSInt &
Value,
13860 assert(T->
isIntegralType(Context) &&
"Integral type required!");
13863 if (Value.isUnsigned() || Value.isNonNegative()) {
13866 return Value.getActiveBits() <= BitWidth;
13868 return Value.getMinSignedBits() <= BitWidth;
13876 assert(T->
isIntegralType(Context) &&
"Integral type required!");
13877 const unsigned NumTypes = 4;
13878 QualType SignedIntegralTypes[NumTypes] = {
13881 QualType UnsignedIntegralTypes[NumTypes] = {
13888 : UnsignedIntegralTypes;
13889 for (
unsigned I = 0;
I != NumTypes; ++
I)
13902 llvm::APSInt EnumVal(IntWidth);
13905 if (Val && DiagnoseUnexpandedParameterPack(Val, UPPC_EnumeratorValue))
13909 Val = DefaultLvalueConversion(Val).get();
13916 if (getLangOpts().CPlusPlus11 && Enum->
isFixed() &&
13917 !getLangOpts().MSVCCompat) {
13928 Val = Converted.
get();
13930 !(Val = VerifyIntegerConstantExpression(Val,
13931 &EnumVal).get())) {
13942 if (getLangOpts().MSVCCompat) {
13943 Diag(IdLoc, diag::ext_enumerator_too_large) << EltTy;
13946 Diag(IdLoc, diag::err_enumerator_too_large) << EltTy;
13964 Diag(IdLoc, diag::ext_enum_value_not_int)
13965 << EnumVal.toString(10) << Val->getSourceRange()
13966 << (EnumVal.isUnsigned() || EnumVal.isNonNegative());
13978 if (Enum->isDependentType())
13980 else if (!LastEnumConst) {
13989 if (Enum->isFixed()) {
13990 EltTy = Enum->getIntegerType();
13997 EnumVal = LastEnumConst->getInitVal();
13999 EltTy = LastEnumConst->getType();
14002 if (EnumVal < LastEnumConst->getInitVal()) {
14014 if (T.
isNull() || Enum->isFixed()) {
14017 EnumVal = LastEnumConst->getInitVal();
14018 EnumVal = EnumVal.zext(EnumVal.getBitWidth() * 2);
14020 if (Enum->isFixed())
14022 Diag(IdLoc, diag::err_enumerator_wrapped)
14023 << EnumVal.toString(10)
14026 Diag(IdLoc, diag::ext_enumerator_increment_too_large)
14027 << EnumVal.toString(10);
14035 EnumVal = LastEnumConst->getInitVal();
14036 EnumVal.setIsSigned(EltTy->isSignedIntegerOrEnumerationType());
14045 if (!getLangOpts().CPlusPlus && !T.
isNull())
14046 Diag(IdLoc, diag::warn_enum_value_overflow);
14047 }
else if (!getLangOpts().CPlusPlus &&
14050 Diag(IdLoc, diag::ext_enum_value_not_int)
14051 << EnumVal.toString(10) << 1;
14056 if (!EltTy->isDependentType()) {
14060 EnumVal.setIsSigned(EltTy->isSignedIntegerOrEnumerationType());
14078 auto *PrevECD = dyn_cast_or_null<EnumConstantDecl>(PrevDecl);
14082 EnumDecl *PrevED = cast<EnumDecl>(PrevECD->getDeclContext());
14097 EnumDecl *TheEnumDecl = cast<EnumDecl>(theEnumDecl);
14099 cast_or_null<EnumConstantDecl>(lastEnumConst);
14113 PrevDecl =
nullptr;
14134 "Received TagDecl when not in C++!");
14136 shouldLinkPossiblyHiddenDecl(PrevDecl, New)) {
14137 if (isa<EnumConstantDecl>(PrevDecl))
14138 Diag(IdLoc, diag::err_redefinition_of_enumerator) << Id;
14140 Diag(IdLoc, diag::err_redefinition) << Id;
14171 if (!BO->isAdditiveOp())
14179 InitExpr = BO->getLHS();
14201 bool isTombstoneOrEmptyKey;
14202 DupKey(int64_t val,
bool isTombstoneOrEmptyKey)
14203 : val(val), isTombstoneOrEmptyKey(isTombstoneOrEmptyKey) {}
14206 static DupKey GetDupKey(
const llvm::APSInt& Val) {
14207 return DupKey(Val.isSigned() ? Val.getSExtValue() : Val.getZExtValue(),
14211 struct DenseMapInfoDupKey {
14212 static DupKey getEmptyKey() {
return DupKey(0,
true); }
14213 static DupKey getTombstoneKey() {
return DupKey(1,
true); }
14214 static unsigned getHashValue(
const DupKey Key) {
14215 return (
unsigned)(Key.val * 37);
14217 static bool isEqual(
const DupKey& LHS,
const DupKey& RHS) {
14218 return LHS.isTombstoneOrEmptyKey == RHS.isTombstoneOrEmptyKey &&
14219 LHS.val == RHS.val;
14242 typedef llvm::PointerUnion<EnumConstantDecl*, ECDVector*> DeclOrVector;
14243 typedef llvm::DenseMap<DupKey, DeclOrVector, DenseMapInfoDupKey>
14246 DuplicatesVector DupVector;
14247 ValueToVectorMap EnumMap;
14251 for (
unsigned i = 0, e = Elements.size(); i != e; ++i) {
14264 DeclOrVector &Entry = EnumMap[Key];
14267 if (Entry.isNull())
14272 for (
unsigned i = 0, e = Elements.size(); i != e; ++i) {
14279 DeclOrVector& Entry = EnumMap[Key];
14280 if (Entry.isNull())
14289 ECDVector *Vec =
new ECDVector();
14291 Vec->push_back(ECD);
14298 DupVector.push_back(Vec);
14302 ECDVector *Vec = Entry.get<ECDVector*>();
14304 if (*Vec->begin() == ECD)
14307 Vec->push_back(ECD);
14312 DupVectorEnd = DupVector.end();
14313 DupVectorIter != DupVectorEnd; ++DupVectorIter) {
14314 ECDVector *Vec = *DupVectorIter;
14315 assert(Vec->size() > 1 &&
"ECDVector should have at least 2 elements.");
14319 S.
Diag((*I)->getLocation(), diag::warn_duplicate_enum_values)
14320 << (*I)->getName() << (*I)->getInitVal().toString(10)
14321 << (*I)->getSourceRange();
14327 S.
Diag((*I)->getLocation(), diag::note_duplicate_element)
14328 << (*I)->getName() << (*I)->getInitVal().toString(10)
14329 << (*I)->getSourceRange();
14335 bool AllowMask)
const {
14336 assert(ED->
hasAttr<FlagEnumAttr>() &&
"looking for value in non-flag enum");
14339 auto R =
FlagBitsCache.insert(std::make_pair(ED, llvm::APInt()));
14340 llvm::APInt &FlagBits = R.first->second;
14344 const auto &EVal = E->getInitVal();
14346 if (EVal.isPowerOf2())
14347 FlagBits = FlagBits.zextOrSelf(EVal.getBitWidth()) | EVal;
14359 llvm::APInt FlagMask = ~FlagBits.zextOrTrunc(Val.getBitWidth());
14360 return !(FlagMask & Val) || (AllowMask && !(FlagMask & ~Val));
14367 EnumDecl *Enum = cast<EnumDecl>(EnumDeclX);
14374 for (
unsigned i = 0, e = Elements.size(); i != e; ++i) {
14376 cast_or_null<EnumConstantDecl>(Elements[i]);
14377 if (!ECD)
continue;
14395 unsigned NumNegativeBits = 0;
14396 unsigned NumPositiveBits = 0;
14399 bool AllElementsInt =
true;
14401 for (
unsigned i = 0, e = Elements.size(); i != e; ++i) {
14403 cast_or_null<EnumConstantDecl>(Elements[i]);
14404 if (!ECD)
continue;
14406 const llvm::APSInt &InitVal = ECD->
getInitVal();
14409 if (InitVal.isUnsigned() || InitVal.isNonNegative())
14410 NumPositiveBits = std::max(NumPositiveBits,
14411 (
unsigned)InitVal.getActiveBits());
14413 NumNegativeBits = std::max(NumNegativeBits,
14414 (
unsigned)InitVal.getMinSignedBits());
14417 if (AllElementsInt)
14423 unsigned BestWidth;
14436 bool Packed = Enum->
hasAttr<PackedAttr>();
14447 BestPromotionType = BestType;
14451 else if (NumNegativeBits) {
14455 if (Packed && NumNegativeBits <= CharWidth && NumPositiveBits < CharWidth) {
14457 BestWidth = CharWidth;
14458 }
else if (Packed && NumNegativeBits <= ShortWidth &&
14459 NumPositiveBits < ShortWidth) {
14461 BestWidth = ShortWidth;
14462 }
else if (NumNegativeBits <= IntWidth && NumPositiveBits < IntWidth) {
14464 BestWidth = IntWidth;
14468 if (NumNegativeBits <= BestWidth && NumPositiveBits < BestWidth) {
14473 if (NumNegativeBits > BestWidth || NumPositiveBits >= BestWidth)
14478 BestPromotionType = (BestWidth <= IntWidth ?
Context.
IntTy : BestType);
14483 if (Packed && NumPositiveBits <= CharWidth) {
14486 BestWidth = CharWidth;
14487 }
else if (Packed && NumPositiveBits <= ShortWidth) {
14490 BestWidth = ShortWidth;
14491 }
else if (NumPositiveBits <= IntWidth) {
14493 BestWidth = IntWidth;
14495 = (NumPositiveBits == BestWidth || !
getLangOpts().CPlusPlus)
14497 }
else if (NumPositiveBits <=
14501 = (NumPositiveBits == BestWidth || !
getLangOpts().CPlusPlus)
14505 assert(NumPositiveBits <= BestWidth &&
14506 "How could an initializer get larger than ULL?");
14509 = (NumPositiveBits == BestWidth || !
getLangOpts().CPlusPlus)
14516 for (
auto *D : Elements) {
14517 auto *ECD = cast_or_null<EnumConstantDecl>(D);
14518 if (!ECD)
continue;
14527 llvm::APSInt InitVal = ECD->getInitVal();
14538 NewWidth = IntWidth;
14540 }
else if (ECD->getType() == BestType) {
14546 ECD->setType(EnumType);
14550 NewWidth = BestWidth;
14555 InitVal = InitVal.extOrTrunc(NewWidth);
14556 InitVal.setIsSigned(NewSign);
14557 ECD->setInitVal(InitVal);
14560 if (ECD->getInitExpr() &&
14564 ECD->getInitExpr(),
14571 ECD->setType(EnumType);
14573 ECD->setType(NewTy);
14577 NumPositiveBits, NumNegativeBits);
14581 if (Enum->
hasAttr<FlagEnumAttr>()) {
14582 for (
Decl *D : Elements) {
14584 if (!ECD)
continue;
14587 if (InitVal != 0 && !InitVal.isPowerOf2() &&
14605 AsmString, StartLoc,
14613 bool FromInclude =
false) {
14616 if (
auto *LSD = dyn_cast<LinkageSpecDecl>(DC)) {
14617 switch (LSD->getLanguage()) {
14620 ExternCLoc = LSD->getLocStart();
14628 while (isa<LinkageSpecDecl>(DC))
14631 if (!isa<TranslationUnitDecl>(DC)) {
14633 ? diag::ext_module_import_not_at_top_level_noop
14634 : diag::err_module_import_not_at_top_level_fatal)
14636 S.
Diag(cast<Decl>(DC)->getLocStart(),
14637 diag::note_module_import_not_at_top_level) << DC;
14639 S.
Diag(ImportLoc, diag::ext_module_import_in_extern_c)
14641 S.
Diag(ExternCLoc, diag::note_module_import_in_extern_c);
14666 Diag(ImportLoc, diag::err_module_self_import)
14669 Diag(ImportLoc, diag::err_module_import_in_implementation)
14674 for (
unsigned I = 0, N = Path.size();
I != N; ++
I) {
14679 ModCheck = ModCheck->
Parent;
14681 IdentifierLocs.push_back(Path[
I].second);
14686 AtLoc.
isValid()? AtLoc : ImportLoc,
14687 Mod, IdentifierLocs);
14700 bool IsInModuleIncludes =
14706 if (!IsInModuleIncludes) {
14716 VisibleModules.
setVisible(Mod, DirectiveLoc);
14723 VisibleModulesStack.push_back(std::move(VisibleModules));
14724 VisibleModules.
setVisible(Mod, DirectiveLoc);
14731 VisibleModules = std::move(VisibleModulesStack.back());
14732 VisibleModulesStack.pop_back();
14733 VisibleModules.
setVisible(Mod, DirectiveLoc);
14762 AsmLabelAttr *
Attr =
14763 AsmLabelAttr::CreateImplicit(
Context, AliasName->
getName(), AliasNameLoc);
14769 if (PrevDecl && (isa<FunctionDecl>(PrevDecl) || isa<VarDecl>(PrevDecl))) {
14773 Diag(PrevDecl->
getLocation(), diag::warn_redefine_extname_not_applied)
14774 << (isa<FunctionDecl>(PrevDecl) ? 0 : 1) << PrevDecl;
14786 PrevDecl->
addAttr(WeakAttr::CreateImplicit(
Context, PragmaLoc));
14789 std::pair<IdentifierInfo*,WeakInfo>
14803 if (PrevDecl && (isa<FunctionDecl>(PrevDecl) || isa<VarDecl>(PrevDecl))) {
14804 if (!PrevDecl->
hasAttr<AliasAttr>())
14805 if (
NamedDecl *ND = dyn_cast<NamedDecl>(PrevDecl))
14809 std::pair<IdentifierInfo*,WeakInfo>(AliasName, W));
14814 return (dyn_cast_or_null<ObjCContainerDecl>(
CurContext));
14831 D = MD->getClassInterface();
14836 dyn_cast<ObjCImplementationDecl>(D)) {
14837 D =
ID->getClassInterface();
static bool ShouldWarnAboutMissingPrototype(const FunctionDecl *FD, const FunctionDecl *&PossibleZeroParamPrototype)
MutableArrayRef< TemplateParameterList * > MultiTemplateParamsArg
unsigned getFlags() const
getFlags - Return the flags for this scope.
A call to an overloaded operator written using operator syntax.
unsigned getAddressSpace() const
Return the address space of this type.
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
Get the outermost AttributedType node that sets a calling convention.
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)
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
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.
CK_LValueToRValue - A conversion which causes the extraction of an r-value from the operand gl-value...
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()
getFunctionTypeInfo - Retrieves the function type info object (looking through parentheses).
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
isTransparentContext - Determines whether this context is a "transparent" context, meaning that the members declared in this context are semantically declared in the nearest enclosing non-transparent (opaque) context but are lexically declared in this context.
bool isTemplateParameter() const
isTemplateParameter - Determines whether this declaration is a template parameter.
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
getName - Get the name of identifier for this declaration as a StringRef.
bool CheckNontrivialField(FieldDecl *FD)
void setjmp_bufDecl(TypeDecl *jmp_bufDecl)
Set the type for the C jmp_buf type.
no exception specification
FunctionTemplateDecl * getInstantiatedFromMemberTemplate() const
bool canDecayToPointerType() const
Determines whether this type can decay to a pointer type.
void setAnonymousStructOrUnion(bool Anon)
PointerType - C99 6.7.5.1 - Pointer Declarators.
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...
A (possibly-)qualified type.
Decl * ActOnIvar(Scope *S, SourceLocation DeclStart, Declarator &D, Expr *BitfieldWidth, tok::ObjCKeywordKind visibility)
ActOnIvar - Each ivar field of an objective-c class is passed into this in order to create an IvarDec...
bool ShouldWarnIfUnusedFileScopedDecl(const DeclaratorDecl *D) const
Simple class containing the result of Sema::CorrectTypo.
capture_const_range captures() const
const IdentifierInfo * getLiteralIdentifier() const
getLiteralIdentifier - The literal suffix identifier this function represents, if any...
void InstantiatedLocal(const Decl *D, Decl *Inst)
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)
InjectAnonymousStructOrUnionMembers - Inject the members of the anonymous struct or union AnonRecord ...
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
Returns a nonzero value if objects of this type require non-trivial work to clean up after...
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'.
Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc...
A class which encapsulates the logic for delaying diagnostics during parsing and other processing...
IdentifierInfo * Name
FIXME: Temporarily stores the name of a specialization.
IdentifierInfo * getIdentifier() const
getIdentifier - Get the identifier that names this declaration, if there is one.
void MergeTypedefNameDecl(Scope *S, TypedefNameDecl *New, LookupResult &OldDecls)
MergeTypedefNameDecl - We just parsed a typedef 'New' which has the same name and scope as a previous...
Decl * getRepAsDecl() const
void setAttrs(const AttrVec &Attrs)
const LangOptions & getLangOpts() const
void setLookupName(DeclarationName Name)
Sets the name to look up.
SourceLocation TemplateNameLoc
TemplateNameLoc - The location of the template name within the source.
bool LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation=false)
Perform unqualified name lookup starting from a given scope.
const Scope * getFnParent() const
getFnParent - Return the closest scope that is a function body.
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...
decl_range decls() const
decls_begin/decls_end - Iterate over the declarations stored in this context.
bool isInitICE() const
Determines whether the initializer is an integral constant expression, or in C++11, whether the initializer is a constant expression.
void setPreviousDecl(decl_type *PrevDecl)
Set the previous declaration.
FunctionType - C99 6.7.5.3 - Function Declarators.
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
Merge availability attributes for an override, which requires an exact match or a weakening of constr...
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 "...
EnumConstantDecl - An instance of this object exists for each enum constant that is defined...
unsigned getIntWidth(QualType T) const
QualType ReturnType
ReturnType - The target type of return statements in this context, or null if unknown.
void setTypedefNameForAnonDecl(TypedefNameDecl *TDD)
const Scope * getParent() const
getParent - Return the scope that this is nested in.
TypedefDecl - Represents the declaration of a typedef-name via the 'typedef' type specifier...
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)
Should be called on all declarations that might have attached documentation comments.
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.
Decl - This represents one declaration (or definition), e.g.
void setRangeEnd(SourceLocation E)
void forgetBuiltin(unsigned ID, IdentifierTable &Table)
Completely forget that the given ID was ever considered a builtin, e.g., because the user provided a ...
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
Return true if this is a literal type (C++11 [basic.types]p10)
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)
Scope * TUScope
Translation Unit Scope - useful to Objective-C actions that need to lookup file scope declarations in...
Represents a C++11 auto or C++14 decltype(auto) type.
static bool canRedefineFunction(const FunctionDecl *FD, const LangOptions &LangOpts)
canRedefineFunction - checks if a function can be redefined.
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.
TemplateSpecializationType(TemplateName T, const TemplateArgument *Args, unsigned NumArgs, QualType Canon, QualType Aliased)
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, SourceRange ESpecRange, ParsedType *Exceptions, SourceRange *ExceptionRanges, unsigned NumExceptions, Expr *NoexceptExpr, CachedTokens *ExceptionSpecTokens, SourceLocation LocalRangeBegin, SourceLocation LocalRangeEnd, Declarator &TheDeclarator, TypeResult TrailingReturnType=TypeResult())
DeclaratorChunk::getFunction - Return a DeclaratorChunk for a function.
bool hasErrorOccurred() const
Determine whether any SFINAE errors have been trapped.
IdentifierInfo * getAsIdentifierInfo() const
getAsIdentifierInfo - Retrieve the IdentifierInfo * stored in this declaration name, or NULL if this declaration name isn't a simple identifier.
The base class of the type hierarchy.
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.
void setTemplateParameterListsInfo(ASTContext &Context, ArrayRef< TemplateParameterList * > TPLists)
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...
Represents an array type, per C99 6.7.5.2 - Array Declarators.
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.
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()
completeDefinition - Notes that the definition of this type is now complete.
ObjCDeclQualifier getObjCDeclQualifier() 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.
Look up of a name that precedes the '::' scope resolution operator in C++.
static NestedNameSpecifier * synthesizeCurrentNestedNameSpecifier(ASTContext &Context, DeclContext *DC)
TypeSourceInfo * getIntegerTypeSourceInfo() const
Return the type source info for the underlying integer type, if no type source info exists...
unsigned getFunctionPrototypeDepth() const
Returns the number of function prototype scopes in this scope chain.
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
void setInitStyle(InitializationStyle Style)
bool isConceptSpecified() const
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.
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)
BuildDeclaratorGroup - convert a list of declarations into a declaration group, performing any necess...
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)
DiagnoseClassNameShadow - Implement C++ [class.mem]p13: If T is the name of a class, then each of the following shall have a name different from T:
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...
VarDecl - An instance of this class is created to represent a variable declaration or definition...
PartialDiagnostic PDiag(unsigned DiagID=0)
Build a partial diagnostic.
CK_IntegralCast - A cast between integral types (other than to boolean).
NamedDecl * LazilyCreateBuiltin(IdentifierInfo *II, unsigned ID, Scope *S, bool ForRedeclaration, SourceLocation Loc)
LazilyCreateBuiltin - The specified Builtin-ID was first used at file scope.
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)
setCXXLiteralOperatorNameLoc - Sets the location of the literal operator name (not the operator keywo...
const Expr * getCallee() const
TLSKind getTLSKind() const
Extra information about a function prototype.
AccessSpecifier getAccess() const
AutoTypeKeyword getKeyword() 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.
The "__interface" keyword.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
void ActOnTagFinishSkippedDefinition(SkippedDefinitionContext Context)
ObjCMethodDecl - Represents an instance or class method declaration.
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)
AddOverriddenMethods - See if a method overrides any in the base classes, and if so, check that it's a valid override and remember it.
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)
ActOnParamDeclarator - Called from Parser::ParseFunctionDeclarator() to introduce parameters into fun...
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)
Represents an expression – generally a full-expression – that introduces cleanups to be run at the en...
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)
Helper method to turn variable array types into constant array types in certain situations which woul...
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)
HandleField - Analyze a field of a C struct or a C++ data member.
bool hasExternalFormalLinkage() const
True if this decl has external linkage.
bool FTIHasNonVoidParameters(const DeclaratorChunk::FunctionTypeInfo &FTI)
QualType CheckConstructorDeclarator(Declarator &D, QualType R, StorageClass &SC)
CheckConstructorDeclarator - Called by ActOnDeclarator to check the well-formedness of the constructo...
void setCorrectionDecl(NamedDecl *CDecl)
Clears the list of NamedDecls before adding the new one.
Base wrapper for a particular "section" of type source info.
Expr * IgnoreImpCasts() LLVM_READONLY
IgnoreImpCasts - Skip past any implicit casts which might surround this expression.
Decl * ActOnStartOfFunctionDef(Scope *S, Declarator &D, MultiTemplateParamsArg TemplateParamLists, SkipBodyInfo *SkipBody=nullptr)
unsigned getNumParams() const
RecordDecl - Represents a struct/union/class.
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).
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.
One of these records is kept for each identifier that is lexed.
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.
bool isAuxBuiltinID(unsigned ID) const
Return true if builtin ID belongs to AuxTarget.
static bool isFunctionDefinitionDiscarded(Sema &S, FunctionDecl *FD)
Given that we are within the definition of the given function, will that definition behave like C99's...
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...
static bool isDeclExternC(const Decl *D)
Returns true if given declaration has external C language linkage.
OpaquePtr< QualType > ParsedType
An opaque type for threading parsed type information through the parser.
void MergeVarDeclTypes(VarDecl *New, VarDecl *Old, bool MergeTypeWithOld)
MergeVarDeclTypes - We parsed a variable 'New' which has the same name and scope as a previous declar...
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)
DiagnoseTemplateParameterShadow - Produce a diagnostic complaining that the template parameter 'PrevD...
class LLVM_ALIGNAS(8) DependentTemplateSpecializationType const IdentifierInfo * Name
Represents a template specialization type whose template cannot be resolved, e.g. ...
TagDecl * getAnonDeclWithTypedefName(bool AnyRedecl=false) const
Retrieves the tag declaration for which this is the typedef name for linkage purposes, if any.
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)
AddTypeInfo - Add a chunk to this declarator.
The results of name lookup within a DeclContext.
ArrayRef< QualType > getParamTypes() const
void ActOnTagStartDefinition(Scope *S, Decl *TagDecl)
ActOnTagStartDefinition - Invoked when we have entered the scope of a tag's definition (e...
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
getCXXScopeSpec - Return the C++ scope specifier (global scope or nested-name-specifier) that is part...
ObjCIvarDecl * getIvarDecl(IdentifierInfo *Id) const
getIvarDecl - This method looks up an ivar in this ContextDecl.
bool isIdentifier() const
Predicate functions for querying what type of name this is.
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
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
bool isCompleteDefinition() const
isCompleteDefinition - Return true if this decl has its body fully specified.
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.
bool isPure() const
Whether this virtual function is pure, i.e.
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
The iterator over UnresolvedSets.
bool isPreviousDeclInSameBlockScope() const
Whether this local extern variable declaration's previous declaration was declared in the same block ...
bool hasSameType(QualType T1, QualType T2) const
Determine whether the given types T1 and T2 are equivalent.
virtual SourceRange getSourceRange() const LLVM_READONLY
Source range that this declaration covers.
static const TST TST_error
Token - This structure provides full information about a lexed token.
void setStaticLocalNumber(const VarDecl *VD, unsigned Number)
SkipBodyInfo shouldSkipAnonEnumBody(Scope *S, IdentifierInfo *II, SourceLocation IILoc)
Determine whether the body of an anonymous enumeration should be skipped.
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)
isMicrosoftMissingTypename - In Microsoft mode, within class scope, if a CXXScopeSpec's type is equal...
void ActOnFinishDelayedAttribute(Scope *S, Decl *D, ParsedAttributes &Attrs)
ActOnFinishDelayedAttribute - Invoked when we have finished parsing an attribute for which parsing is...
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 {'.
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
A nullability kind paired with a bit indicating whether it used a context-sensitive keyword...
No entity found met the criteria within the current instantiation,, but there were dependent base cla...
static bool adjustContextForLocalExternDecl(DeclContext *&DC)
Adjust the DeclContext for a function or variable that might be a function-local external declaration...
Describes a module or submodule.
bool isThisDeclarationADefinition() const
isThisDeclarationADefinition() - Return true if this declaration is a completion definition of the ty...
void diagnoseMisplacedModuleImport(Module *M, SourceLocation ImportLoc)
Check if module import may be found in the current context, emit error if not.
StorageClass getStorageClass() const
Returns the storage class as written in the source.
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.
Provides information about a function template specialization, which is a FunctionDecl that has been ...
bool isExplicitlyDefaulted() const
Whether this function is explicitly defaulted per C++0x.
unsigned getRegParmType() const
QualType mergeObjCGCQualifiers(QualType, QualType)
mergeObjCGCQualifiers - This routine merges ObjC's GC attribute of 'LHS' and 'RHS' attributes and ret...
SourceLocation getBeginLoc() const
Get the begin source location.
VarDecl * getActingDefinition()
Get the tentative definition that acts as the real definition in a TU.
UnionParsedType DestructorName
When Kind == IK_DestructorName, the type referred to by the class-name.
Describes an C or C++ initializer list.
VarTemplateDecl * getInstantiatedFromMemberTemplate() const
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)
CheckConvertedConstantExpression - Check that the expression From is a converted constant expression ...
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)
ObjCContainerDecl - Represents a container for method declarations.
const LangOptions & getLangOpts() const
static void filterNonConflictingPreviousTypedefDecls(Sema &S, TypedefNameDecl *Decl, LookupResult &Previous)
Typedef declarations don't have linkage, but they still denote the same entity if their types are the...
unsigned getNumTypeObjects() const
Return the number of types applied to this declarator.
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
CharUnits - This is an opaque type for sizes expressed in character units.
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...
A convenient class for passing around template argument information.
bool isLocalVarDeclOrParm() const
Similar to isLocalVarDecl but also includes parameters.
void setcudaConfigureCallDecl(FunctionDecl *FD)
Scope * getNonFieldDeclScope(Scope *S)
getNonFieldDeclScope - Retrieves the innermost scope, starting from S, where a non-field would be dec...
static bool mergeAlignedAttrs(Sema &S, NamedDecl *New, Decl *Old)
Merge alignment attributes from Old to New, taking into account the special semantics of C11's _Align...
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)
ActOnInitializerError - Given that there was an error parsing an initializer for the given declaratio...
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
Returns the parent of this method declaration, which is the class in which this method is defined...
AmbiguityKind getAmbiguityKind() const
bool isDefaulted() const
Whether this function is defaulted per C++0x.
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)
A friend of a previously-undeclared entity.
bool isObjCLifetimeType() const
Returns true if objects of this type have lifetime semantics under ARC.
const ArrayType * getAsArrayType(QualType T) const
Type Query functions.
bool containsDecl(Decl *D) const
Checks whether a declaration is in this context.
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)
TypeDecl - Represents a declaration of a type.
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
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
AvailabilityAttr * mergeAvailabilityAttr(NamedDecl *D, SourceRange Range, IdentifierInfo *Platform, VersionTuple Introduced, VersionTuple Deprecated, VersionTuple Obsoleted, bool IsUnavailable, StringRef Message, AvailabilityMergeKind AMK, unsigned AttrSpellingListIndex)
Attribute merging methods. Return true if a new attribute was added.
static OpenCLParamType getOpenCLKernelParameterType(QualType PT)
QualType CheckDestructorDeclarator(Declarator &D, QualType R, StorageClass &SC)
CheckDestructorDeclarator - Called by ActOnDeclarator to check the well-formednes of the destructor d...
QualType withoutLocalFastQualifiers() const
void setHasImplicitReturnZero(bool IRZ)
ParsedTemplateArgument * getTemplateArgs()
Retrieves a pointer to the template arguments.
Module * Parent
The parent of this 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
isOverloadedOperator - Whether this function declaration represents an C++ overloaded operator...
LabelStmt * getStmt() const
void ActOnModuleInclude(SourceLocation DirectiveLoc, Module *Mod)
The parser has processed a module import translated from a #include or similar preprocessing directiv...
Scope - A scope is a transient data structure that is used while parsing the program.
ExprResult Perform(Sema &S, const InitializedEntity &Entity, const InitializationKind &Kind, MultiExprArg Args, QualType *ResultType=nullptr)
Perform the actual initialization of the given entity based on the computed initialization sequence...
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.
bool isDependent() const
Whether this nested name specifier refers to a dependent type or not.
void DiagnoseUnusedDecl(const NamedDecl *ND)
DiagnoseUnusedDecl - Emit warnings about declarations that are not used unless they are marked attr(u...
Represents a C++ nested-name-specifier or a global scope specifier.
void ActOnFinishInlineMethodDef(CXXMethodDecl *D)
bool hasUnrecoverableErrorOccurred() const
int hasAttribute(AttrSyntax Syntax, const IdentifierInfo *Scope, const IdentifierInfo *Attr, const TargetInfo &Target, const LangOptions &LangOpts)
Return the version number associated with the attribute if we recognize and implement the attribute s...
bool isStructureType() const
SourceLocation getConceptSpecLoc() const
void setRedeclarationKind(Sema::RedeclarationKind RK)
Change this lookup's redeclaration kind.
bool isIncompleteType(NamedDecl **Def=nullptr) const
Types are partitioned into 3 broad categories (C99 6.2.5p1): object types, function types...
DeclContext * getLexicalDeclContext()
getLexicalDeclContext - The declaration context where this Decl was lexically declared (LexicalDC)...
static bool mergeDeclAttribute(Sema &S, NamedDecl *D, const InheritableAttr *Attr, Sema::AvailabilityMergeKind AMK)
NestedNameSpecifierLoc getWithLocInContext(ASTContext &Context) const
Retrieve a nested-name-specifier with location information, copied into the given AST context...
static Scope * getTagInjectionScope(Scope *S, const LangOptions &LangOpts)
Find the Scope in which a tag is implicitly declared if we see an elaborated type specifier in the sp...
bool isIncompatibleTypedef(TypeDecl *Old, TypedefNameDecl *New)
void UpdateExprRep(Expr *Rep)
void CheckCompleteVariableDeclaration(VarDecl *var)
void CheckVariableDeclarationType(VarDecl *NewVD)
SourceLocation getLocation() const
bool isStaticLocal() const
isStaticLocal - Returns true if a variable with function scope is a static local variable.
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...
void setTemplateParameterListsInfo(ASTContext &Context, ArrayRef< TemplateParameterList * > TPLists)
bool isLambdaCallOperator(const CXXMethodDecl *MD)
FunctionTemplateDecl * getDescribedFunctionTemplate() const
Retrieves the function template that is described by this function declaration.
void CheckMSVCRTEntryPoint(FunctionDecl *FD)
Decl * ActOnFinishFunctionBody(Decl *Decl, Stmt *Body)
Represents an ObjC class declaration.
void revertBuiltin()
Revert the identifier to a non-builtin identifier.
Represents a linkage specification.
static FunctionTemplateDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation L, DeclarationName Name, TemplateParameterList *Params, NamedDecl *Decl)
Create a function template node.
SourceLocation getLocStart() const LLVM_READONLY
void addDecl(NamedDecl *D)
Add a declaration to these results with its natural access.
Member name lookup, which finds the names of class/struct/union members.
SourceRange getSourceRange() const LLVM_READONLY
detail::InMemoryDirectory::const_iterator I
llvm::DenseMap< IdentifierInfo *, AsmLabelAttr * > ExtnameUndeclaredIdentifiers
ExtnameUndeclaredIdentifiers - Identifiers contained in #pragma redefine_extname before declared...
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)
ProcessDeclAttributeList - Apply all the decl attributes in the specified attribute list to the speci...
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)
Pushes space for a typespec TypeLoc.
This object can be modified without requiring retains or releases.
SourceRange getRange() const
bool isDefined(const FunctionDecl *&Definition) const
isDefined - Returns true if the function is defined at all, including a deleted definition.
param_iterator param_begin()
unsigned getMSLastManglingNumber() const
void setHasInheritedPrototype(bool P=true)
TyLocType push(QualType T)
Pushes space for a new TypeLoc of the given type.
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
SourceLocation LAngleLoc
The location of the '<' before the template argument list.
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)
completeDefinition - When created, the EnumDecl corresponds to a forward-declared enum...
static ImportDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, Module *Imported, ArrayRef< SourceLocation > IdentifierLocs)
Create a new module import declaration.
FunctionTemplateSpecializationInfo * getTemplateSpecializationInfo() const
If this function is actually a function template specialization, retrieve information about this func...
ConditionalOperator - The ?: ternary operator.
DeclSpec & getMutableDeclSpec()
getMutableDeclSpec - Return a non-const version of the DeclSpec.
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
A variant of castAs<> for array type which silently discards qualifiers from the outermost type...
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.
Merge availability attributes for an implementation of a protocol requirement.
llvm::APInt getValue() const
bool isFunctionDeclarator(unsigned &idx) const
isFunctionDeclarator - This method returns true if the declarator is a function declarator (looking t...
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
Represents a prototype with parameter type info, e.g.
void AddInitializerToDecl(Decl *dcl, Expr *init, bool DirectInit, bool TypeMayContainAuto)
AddInitializerToDecl - Adds the initializer Init to the declaration dcl.
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)
mergeParamDeclAttributes - Copy attributes from the old parameter to the new one. ...
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
TypeSpecifierType isTagName(IdentifierInfo &II, Scope *S)
isTagName() - This method is called for error recovery purposes only to determine if the specified na...
bool inferObjCARCLifetime(ValueDecl *decl)
Represents a ValueDecl that came out of a declarator.
void SetRangeStart(SourceLocation Loc)
static ImplicitCastExpr * Create(const ASTContext &Context, QualType T, CastKind Kind, Expr *Operand, const CXXCastPath *BasePath, ExprValueKind Cat)
SourceLocation getFriendSpecLoc() const
DeclarationNameTable DeclarationNames
unsigned NumParams
NumParams - This is the number of formal parameters specified by the declarator.
SourceLocation getLBracketLoc() const
bool MergeFunctionDecl(FunctionDecl *New, NamedDecl *&Old, Scope *S, bool MergeTypeWithOld)
MergeFunctionDecl - We just parsed a function 'New' from declarator D which has the same name and sco...
SourceLocation getTypeSpecStartLoc() const
std::vector< bool > & Stack
SourceLocation getInnerLocStart() const
getInnerLocStart - Return SourceLocation representing start of source range ignoring outer template d...
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.
const CXXMethodDecl *const * method_iterator
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
bool isFunctionPointerType() const
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
getObjCInterfaceType - Return the unique reference to the type for the specified ObjC interface decl...
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
Determines whether this is an integer type that is signed or an enumeration types whose underlying ty...
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()
getLexicalParent - Returns the containing lexical DeclContext.
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
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
bool isUndeducedType() const
Determine whether this type is an undeduced type, meaning that it somehow involves a C++11 'auto' typ...
Expr - This represents one expression.
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 char * getName(unsigned ID) const
Return the identifier name for the specified builtin, e.g.
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
void addTypedefNameForUnnamedTagDecl(TagDecl *TD, TypedefNameDecl *TND)
void ResetObjCLayout(const ObjCContainerDecl *CD)
bool isDeclScope(Decl *D)
isDeclScope - Return true if this is the scope that the specified decl is declared in...
llvm::SmallPtrSet< const Decl *, 4 > ParsingInitForAutoVars
ParsingInitForAutoVars - a set of declarations with auto types for which we are currently parsing the...
static Kind getNullabilityAttrKind(NullabilityKind kind)
Retrieve the attribute kind corresponding to the given nullability kind.
static bool checkForConflictWithNonVisibleExternC(Sema &S, const T *ND, LookupResult &Previous)
Apply special rules for handling extern "C" declarations.
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
Gets the location of the identifier.
This file defines the classes used to store parsed information about declaration-specifiers and decla...
bool Encloses(const DeclContext *DC) const
Determine whether this declaration context encloses the declaration context DC.
bool isModuleVisible(Module *M)
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)
setInvalidDecl - Indicates the Decl had a semantic error.
TranslationUnitDecl * getTranslationUnitDecl() const
NamedDecl * getFoundDecl() const
Fetch the unique decl found by this lookup.
bool isObjCGCWeak() const
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)
BuildMicrosoftCAnonymousStruct - Handle the declaration of an Microsoft C anonymous structure...
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
WeakUndeclaredIdentifiers - Identifiers contained in #pragma weak before declared.
Defines the classes clang::DelayedDiagnostic and clang::AccessedEntity.
SourceLocation getVolatileSpecLoc() const
bool isLocalExternDecl()
Determine whether this is a block-scope declaration with linkage.
Name lookup results in an ambiguity because an entity with a tag name was hidden by an entity with an...
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.
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)
Converts a type specifier (DeclSpec::TST) into a tag type kind.
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)
ActOnTypedefNameDecl - Perform semantic checking for a declaration which declares a typedef-name...
bool isMSAsmLabel() const
bool isFunctionNoProtoType() const
bool isObjCIdType() const
Decl * ActOnField(Scope *S, Decl *TagD, SourceLocation DeclStart, Declarator &D, Expr *BitfieldWidth)
ActOnField - Each field of a C struct/union is passed into this in order to create a FieldDecl object...
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)
checkNewAttributesAfterDef - If we already have a definition, check that there are no new attributes ...
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)
hasSimilarParameters - Determine whether the C++ functions Declaration and Definition have "nearly" m...
StorageClass
Storage classes.
Expr * getSubExpr() const
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
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
EvaluateAsInt - Return true if this is a constant which we can fold and convert to an integer...
QualType getCXXNameType() const
getCXXNameType - If this name is one of the C++ names (of a constructor, destructor, or conversion function), return the type associated with that name.
QualType getObjCIdType() const
Represents the Objective-CC id type.
ReturnStmt - This represents a return, optionally of an expression: return; return 4;...
An expression that sends a message to the given Objective-C object or class.
bool isExternallyVisible() const
void setModedTypeSourceInfo(TypeSourceInfo *unmodedTSI, QualType modedTy)
static bool hasDefinition(const ObjCObjectPointerType *ObjPtr)
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
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
getDeclName - Get the actual, stored name of the declaration, which may be a special name...
void addDeclaratorForUnnamedTagDecl(TagDecl *TD, DeclaratorDecl *DD)
DeclContext * getContainingDC(DeclContext *DC)
void PushOnScopeChains(NamedDecl *D, Scope *S, bool AddToContext=true)
Add this decl to the scope shadowed decl chains.
InternalLinkageAttr * mergeInternalLinkageAttr(Decl *D, SourceRange Range, IdentifierInfo *Ident, unsigned AttrSpellingListIndex)
TagDecl * getDefinition() const
getDefinition - Returns the TagDecl that actually defines this struct/union/class/enum.
const Type * getAsType() const
Retrieve the type stored in this nested name specifier.
void setDescribedClassTemplate(ClassTemplateDecl *Template)
Linkage getFormalLinkage() const
Get the linkage from a semantic point of view.
void setStorageClass(StorageClass SC)
Represents a C++ conversion function within a class.
sema::LambdaScopeInfo * PushLambdaScope()
The result type of a method or function.
This template specialization was implicitly instantiated from a template.
NamedDecl * LookupSingleName(Scope *S, DeclarationName Name, SourceLocation Loc, LookupNameKind NameKind, RedeclarationKind Redecl=NotForRedeclaration)
Look up a name, looking for a single declaration.
SourceLocation getLocEnd() const LLVM_READONLY
bool hasNameForLinkage() const
Is this tag type named, either directly or via being defined in a typedef of this type...
void setQualifierLoc(NestedNameSpecifierLoc QualifierLoc)
SourceLocation getStorageClassSpecLoc() const
RecordDecl * getDefinition() const
getDefinition - Returns the RecordDecl that actually defines this struct/union/class.
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 '@'.
void setDeclContext(DeclContext *DC)
setDeclContext - Set both the semantic and lexical DeclContext to 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.
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)
Check for conflict between this global or extern "C" declaration and previous global or extern "C" de...
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.
void CheckForFunctionRedefinition(FunctionDecl *FD, const FunctionDecl *EffectiveDefinition=nullptr, SkipBodyInfo *SkipBody=nullptr)
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)
ImplicitlyDefineFunction - An undeclared identifier was used in a function call, forming a call to an...
static bool isIncompleteDeclExternC(Sema &S, const T *D)
Determine whether a variable is extern "C" prior to attaching an initializer.
bool isCtorOrDtor()
Returns true if this declares a constructor or a destructor.
TypeLoc getInnerLoc() const
void setTypeForDecl(const Type *TD)
Wrapper for source info for arrays.
static unsigned getMSManglingNumber(const LangOptions &LO, Scope *S)
bool doesThisDeclarationHaveABody() const
doesThisDeclarationHaveABody - Returns whether this specific declaration of the function has a body -...
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. ...
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
redecl_range redecls() const
Returns an iterator range for all the redeclarations of the same decl.
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)
Tag name lookup, which finds the names of enums, classes, structs, and unions.
Assigning into this object requires the old value to be released and the new value to be retained...
DeclarationNameInfo getNameForTemplate(TemplateName Name, SourceLocation NameLoc) const
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.
enum clang::DeclaratorChunk::@183 Kind
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
IsValueInFlagEnum - Determine if a value is allowed as part of a flag enum.
SourceLocation getOuterLocStart() const
getOuterLocStart - Return SourceLocation representing start of source range taking into account any o...
ExternCContextDecl * getExternCContextDecl() const
Encodes a location in the source.
enumerator_range enumerators() const
bool isAnonymousStructOrUnion() const
isAnonymousStructOrUnion - Determines whether this field is a representative for an anonymous struct ...
Sugar for parentheses used when specifying types.
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
getNumParams - Return the number of parameters this function must have based on its FunctionType...
SourceLocation CurrentPragmaLocation
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of enums...
const Type * getTypePtr() const
Retrieves a pointer to the underlying (unqualified) type.
const TemplateArgument * iterator
bool containedInPrototypeScope() const
containedInPrototypeScope - Return true if this or a parent scope is a FunctionPrototypeScope.
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.
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)
FinalizeDeclaration - called by ParseDeclarationAfterDeclarator to perform any semantic actions neces...
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
getCXXOverloadedOperator - If this name is the name of an overloadable operator in C++ (e...
void setFreeStanding(bool isFreeStanding=true)
void disableCheckFallThrough()
void ExitDeclaratorContext(Scope *S)
The nullability qualifier is set when the nullability of the result or parameter was expressed via a ...
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
isLocalVarDecl - Returns true for local variable declarations other than parameters.
static const TST TST_union
InheritableAttr * getDLLAttr(Decl *D)
Return a DLL attribute from the declaration.
CommonAttr * mergeCommonAttr(Decl *D, SourceRange Range, IdentifierInfo *Ident, unsigned AttrSpellingListIndex)
LabelDecl - Represents the declaration of a label.
bool SetStorageClassSpec(Sema &S, SCS SC, SourceLocation Loc, const char *&PrevSpec, unsigned &DiagID, const PrintingPolicy &Policy)
These methods set the specified attribute of the DeclSpec and return false if there was no error...
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...
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 if D has a visible definition.
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
SourceRange getExceptionSpecRange() 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.
MemberPointerTypeInfo Mem
ObjCCategoryDecl - Represents a category declaration.
bool isIntegerConstantExpr(llvm::APSInt &Result, const ASTContext &Ctx, SourceLocation *Loc=nullptr, bool isEvaluated=true) const
isIntegerConstantExpr - Return true if this expression is a valid integer constant expression...
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...
A class for iterating through a result set and possibly filtering out results.
This declaration is only a declaration.
SourceLocation getVirtualSpecLoc() const
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
static const TST TST_typeofType
SourceLocation getBegin() const
bool isTypeDependent() const
isTypeDependent - Determines whether this expression is type-dependent (C++ [temp.dep.expr]), which means that its type could change from one template instantiation to the next.
const T * castAs() const
Member-template castAs<specific type>.
SourceLocation getBeginLoc() const
lookup_result lookup(DeclarationName Name) const
lookup - Find the declarations (if any) with the given Name in this context.
No entity found met the criteria.
QualType getAttributedType(AttributedType::Kind attrKind, QualType modifiedType, QualType equivalentType)
const IdentifierInfo * getIdentifier() const
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
is/isNot - Predicates to check if this token is a specific kind, as in "if (Tok.is(tok::l_brace)) {...
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)
ActOnLastBitfield - This routine handles synthesized bitfields rules for class and class extensions...
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.
bool isStaticMember()
Returns true if this declares a static member.
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.
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.
Describes a module import declaration, which makes the contents of the named module visible in the cu...
SourceLocation getExprLoc() const LLVM_READONLY
getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...
bool isFunctionProtoType() const
ClassTemplateDecl * getDescribedClassTemplate() const
Retrieves the class template that is described by this class declaration.
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. ...
SourceRange getSourceRange() const LLVM_READONLY
Get the source range that spans this declarator.
void takeAttributes(ParsedAttributes &attrs, SourceLocation lastLoc)
takeAttributes - Takes attributes from the given parsed-attributes set and add them to this declarato...
AttributeFactory & getFactory() const
CanQualType UnsignedShortTy
bool isInitCapture() const
Whether this variable is the implicit variable for a lambda init-capture.
bool isTSBuiltin(unsigned ID) const
Return true if this function is a target-specific builtin.
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()))
bool isAnonymousStructOrUnion() const
isAnonymousStructOrUnion - Whether this is an anonymous struct or union.
TLS with a dynamic initializer.
Represents a template argument.
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
getCXXOperatorNameRange - Gets the range of the operator name (without the operator keyword)...
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)
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
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)
EnterDeclaratorContext - Used when we must lookup names in the context of a declarator's nested name ...
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 isFriendSpecified() const
FunctionDecl * getDirectCallee()
If the callee is a FunctionDecl, return it. Otherwise return 0.
void DeclApplyPragmaWeak(Scope *S, NamedDecl *ND, WeakInfo &W)
DeclApplyPragmaWeak - A declaration (maybe definition) needs #pragma weak applied to it...
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
bool isCanonicalDecl() const
Whether this particular Decl is a canonical one.
static bool CheckAnonMemberRedeclaration(Sema &SemaRef, Scope *S, DeclContext *Owner, DeclarationName Name, SourceLocation NameLoc, bool IsUnion)
We are trying to inject an anonymous member into the given scope; check if there's an existing declar...
comments::FullComment * getCommentForDecl(const Decl *D, const Preprocessor *PP) const
Return parsed documentation comment attached to a given declaration.
void ActOnEnumBody(SourceLocation EnumLoc, SourceLocation LBraceLoc, SourceLocation RBraceLoc, Decl *EnumDecl, ArrayRef< Decl * > Elements, Scope *S, AttributeList *Attr)
SourceLocation RAngleLoc
The location of the '>' after the template argument list.
void ActOnTagFinishDefinition(Scope *S, Decl *TagDecl, SourceLocation RBraceLoc)
ActOnTagFinishDefinition - Invoked once we have finished parsing the definition of a tag (enumeration...
bool isInvalidDecl() const
unsigned getCharWidth() const
bool getProducesResult() const
bool CheckEnumRedeclaration(SourceLocation EnumLoc, bool IsScoped, QualType EnumUnderlyingTy, bool EnumUnderlyingIsImplicit, const EnumDecl *Prev)
Check whether this is a valid redeclaration of a previous enumeration.
IndirectFieldDecl - An instance of this class is created to represent a field injected from an anonym...
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()
Return the number of parameters declared in this function prototype, increasing it by one for the nex...
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.
virtual void HandleImplicitImportDecl(ImportDecl *D)
Handle an ImportDecl that was implicitly created due to an inclusion directive.
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).
DeclarationName - The name of a declaration.
unsigned short getMaxTLSAlign() const
Return the maximum alignment (in bits) of a TLS variable.
static ObjCIvarDecl::AccessControl TranslateIvarVisibility(tok::ObjCKeywordKind ivarVisibility)
TranslateIvarVisibility - Translate visibility from a token ID to an AST enum value.
CallingConv getCC() const
const Type * strip(QualType type)
Collect any qualifiers on the given type and return an unqualified type.
void handleTagNumbering(const TagDecl *Tag, Scope *TagScope)
bool lookupInBases(BaseMatchesCallback BaseMatches, CXXBasePaths &Paths) const
Look for entities within the base classes of this C++ class, transitively searching all base class su...
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.
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
isThisDeclarationADefinition - Returns whether this specific declaration of the function is also a de...
SourceLocation getLocStart() const LLVM_READONLY
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
EnumDecl - Represents an enum.
VisibilityAttr * mergeVisibilityAttr(Decl *D, SourceRange Range, VisibilityAttr::VisibilityType Vis, unsigned AttrSpellingListIndex)
detail::InMemoryDirectory::const_iterator E
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
bool hasName() const
hasName - Whether this declarator has a name, which might be an identifier (accessible via getIdentif...
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
bool isSingleResult() const
Determines if this names a single result which is not an unresolved value using decl.
static 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)
ActOnStartCXXMemberDeclarations - Invoked when we have parsed a C++ record definition's base-specifie...
bool isMsStruct(const ASTContext &C) const
isMsStrust - Get whether or not this is an ms_struct which can be turned on with an attribute...
DeclarationNameInfo - A collector data type for bundling together a DeclarationName and the correspnd...
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)
The name refers to a template whose specialization produces a type.
static const TST TST_unspecified
static FileScopeAsmDecl * Create(ASTContext &C, DeclContext *DC, StringLiteral *Str, SourceLocation AsmLoc, SourceLocation RParenLoc)
specific_decl_iterator - Iterates over a subrange of declarations stored in a DeclContext, providing only those that are of type SpecificDecl (or a class derived from it).
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.
bool DeclAttrsMatchCUDAMode(const LangOptions &LangOpts, Decl *D)
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
IgnoreParenImpCasts - Ignore parentheses and implicit casts.
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
isConstantInitializer - Returns true if this expression can be emitted to IR as a constant...
NamedDecl * ActOnTypedefDeclarator(Scope *S, Declarator &D, DeclContext *DC, TypeSourceInfo *TInfo, LookupResult &Previous)
Name lookup found a single declaration that met the criteria.
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 isEvaluatable(const ASTContext &Ctx, SideEffectsKind AllowSideEffects=SE_NoSideEffects) const
isEvaluatable - Call EvaluateAsRValue to see if this expression can be constant folded without side-e...
bool isObjCObjectType() const
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
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
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
unsigned getNumNegativeBits() const
Returns the width in bits required to store all the negative enumerators of this enum.
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)
ActOnTagDefinitionError - Invoked when there was an unrecoverable error parsing the definition of a t...
const T * getAs() const
Member-template getAs<specific type>'.
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.
unsigned hasPrototype
hasPrototype - This is true if the function had at least one typed parameter.
This template specialization was declared or defined by an explicit specialization (C++ [temp...
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)
isDeclInScope - If 'Ctx' is a function/method, isDeclInScope returns true if 'D' is in Scope 'S'...
EnumConstantDecl * CheckEnumConstant(EnumDecl *Enum, EnumConstantDecl *LastEnumConst, SourceLocation IdLoc, IdentifierInfo *Id, Expr *val)
static Scope * getScopeForDeclContext(Scope *S, DeclContext *DC)
Finds the scope corresponding to the given decl context, if it happens to be an enclosing scope...
QualType getIntegerType() const
getIntegerType - Return the integer type this enum decl corresponds to.
void setTypeSourceInfo(TypeSourceInfo *TI)
void setNonKeyFunction(const CXXMethodDecl *method)
Observe that the given method cannot be a key function.
bool isFunctionType() const
static const TST TST_typename
Expr * getArg(unsigned Arg)
Return the specified argument.
DeclContext * getRedeclContext()
getRedeclContext - Retrieve the context in which an entity conflicts with other entities of the same ...
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...
bool isTrivial() const
Whether this function is "trivial" in some specialized C++ senses.
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.
void ActOnPragmaRedefineExtname(IdentifierInfo *WeakName, IdentifierInfo *AliasName, SourceLocation PragmaLoc, SourceLocation WeakNameLoc, SourceLocation AliasNameLoc)
ActOnPragmaRedefineExtname - Called on well formed #pragma redefine_extname oldname newname...
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)
BuildAnonymousStructOrUnion - Handle the declaration of an anonymous structure or union...
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
getIntWidth/Align - Return the size of 'signed int' and 'unsigned int' for this target, in bits.
unsigned getLongLongWidth() const
getLongLongWidth/Align - Return the size of 'signed long long' and 'unsigned long long' for this targ...
A template-id, e.g., f<int>.
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)
setNamedTypeInfo - Sets the source type info associated to the name.
static void checkModuleImportContext(Sema &S, Module *M, SourceLocation ImportLoc, DeclContext *DC, bool FromInclude=false)
This is a scope that can contain a declaration.
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)
ParsedFreeStandingDeclSpec - This method is invoked when a declspec with no declarator (e...
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
isFunctionPrototypeScope - Return true if this scope is a function prototype scope.
const DeclContext * getCurObjCLexicalContext() const
bool isObjCGCStrong() const
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.
QualType deduceVarTypeFromInitializer(VarDecl *VDecl, DeclarationName Name, QualType Type, TypeSourceInfo *TSI, SourceRange Range, bool DirectInit, Expr *Init)
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).
An attributed type is a type to which a type attribute has been applied.
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.
bool Failed() const
Determine whether the initialization sequence is invalid.
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
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)
Helper method to turn variable array types into constant array types in certain situations which woul...
static DeclContext * getTagInjectionContext(DeclContext *DC)
Find the DeclContext in which a tag is implicitly declared if we see an elaborated type specifier in ...
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
A factory, from which one makes pools, from which one creates individual attributes which are dealloc...
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)
MergeVarDecl - We just parsed a variable 'New' which has the same name and scope as a previous declar...
bool isObjCObjectPointerType() const
void setDescribedVarTemplate(VarTemplateDecl *Template)
Represents a C array with an unspecified size.
static bool RebuildDeclaratorInCurrentInstantiation(Sema &S, Declarator &D, DeclarationName Name)
NeedsRebuildingInCurrentInstantiation - Checks whether the given declarator needs to be rebuilt in th...
ExprResult VerifyBitField(SourceLocation FieldLoc, IdentifierInfo *FieldName, QualType FieldTy, bool IsMsStruct, Expr *BitWidth, bool *ZeroWidth=nullptr)
VerifyBitField - verifies that a bit field expression is an ICE and has the correct width...
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...
Look up a friend of a local class.
bool isOutOfLine() const override
Determine whether this is or was instantiated from an out-of-line definition of a static data member...
BinaryConditionalOperator - The GNU extension to the conditional operator which allows the middle ope...
void setConstexpr(bool IC)
llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const
static bool hasIdenticalPassObjectSizeAttrs(const FunctionDecl *A, const FunctionDecl *B)
virtual bool isOutOfLine() const
Determine whether this declaration is declared out of line (outside its semantic context).
static bool anyDependentTemplateArguments(const TemplateArgumentLoc *Args, unsigned NumArgs, bool &InstantiationDependent)
Determine whether any of the given template arguments are dependent.
ObjCIvarDecl - Represents an ObjC instance variable.
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)
StorageClassSpecToVarDeclStorageClass - Maps a DeclSpec::SCS to a VarDecl::StorageClass.
static FixItHint CreateReplacement(CharSourceRange RemoveRange, StringRef Code)
Create a code modification hint that replaces the given source range with the given code string...
This class is used for builtin types like 'int'.
void addVLATypeCapture(SourceLocation Loc, QualType CaptureType)
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
getLongWidth/Align - Return the size of 'signed long' and 'unsigned long' for this target...
bool isTypeSpecOwned() const
TranslationUnitKind TUKind
The kind of translation unit we are processing.
StringLiteral - This represents a string literal expression, e.g.
Defines the clang::TargetInfo interface.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
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
void setDescribedFunctionTemplate(FunctionTemplateDecl *Template)
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...
void adjustExceptionSpec(FunctionDecl *FD, const FunctionProtoType::ExceptionSpecInfo &ESI, bool AsWritten=false)
Change the exception specification on a function once it is delay-parsed, instantiated, or computed.
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)
DeclhasAttr - returns true if decl Declaration already has the target attribute.
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.
CK_NoOp - A conversion which does not affect the type other than (possibly) adding qualifiers...
A reference to a declared variable, function, enum, etc.
void CheckConversionDeclarator(Declarator &D, QualType &R, StorageClass &SC)
CheckConversionDeclarator - Called by ActOnDeclarator to check the well-formednes of the conversion f...
bool isSet() const
Deprecated.
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()
getPrimaryContext - There may be many different declarations of the same entity (including forward de...
void ActOnObjCContainerFinishDefinition()
SourceManager & SourceMgr
bool isResolvedMSAsmLabel() const
BasePaths - Represents the set of paths from a derived class to one of its (direct or indirect) bases...
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 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.
void initializeFullCopy(TypeLoc Other)
Initializes this by copying its information from another TypeLoc of the same type.
static bool hasDependentAlignment(VarDecl *VD)
Determines if a variable's alignment is dependent.
void suppressDiagnostics()
Suppress the diagnostics that would normally fire because of this lookup.
const DeclaratorChunk & getTypeObject(unsigned i) const
Return the specified TypeInfo from this declarator.
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)
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)
NamedDecl - This represents a decl with a name.
void setIdentifier(const IdentifierInfo *Id, SourceLocation IdLoc)
Specify that this unqualified-id was parsed as an identifier.
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)
Represents a C array with a specified size that is not an integer-constant-expression.
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
Whether falling off this function implicitly returns null/zero.
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
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
Determine the nullability of the given type.
ParsedAttributes - A collection of parsed attributes.
void setDeletedAsWritten(bool D=true)
static bool isAttributeTargetADefinition(Decl *D)
DeclarationNameInfo GetNameForDeclarator(Declarator &D)
GetNameForDeclarator - Determine the full declaration name for the given Declarator.
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.
llvm::DenseMap< const EnumDecl *, llvm::APInt > FlagBitsCache
A cache of the flags available in enumerations with the flag_bits attribute.
iterator - Iterate over the decls of a specified declaration name.
void clear()
Clears out any current state.
A class which abstracts out some details necessary for making a call.
ParamInfo * Params
Params - This is a pointer to a new[]'d array of ParamInfo objects that describe the parameters speci...
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
hasLocalStorage - Returns true if a variable with function scope is a non-static local variable...
void setRBraceLoc(SourceLocation L)
ParsedTemplateTy Template
The declaration of the template corresponding to the template-name.
const RecordDecl * getParent() const
getParent - Returns the parent of this field declaration, which is the struct in which this method is...
ObjCCompatibleAliasDecl - Represents alias of a class.
Expr * IgnoreParens() LLVM_READONLY
IgnoreParens - Ignore parentheses.
const DeclSpec & getDeclSpec() const
getDeclSpec - Return the declaration-specifier that this declarator was declared with.
Decl * ActOnDeclarator(Scope *S, Declarator &D)
AttributeList - Represents a syntactic attribute.
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)
Filters out lookup results that don't fall within the given scope as determined by isDeclInScope...
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 ...