Lines Matching refs:Old
1563 /// We've determined that \p New is a redeclaration of \p Old. Check that they
1565 bool Sema::CheckRedeclarationModuleOwnership(NamedDecl *New, NamedDecl *Old) {
1571 Old->getOwningModuleForLinkage() != New->getOwningModuleForLinkage()) {
1572 New->setLocalOwningModule(Old->getOwningModule());
1578 Module *OldM = Old->getOwningModule();
1600 Diag(Old->getLocation(), diag::note_previous_declaration);
2168 NamedDecl *Old = Filter.next();
2171 if (S.isVisible(Old))
2176 if (auto *OldTD = dyn_cast<TypedefNameDecl>(Old)) {
2194 bool Sema::isIncompatibleTypedef(TypeDecl *Old, TypedefNameDecl *New) {
2196 if (TypedefNameDecl *OldTypedef = dyn_cast<TypedefNameDecl>(Old))
2199 OldType = Context.getTypeDeclType(Old);
2204 int Kind = isa<TypeAliasDecl>(Old) ? 1 : 0;
2207 if (Old->getLocation().isValid())
2208 notePreviousDefinition(Old, New->getLocation());
2217 int Kind = isa<TypeAliasDecl>(Old) ? 1 : 0;
2220 if (Old->getLocation().isValid())
2221 notePreviousDefinition(Old, New->getLocation());
2229 /// same name and scope as a previous declaration 'Old'. Figure out
2280 // Verify the old decl was also a type.
2281 TypeDecl *Old = OldDecls.getAsSingle<TypeDecl>();
2282 if (!Old) {
2293 // If the old declaration is invalid, just give up here.
2294 if (Old->isInvalidDecl())
2297 if (auto *OldTD = dyn_cast<TypedefNameDecl>(Old)) {
2313 // Make the old tag definition visible.
2333 if (isIncompatibleTypedef(Old, New))
2337 // the old declaration was a typedef.
2338 if (TypedefNameDecl *Typedef = dyn_cast<TypedefNameDecl>(Old)) {
2340 mergeDeclAttributes(New, Old);
2375 if (!isa<TypedefNameDecl>(Old))
2380 notePreviousDefinition(Old, New->getLocation());
2394 (Old->isImplicit() ||
2395 Context.getSourceManager().isInSystemHeader(Old->getLocation()) ||
2401 notePreviousDefinition(Old, New->getLocation());
2433 /// Merge alignment attributes from \p Old to \p New, taking into account the
2437 static bool mergeAlignedAttrs(Sema &S, NamedDecl *New, Decl *Old) {
2438 // Look for alignas attributes on Old, and pick out whichever attribute
2443 for (auto *I : Old->specific_attrs<AlignedAttr>()) {
2532 // Ensure we have an alignas attribute if the old declaration had one.
2664 static void checkNewAttributesAfterDef(Sema &S, Decl *New, const Decl *Old) {
2668 const NamedDecl *Def = getDefinition(Old);
2784 // Figure out a good way to write this specifier on the old declaration.
2831 /// mergeDeclAttributes - Copy attributes from the Old decl to the New one.
2832 void Sema::mergeDeclAttributes(NamedDecl *New, Decl *Old,
2834 if (UsedAttr *OldAttr = Old->getMostRecentDecl()->getAttr<UsedAttr>()) {
2839 if (RetainAttr *OldAttr = Old->getMostRecentDecl()->getAttr<RetainAttr>()) {
2845 if (!Old->hasAttrs() && !New->hasAttrs())
2851 const auto *OldConstInit = Old->getAttr<ConstInitAttr>();
2854 const auto *OldVD = cast<VarDecl>(Old);
2884 checkNewAttributesAfterDef(*this, New, Old);
2887 if (AsmLabelAttr *OldA = Old->getAttr<AsmLabelAttr>()) {
2893 } else if (Old->isUsed()) {
2897 << isa<FunctionDecl>(Old) << New->getAttr<AsmLabelAttr>()->getRange();
2903 if (const auto *OldAbiTagAttr = Old->getAttr<AbiTagAttr>()) {
2915 Diag(Old->getLocation(), diag::note_previous_declaration);
2920 if (New->hasAttr<SectionAttr>() && !Old->hasAttr<SectionAttr>()) {
2924 Diag(Old->getLocation(), diag::note_previous_declaration);
2931 if (NewCSA && !Old->hasAttr<CodeSegAttr>() &&
2935 Diag(Old->getLocation(), diag::note_previous_declaration);
2938 if (!Old->hasAttrs())
2947 for (auto *I : Old->specific_attrs<InheritableAttr>()) {
2974 if (mergeAlignedAttrs(*this, New, Old))
2980 /// mergeParamDeclAttributes - Copy attributes from the old parameter
3068 getNoteDiagForInvalidRedeclaration(const T *Old, const T *New) {
3070 SourceLocation OldLocation = Old->getLocation();
3071 if (Old->isThisDeclarationADefinition())
3073 else if (Old->isImplicit()) {
3101 static bool haveIncompatibleLanguageLinkages(const T *Old, const T *New) {
3102 const DeclContext *DC = Old->getDeclContext();
3106 LanguageLinkage OldLinkage = Old->getLanguageLinkage();
3140 auto *Old = dyn_cast<ExpectedDecl>(OldS->getTargetDecl());
3141 if (Old &&
3142 !Old->getDeclContext()->getRedeclContext()->Equals(
3144 !(isExternC(Old) && isExternC(New)))
3145 Old = nullptr;
3147 if (!Old) {
3216 /// declaration 'Old'. Figure out how to resolve this situation,
3219 /// In C++, New and Old must be declarations that are not
3220 /// overloaded. Use IsOverload to determine whether New and Old are
3221 /// overloaded, and to select the Old declaration that New should be
3227 // Verify the old decl was also a function.
3228 FunctionDecl *Old = OldD->getAsFunction();
3229 if (!Old) {
3243 OldD = Old = cast<FunctionDecl>(Shadow->getTargetDecl());
3252 // If the old declaration was found in an inline namespace and the new
3254 adjustDeclContextForDeclaratorDecl(New, Old);
3256 // If the old declaration is invalid, just give up here.
3257 if (Old->isInvalidDecl())
3261 if (!getASTContext().canBuiltinBeRedeclared(Old)) {
3262 Diag(New->getLocation(), diag::err_builtin_redeclare) << Old->getDeclName();
3263 Diag(Old->getLocation(), diag::note_previous_builtin_declaration)
3264 << Old << Old->getType();
3271 getNoteDiagForInvalidRedeclaration(Old, New);
3273 // Don't complain about this if we're in GNU89 mode and the old function
3277 if (!isa<CXXMethodDecl>(New) && !isa<CXXMethodDecl>(Old) &&
3279 Old->hasExternalFormalLinkage() &&
3281 !canRedefineFunction(Old, getLangOpts())) {
3293 !Old->hasAttr<InternalLinkageAttr>()) {
3296 notePreviousDefinition(Old, New->getLocation());
3300 if (CheckRedeclarationModuleOwnership(New, Old))
3304 bool OldOvl = Old->hasAttr<OverloadableAttr>();
3305 if (OldOvl != New->hasAttr<OverloadableAttr>() && !Old->isImplicit()) {
3315 const Decl *DiagOld = Old;
3317 auto OldIter = llvm::find_if(Old->redecls(), [](const Decl *D) {
3323 DiagOld = OldIter == Old->redecls_end() ? nullptr : *OldIter;
3351 QualType OldQType = Context.getCanonicalType(Old->getType());
3360 Old->getFirstDecl();
3370 } else if (Old->getBuiltinID()) {
3372 // so we check if the old one is a builtin.
3454 if (!Old->isInlined() && New->isInlined() &&
3457 Old->isUsed(false) &&
3458 !Old->isDefined() && !New->isThisDeclarationADefinition())
3459 UndefinedButUsed.insert(std::make_pair(Old->getCanonicalDecl(),
3465 Old->isInlined() && !Old->hasAttr<GNUInlineAttr>()) {
3466 UndefinedButUsed.erase(Old->getCanonicalDecl());
3471 if (Old->getNumParams() > 0 && Old->getNumParams() == New->getNumParams() &&
3472 !hasIdenticalPassObjectSizeAttrs(Old, New)) {
3475 Diag(OldLocation, PrevDiag) << Old << Old->getType();
3486 // both Old and New if it resolved exception specifications, so grab the
3490 if (CheckEquivalentExceptionSpec(Old, New))
3492 OldQType = Context.getCanonicalType(Old->getType());
3500 QualType OldDeclaredReturnType = Old->getDeclaredReturnType();
3503 canFullyTypeCheckRedeclaration(New, Old, NewDeclaredReturnType,
3517 Diag(OldLocation, PrevDiag) << Old << Old->getType()
3518 << Old->getReturnTypeSourceRange();
3529 // defined, copy the deduced value from the old declaration.
3530 AutoType *OldAT = Old->getReturnType()->getContainedAutoType();
3543 const CXXMethodDecl *OldMethod = dyn_cast<CXXMethodDecl>(Old);
3564 Diag(OldLocation, PrevDiag) << Old << Old->getType();
3588 Diag(OldLocation, PrevDiag) << Old << Old->getType();
3618 if (NRA && !Old->hasAttr<CXX11NoReturnAttr>()) {
3620 Diag(Old->getFirstDecl()->getLocation(),
3629 if (CDA && !Old->hasAttr<CarriesDependencyAttr>()) {
3632 Diag(Old->getFirstDecl()->getLocation(),
3641 // noreturn should now match unless the old type info didn't have it.
3651 if (haveIncompatibleLanguageLinkages(Old, New)) {
3676 return MergeCompatibleFunctionDecls(New, Old, S, MergeTypeWithOld);
3681 if (!canFullyTypeCheckRedeclaration(New, Old, NewQType, OldQType))
3696 // The old declaration provided a function prototype, but the
3721 return MergeCompatibleFunctionDecls(New, Old, S, MergeTypeWithOld);
3741 Old->hasPrototype() && !New->hasPrototype() &&
3743 Old->getNumParams() == New->getNumParams()) {
3747 = Old->getType()->getAs<FunctionProtoType>();
3755 for (unsigned Idx = 0, End = Old->getNumParams();
3757 ParmVarDecl *OldParm = Old->getParamDecl(Idx);
3787 return MergeCompatibleFunctionDecls(New, Old, S, MergeTypeWithOld);
3799 if (Old->isImplicit() && (BuiltinID = Old->getBuiltinID())) {
3805 << Old << Old->getType();
3813 Diag(OldLocation, PrevDiag) << Old << Old->getType();
3821 /// properties of function declarations from the old declaration to
3823 /// redeclaration of Old.
3826 bool Sema::MergeCompatibleFunctionDecls(FunctionDecl *New, FunctionDecl *Old,
3829 mergeDeclAttributes(New, Old);
3832 if (Old->isPure())
3836 if (Old->getMostRecentDecl()->isUsed(false))
3841 if (New->getNumParams() == Old->getNumParams())
3844 ParmVarDecl *OldParam = Old->getParamDecl(i);
3850 return MergeCXXFunctionDecl(New, Old, S);
3853 // and argument types. Per C11 6.2.7/4, only update the type if the old decl
3855 QualType Merged = Context.mergeTypes(Old->getType(), New->getType());
3885 static void diagnoseVarDeclTypeMismatch(Sema &S, VarDecl *New, VarDecl* Old) {
3886 assert(!S.Context.hasSameType(New->getType(), Old->getType()));
3891 << New->getDeclName() << New->getType() << Old->getType();
3896 = getNoteDiagForInvalidRedeclaration(Old, New);
3902 /// scope as a previous declaration 'Old'. Figure out how to merge their types,
3908 void Sema::MergeVarDeclTypes(VarDecl *New, VarDecl *Old,
3910 if (New->isInvalidDecl() || Old->isInvalidDecl())
3918 } else if (Context.hasSameType(New->getType(), Old->getType())) {
3920 return MergeVarDeclExceptionSpecs(New, Old);
3927 else if (Old->getType()->isArrayType() && New->getType()->isArrayType()) {
3928 const ArrayType *OldArray = Context.getAsArrayType(Old->getType());
3931 // We are merging a variable declaration New into Old. If it has an array
3932 // bound, and that bound differs from Old's bound, we should diagnose the
3935 for (VarDecl *PrevVD = Old->getMostRecentDecl(); PrevVD;
3952 // has no array bound, it should not inherit one from Old, if Old is not
3957 MergedT = Old->getType();
3961 Old->getType()->isObjCObjectPointerType()) {
3963 Old->getType());
3969 MergedT = Context.mergeTypes(New->getType(), Old->getType());
3978 Old->getType()->isDependentType()) && New->isLocalVarDecl()) {
3979 // If the old type was dependent, we can't merge with it, so the new type
3986 return diagnoseVarDeclTypeMismatch(*this, New, Old);
3989 // Don't actually update the type on the new declaration if the old
4017 // If the old declaration was function-local, don't merge with its
4025 /// and scope as a previous declaration 'Old'. Figure out how to resolve this
4042 // Verify the old decl was also a variable or variable template.
4043 VarDecl *Old = nullptr;
4048 Old = OldTemplate ? OldTemplate->getTemplatedDecl() : nullptr;
4055 Old = dyn_cast<VarDecl>(Previous.getFoundDecl());
4063 if (!Old) {
4071 // If the old declaration was found in an inline namespace and the new
4073 adjustDeclContextForDeclaratorDecl(New, Old);
4086 if (Old->isStaticDataMember() && !New->isOutOfLine()) {
4089 Diag(Old->getLocation(), diag::note_previous_declaration);
4093 mergeDeclAttributes(New, Old);
4097 Old->getStorageClass() == SC_None &&
4098 !Old->hasAttr<WeakImportAttr>()) {
4100 notePreviousDefinition(Old, New->getLocation());
4106 !Old->hasAttr<InternalLinkageAttr>()) {
4109 notePreviousDefinition(Old, New->getLocation());
4114 VarDecl *MostRecent = Old->getMostRecentDecl();
4115 if (MostRecent != Old) {
4122 MergeVarDeclTypes(New, Old, mergeTypeWithPrevious(*this, New, Old, Previous));
4129 getNoteDiagForInvalidRedeclaration(Old, New);
4134 Old->hasExternalFormalLinkage()) {
4155 if (New->hasExternalStorage() && Old->hasLinkage())
4159 Old->getCanonicalDecl()->getStorageClass() == SC_Static) {
4167 !Old->hasLinkage() && Old->isLocalVarDeclOrParm()) {
4172 if (Old->hasLinkage() && New->isLocalVarDeclOrParm() &&
4179 if (CheckRedeclarationModuleOwnership(New, Old))
4188 !(Old->getLexicalDeclContext()->isRecord() &&
4195 if (New->isInline() && !Old->getMostRecentDecl()->isInline()) {
4196 if (VarDecl *Def = Old->getDefinition()) {
4207 if (!Old->isInline() && New->isInline() && Old->isUsed(false) &&
4208 !Old->getDefinition() && !New->isThisDeclarationADefinition())
4209 UndefinedButUsed.insert(std::make_pair(Old->getCanonicalDecl(),
4212 if (New->getTLSKind() != Old->getTLSKind()) {
4213 if (!Old->getTLSKind()) {
4233 if (Old->isStaticDataMember() && Old->getCanonicalDecl()->isInline() &&
4234 Old->getCanonicalDecl()->isConstexpr()) {
4238 } else if (VarDecl *Def = Old->getDefinition()) {
4244 if (haveIncompatibleLanguageLinkages(Old, New)) {
4252 if (Old->getMostRecentDecl()->isUsed(false))
4256 New->setPreviousDecl(Old);
4261 New->setAccess(Old->getAccess());
4265 if (Old->isInline())
4269 void Sema::notePreviousDefinition(const NamedDecl *Old, SourceLocation New) {
4272 auto FOldDecLoc = SrcMgr.getDecomposedLoc(Old->getLocation());
4277 SrcMgr.getFilename(SrcMgr.getSpellingLoc(Old->getLocation()));
4308 noteFromModuleOrInclude(Old->getOwningModule(), OldIncLoc);
4313 Diag(Old->getLocation(), diag::note_use_ifdef_guards);
4320 if (Old->getLocation().isValid())
4321 Diag(Old->getLocation(), diag::note_previous_definition);
4324 /// We've just determined that \p Old and \p New both appear to be definitions
4326 bool Sema::checkVarDeclRedefinition(VarDecl *Old, VarDecl *New) {
4327 if (!hasVisibleDefinition(Old) &&
4338 if (auto *OldTD = Old->getDescribedVarTemplate())
4340 makeMergedDefinitionVisible(Old);
4344 notePreviousDefinition(Old, New->getLocation());
7789 // Both the old and new declarations have C language linkage. This is a
8732 // Trivial and standard-layout types C++17 [basic.types] (plain old data
9780 // extension for compatibility with old SWIG code which likes to
10074 /// \param OldD The old declaration.
10076 /// \param OldT The portion of the type of the old declaration to check.
10428 // If the old decl is NOT MultiVersioned yet, and we don't cause that
11800 if (VarDecl *Old = VDecl->getPreviousDecl()) {
11803 MergeVarDeclTypes(VDecl, Old, /*MergeTypeWithPrevious*/ false);
15921 // Recover by ignoring the old declaration.
16051 // Postpone making the old definition visible until after we