• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /freebsd-13-stable/contrib/llvm-project/clang/lib/Sema/

Lines Matching defs:Old

1546 /// We've determined that \p New is a redeclaration of \p Old. Check that they
1548 bool Sema::CheckRedeclarationModuleOwnership(NamedDecl *New, NamedDecl *Old) {
1554 Old->getOwningModuleForLinkage() != New->getOwningModuleForLinkage()) {
1555 New->setLocalOwningModule(Old->getOwningModule());
1561 Module *OldM = Old->getOwningModule();
1583 Diag(Old->getLocation(), diag::note_previous_declaration);
2174 NamedDecl *Old = Filter.next();
2177 if (S.isVisible(Old))
2182 if (auto *OldTD = dyn_cast<TypedefNameDecl>(Old)) {
2200 bool Sema::isIncompatibleTypedef(TypeDecl *Old, TypedefNameDecl *New) {
2202 if (TypedefNameDecl *OldTypedef = dyn_cast<TypedefNameDecl>(Old))
2205 OldType = Context.getTypeDeclType(Old);
2210 int Kind = isa<TypeAliasDecl>(Old) ? 1 : 0;
2213 if (Old->getLocation().isValid())
2214 notePreviousDefinition(Old, New->getLocation());
2223 int Kind = isa<TypeAliasDecl>(Old) ? 1 : 0;
2226 if (Old->getLocation().isValid())
2227 notePreviousDefinition(Old, New->getLocation());
2235 /// same name and scope as a previous declaration 'Old'. Figure out
2287 TypeDecl *Old = OldDecls.getAsSingle<TypeDecl>();
2288 if (!Old) {
2300 if (Old->isInvalidDecl())
2303 if (auto *OldTD = dyn_cast<TypedefNameDecl>(Old)) {
2339 if (isIncompatibleTypedef(Old, New))
2344 if (TypedefNameDecl *Typedef = dyn_cast<TypedefNameDecl>(Old)) {
2346 mergeDeclAttributes(New, Old);
2381 if (!isa<TypedefNameDecl>(Old))
2386 notePreviousDefinition(Old, New->getLocation());
2400 (Old->isImplicit() ||
2401 Context.getSourceManager().isInSystemHeader(Old->getLocation()) ||
2407 notePreviousDefinition(Old, New->getLocation());
2439 /// Merge alignment attributes from \p Old to \p New, taking into account the
2443 static bool mergeAlignedAttrs(Sema &S, NamedDecl *New, Decl *Old) {
2444 // Look for alignas attributes on Old, and pick out whichever attribute
2449 for (auto *I : Old->specific_attrs<AlignedAttr>()) {
2657 static void checkNewAttributesAfterDef(Sema &S, Decl *New, const Decl *Old) {
2661 const NamedDecl *Def = getDefinition(Old);
2824 /// mergeDeclAttributes - Copy attributes from the Old decl to the New one.
2825 void Sema::mergeDeclAttributes(NamedDecl *New, Decl *Old,
2827 if (UsedAttr *OldAttr = Old->getMostRecentDecl()->getAttr<UsedAttr>()) {
2833 if (!Old->hasAttrs() && !New->hasAttrs())
2839 const auto *OldConstInit = Old->getAttr<ConstInitAttr>();
2842 const auto *OldVD = cast<VarDecl>(Old);
2872 checkNewAttributesAfterDef(*this, New, Old);
2875 if (AsmLabelAttr *OldA = Old->getAttr<AsmLabelAttr>()) {
2881 } else if (Old->isUsed()) {
2885 << isa<FunctionDecl>(Old) << New->getAttr<AsmLabelAttr>()->getRange();
2891 if (const auto *OldAbiTagAttr = Old->getAttr<AbiTagAttr>()) {
2903 Diag(Old->getLocation(), diag::note_previous_declaration);
2908 if (New->hasAttr<SectionAttr>() && !Old->hasAttr<SectionAttr>()) {
2912 Diag(Old->getLocation(), diag::note_previous_declaration);
2919 if (NewCSA && !Old->hasAttr<CodeSegAttr>() &&
2923 Diag(Old->getLocation(), diag::note_previous_declaration);
2926 if (!Old->hasAttrs())
2935 for (auto *I : Old->specific_attrs<InheritableAttr>()) {
2961 if (mergeAlignedAttrs(*this, New, Old))
3055 getNoteDiagForInvalidRedeclaration(const T *Old, const T *New) {
3057 SourceLocation OldLocation = Old->getLocation();
3058 if (Old->isThisDeclarationADefinition())
3060 else if (Old->isImplicit()) {
3088 static bool haveIncompatibleLanguageLinkages(const T *Old, const T *New) {
3089 const DeclContext *DC = Old->getDeclContext();
3093 LanguageLinkage OldLinkage = Old->getLanguageLinkage();
3127 auto *Old = dyn_cast<ExpectedDecl>(OldS->getTargetDecl());
3128 if (Old &&
3129 !Old->getDeclContext()->getRedeclContext()->Equals(
3131 !(isExternC(Old) && isExternC(New)))
3132 Old = nullptr;
3134 if (!Old) {
3203 /// declaration 'Old'. Figure out how to resolve this situation,
3206 /// In C++, New and Old must be declarations that are not
3207 /// overloaded. Use IsOverload to determine whether New and Old are
3208 /// overloaded, and to select the Old declaration that New should be
3215 FunctionDecl *Old = OldD->getAsFunction();
3216 if (!Old) {
3230 OldD = Old = cast<FunctionDecl>(Shadow->getTargetDecl());
3240 if (Old->isInvalidDecl())
3244 if (!getASTContext().canBuiltinBeRedeclared(Old)) {
3245 Diag(New->getLocation(), diag::err_builtin_redeclare) << Old->getDeclName();
3246 Diag(Old->getLocation(), diag::note_previous_builtin_declaration)
3247 << Old << Old->getType();
3254 getNoteDiagForInvalidRedeclaration(Old, New);
3260 if (!isa<CXXMethodDecl>(New) && !isa<CXXMethodDecl>(Old) &&
3262 Old->hasExternalFormalLinkage() &&
3264 !canRedefineFunction(Old, getLangOpts())) {
3276 !Old->hasAttr<InternalLinkageAttr>()) {
3279 notePreviousDefinition(Old, New->getLocation());
3283 if (CheckRedeclarationModuleOwnership(New, Old))
3287 bool OldOvl = Old->hasAttr<OverloadableAttr>();
3288 if (OldOvl != New->hasAttr<OverloadableAttr>() && !Old->isImplicit()) {
3298 const Decl *DiagOld = Old;
3300 auto OldIter = llvm::find_if(Old->redecls(), [](const Decl *D) {
3306 DiagOld = OldIter == Old->redecls_end() ? nullptr : *OldIter;
3334 QualType OldQType = Context.getCanonicalType(Old->getType());
3343 FunctionDecl *First = Old->getFirstDecl();
3353 } else if (Old->getBuiltinID()) {
3437 if (!Old->isInlined() && New->isInlined() &&
3440 Old->isUsed(false) &&
3441 !Old->isDefined() && !New->isThisDeclarationADefinition())
3442 UndefinedButUsed.insert(std::make_pair(Old->getCanonicalDecl(),
3448 Old->isInlined() && !Old->hasAttr<GNUInlineAttr>()) {
3449 UndefinedButUsed.erase(Old->getCanonicalDecl());
3454 if (Old->getNumParams() > 0 && Old->getNumParams() == New->getNumParams() &&
3455 !hasIdenticalPassObjectSizeAttrs(Old, New)) {
3458 Diag(OldLocation, PrevDiag) << Old << Old->getType();
3469 // both Old and New if it resolved exception specifications, so grab the
3473 if (CheckEquivalentExceptionSpec(Old, New))
3475 OldQType = Context.getCanonicalType(Old->getType());
3483 QualType OldDeclaredReturnType = Old->getDeclaredReturnType();
3486 canFullyTypeCheckRedeclaration(New, Old, NewDeclaredReturnType,
3500 Diag(OldLocation, PrevDiag) << Old << Old->getType()
3501 << Old->getReturnTypeSourceRange();
3513 AutoType *OldAT = Old->getReturnType()->getContainedAutoType();
3526 const CXXMethodDecl *OldMethod = dyn_cast<CXXMethodDecl>(Old);
3547 Diag(OldLocation, PrevDiag) << Old << Old->getType();
3571 Diag(OldLocation, PrevDiag) << Old << Old->getType();
3601 if (NRA && !Old->hasAttr<CXX11NoReturnAttr>()) {
3603 Diag(Old->getFirstDecl()->getLocation(),
3612 if (CDA && !Old->hasAttr<CarriesDependencyAttr>()) {
3615 Diag(Old->getFirstDecl()->getLocation(),
3634 if (haveIncompatibleLanguageLinkages(Old, New)) {
3659 return MergeCompatibleFunctionDecls(New, Old, S, MergeTypeWithOld);
3664 if (!canFullyTypeCheckRedeclaration(New, Old, NewQType, OldQType))
3704 return MergeCompatibleFunctionDecls(New, Old, S, MergeTypeWithOld);
3724 Old->hasPrototype() && !New->hasPrototype() &&
3726 Old->getNumParams() == New->getNumParams()) {
3730 = Old->getType()->getAs<FunctionProtoType>();
3738 for (unsigned Idx = 0, End = Old->getNumParams();
3740 ParmVarDecl *OldParm = Old->getParamDecl(Idx);
3770 return MergeCompatibleFunctionDecls(New, Old, S, MergeTypeWithOld);
3782 if (Old->isImplicit() && (BuiltinID = Old->getBuiltinID())) {
3788 << Old << Old->getType();
3796 Diag(OldLocation, PrevDiag) << Old << Old->getType();
3806 /// redeclaration of Old.
3809 bool Sema::MergeCompatibleFunctionDecls(FunctionDecl *New, FunctionDecl *Old,
3812 mergeDeclAttributes(New, Old);
3815 if (Old->isPure())
3819 if (Old->getMostRecentDecl()->isUsed(false))
3824 if (New->getNumParams() == Old->getNumParams())
3827 ParmVarDecl *OldParam = Old->getParamDecl(i);
3833 return MergeCXXFunctionDecl(New, Old, S);
3838 QualType Merged = Context.mergeTypes(Old->getType(), New->getType());
3867 static void diagnoseVarDeclTypeMismatch(Sema &S, VarDecl *New, VarDecl* Old) {
3868 assert(!S.Context.hasSameType(New->getType(), Old->getType()));
3873 << New->getDeclName() << New->getType() << Old->getType();
3878 = getNoteDiagForInvalidRedeclaration(Old, New);
3884 /// scope as a previous declaration 'Old'. Figure out how to merge their types,
3890 void Sema::MergeVarDeclTypes(VarDecl *New, VarDecl *Old,
3892 if (New->isInvalidDecl() || Old->isInvalidDecl())
3900 } else if (Context.hasSameType(New->getType(), Old->getType())) {
3902 return MergeVarDeclExceptionSpecs(New, Old);
3909 else if (Old->getType()->isArrayType() && New->getType()->isArrayType()) {
3910 const ArrayType *OldArray = Context.getAsArrayType(Old->getType());
3913 // We are merging a variable declaration New into Old. If it has an array
3914 // bound, and that bound differs from Old's bound, we should diagnose the
3917 for (VarDecl *PrevVD = Old->getMostRecentDecl(); PrevVD;
3934 // has no array bound, it should not inherit one from Old, if Old is not
3939 MergedT = Old->getType();
3943 Old->getType()->isObjCObjectPointerType()) {
3945 Old->getType());
3951 MergedT = Context.mergeTypes(New->getType(), Old->getType());
3960 Old->getType()->isDependentType()) && New->isLocalVarDecl()) {
3968 return diagnoseVarDeclTypeMismatch(*this, New, Old);
4007 /// and scope as a previous declaration 'Old'. Figure out how to resolve this
4025 VarDecl *Old = nullptr;
4030 Old = OldTemplate ? OldTemplate->getTemplatedDecl() : nullptr;
4037 Old = dyn_cast<VarDecl>(Previous.getFoundDecl());
4045 if (!Old) {
4064 if (Old->isStaticDataMember() && !New->isOutOfLine()) {
4067 Diag(Old->getLocation(), diag::note_previous_declaration);
4071 mergeDeclAttributes(New, Old);
4075 Old->getStorageClass() == SC_None &&
4076 !Old->hasAttr<WeakImportAttr>()) {
4078 notePreviousDefinition(Old, New->getLocation());
4084 !Old->hasAttr<InternalLinkageAttr>()) {
4087 notePreviousDefinition(Old, New->getLocation());
4092 VarDecl *MostRecent = Old->getMostRecentDecl();
4093 if (MostRecent != Old) {
4100 MergeVarDeclTypes(New, Old, mergeTypeWithPrevious(*this, New, Old, Previous));
4107 getNoteDiagForInvalidRedeclaration(Old, New);
4112 Old->hasExternalFormalLinkage()) {
4133 if (New->hasExternalStorage() && Old->hasLinkage())
4137 Old->getCanonicalDecl()->getStorageClass() == SC_Static) {
4145 !Old->hasLinkage() && Old->isLocalVarDeclOrParm()) {
4150 if (Old->hasLinkage() && New->isLocalVarDeclOrParm() &&
4157 if (CheckRedeclarationModuleOwnership(New, Old))
4166 !(Old->getLexicalDeclContext()->isRecord() &&
4173 if (New->isInline() && !Old->getMostRecentDecl()->isInline()) {
4174 if (VarDecl *Def = Old->getDefinition()) {
4185 if (!Old->isInline() && New->isInline() && Old->isUsed(false) &&
4186 !Old->getDefinition() && !New->isThisDeclarationADefinition())
4187 UndefinedButUsed.insert(std::make_pair(Old->getCanonicalDecl(),
4190 if (New->getTLSKind() != Old->getTLSKind()) {
4191 if (!Old->getTLSKind()) {
4211 if (Old->isStaticDataMember() && Old->getCanonicalDecl()->isInline() &&
4212 Old->getCanonicalDecl()->isConstexpr()) {
4216 } else if (VarDecl *Def = Old->getDefinition()) {
4222 if (haveIncompatibleLanguageLinkages(Old, New)) {
4230 if (Old->getMostRecentDecl()->isUsed(false))
4234 New->setPreviousDecl(Old);
4237 adjustDeclContextForDeclaratorDecl(New, Old);
4240 New->setAccess(Old->getAccess());
4244 if (Old->isInline())
4248 void Sema::notePreviousDefinition(const NamedDecl *Old, SourceLocation New) {
4251 auto FOldDecLoc = SrcMgr.getDecomposedLoc(Old->getLocation());
4256 SrcMgr.getFilename(SrcMgr.getSpellingLoc(Old->getLocation()));
4287 noteFromModuleOrInclude(Old->getOwningModule(), OldIncLoc);
4292 Diag(Old->getLocation(), diag::note_use_ifdef_guards);
4299 if (Old->getLocation().isValid())
4300 Diag(Old->getLocation(), diag::note_previous_definition);
4303 /// We've just determined that \p Old and \p New both appear to be definitions
4305 bool Sema::checkVarDeclRedefinition(VarDecl *Old, VarDecl *New) {
4306 if (!hasVisibleDefinition(Old) &&
4317 if (auto *OldTD = Old->getDescribedVarTemplate())
4319 makeMergedDefinitionVisible(Old);
4323 notePreviousDefinition(Old, New->getLocation());
11603 if (VarDecl *Old = VDecl->getPreviousDecl()) {
11606 MergeVarDeclTypes(VDecl, Old, /*MergeTypeWithPrevious*/ false);