Home | History | Annotate | Download | only in Sema

Lines Matching defs:Old

1717     NamedDecl *old = filter.next();
1720 if (!old->isHidden())
1723 if (!old->isExternallyVisible())
1730 bool Sema::isIncompatibleTypedef(TypeDecl *Old, TypedefNameDecl *New) {
1732 if (TypedefNameDecl *OldTypedef = dyn_cast<TypedefNameDecl>(Old))
1735 OldType = Context.getTypeDeclType(Old);
1740 int Kind = isa<TypeAliasDecl>(Old) ? 1 : 0;
1743 if (Old->getLocation().isValid())
1744 Diag(Old->getLocation(), diag::note_previous_definition);
1753 int Kind = isa<TypeAliasDecl>(Old) ? 1 : 0;
1756 if (Old->getLocation().isValid())
1757 Diag(Old->getLocation(), diag::note_previous_definition);
1765 /// same name and scope as a previous declaration 'Old'. Figure out
1815 // Verify the old decl was also a type.
1816 TypeDecl *Old = OldDecls.getAsSingle<TypeDecl>();
1817 if (!Old) {
1828 // If the old declaration is invalid, just give up here.
1829 if (Old->isInvalidDecl())
1834 if (isIncompatibleTypedef(Old, New))
1838 // the old declaration was a typedef.
1839 if (TypedefNameDecl *Typedef = dyn_cast<TypedefNameDecl>(Old)) {
1841 mergeDeclAttributes(New, Old);
1876 if (!isa<TypedefNameDecl>(Old))
1881 Diag(Old->getLocation(), diag::note_previous_definition);
1894 (Context.getSourceManager().isInSystemHeader(Old->getLocation()) ||
1900 Diag(Old->getLocation(), diag::note_previous_definition);
1933 /// Merge alignment attributes from \p Old to \p New, taking into account the
1937 static bool mergeAlignedAttrs(Sema &S, NamedDecl *New, Decl *Old) {
1938 // Look for alignas attributes on Old, and pick out whichever attribute
1943 for (auto *I : Old->specific_attrs<AlignedAttr>()) {
2032 // Ensure we have an alignas attribute if the old declaration had one.
2119 static void checkNewAttributesAfterDef(Sema &S, Decl *New, const Decl *Old) {
2123 const Decl *Def = getDefinition(Old);
2193 /// mergeDeclAttributes - Copy attributes from the Old decl to the New one.
2194 void Sema::mergeDeclAttributes(NamedDecl *New, Decl *Old,
2196 if (UsedAttr *OldAttr = Old->getMostRecentDecl()->getAttr<UsedAttr>()) {
2202 if (!Old->hasAttrs() && !New->hasAttrs())
2206 checkNewAttributesAfterDef(*this, New, Old);
2208 if (!Old->hasAttrs())
2217 for (auto *I : Old->specific_attrs<InheritableAttr>()) {
2244 if (mergeAlignedAttrs(*this, New, Old))
2250 /// mergeParamDeclAttributes - Copy attributes from the old parameter
2333 getNoteDiagForInvalidRedeclaration(const T *Old, const T *New) {
2335 SourceLocation OldLocation = Old->getLocation();
2336 if (Old->isThisDeclarationADefinition())
2338 else if (Old->isImplicit()) {
2366 static bool haveIncompatibleLanguageLinkages(const T *Old, const T *New) {
2367 const DeclContext *DC = Old->getDeclContext();
2371 LanguageLinkage OldLinkage = Old->getLanguageLinkage();
2381 /// declaration 'Old'. Figure out how to resolve this situation,
2384 /// In C++, New and Old must be declarations that are not
2385 /// overloaded. Use IsOverload to determine whether New and Old are
2386 /// overloaded, and to select the Old declaration that New should be
2392 // Verify the old decl was also a function.
2393 FunctionDecl *Old = OldD->getAsFunction();
2394 if (!Old) {
2412 Old = dyn_cast<FunctionDecl>(Shadow->getTargetDecl());
2413 if (Old &&
2414 !Old->getDeclContext()->getRedeclContext()->Equals(
2416 !(Old->isExternC() && New->isExternC()))
2417 Old = nullptr;
2419 if (!Old) {
2426 OldD = Old;
2435 // If the old declaration is invalid, just give up here.
2436 if (Old->isInvalidDecl())
2442 getNoteDiagForInvalidRedeclaration(Old, New);
2444 // Don't complain about this if we're in GNU89 mode and the old function
2448 if (!isa<CXXMethodDecl>(New) && !isa<CXXMethodDecl>(Old) &&
2450 Old->hasExternalFormalLinkage() &&
2452 !canRedefineFunction(Old, getLangOpts())) {
2477 QualType OldQType = Context.getCanonicalType(Old->getType());
2486 FunctionDecl *First = Old->getFirstDecl();
2554 if (!Old->isInlined() && New->isInlined() &&
2557 Old->isUsed(false) &&
2558 !Old->isDefined() && !New->isThisDeclarationADefinition())
2559 UndefinedButUsed.insert(std::make_pair(Old->getCanonicalDecl(),
2565 Old->isInlined() && !Old->hasAttr<GNUInlineAttr>()) {
2566 UndefinedButUsed.erase(Old->getCanonicalDecl());
2581 (Old->getTypeSourceInfo()
2582 ? Old->getTypeSourceInfo()->getType()->castAs<FunctionType>()
2602 Diag(OldLocation, PrevDiag) << Old << Old->getType()
2603 << Old->getReturnTypeSourceRange();
2614 // defined, copy the deduced value from the old declaration.
2615 AutoType *OldAT = Old->getReturnType()->getContainedAutoType();
2628 const CXXMethodDecl *OldMethod = dyn_cast<CXXMethodDecl>(Old);
2649 Diag(OldLocation, PrevDiag) << Old << Old->getType();
2673 Diag(OldLocation, PrevDiag) << Old << Old->getType();
2702 if (NRA && !Old->hasAttr<CXX11NoReturnAttr>()) {
2704 Diag(Old->getFirstDecl()->getLocation(),
2713 if (CDA && !Old->hasAttr<CarriesDependencyAttr>()) {
2716 Diag(Old->getFirstDecl()->getLocation(),
2725 // noreturn should now match unless the old type info didn't have it.
2735 if (haveIncompatibleLanguageLinkages(Old, New)) {
2755 return MergeCompatibleFunctionDecls(New, Old, S, MergeTypeWithOld);
2760 // if either the old or new type is dependent. We'll merge the types
2777 // The old declaration provided a function prototype, but the
2802 return MergeCompatibleFunctionDecls(New, Old, S, MergeTypeWithOld);
2817 Old->hasPrototype() && !New->hasPrototype() &&
2819 Old->getNumParams() == New->getNumParams()) {
2823 = Old->getType()->getAs<FunctionProtoType>();
2831 for (unsigned Idx = 0, End = Old->getNumParams();
2833 ParmVarDecl *OldParm = Old->getParamDecl(Idx);
2863 return MergeCompatibleFunctionDecls(New, Old, S, MergeTypeWithOld);
2875 if (Old->isImplicit() && (BuiltinID = Old->getBuiltinID())) {
2881 << Old << Old->getType();
2901 Diag(OldLocation, PrevDiag) << Old << Old->getType();
2909 /// properties of function declarations from the old declaration to
2911 /// redeclaration of Old.
2914 bool Sema::MergeCompatibleFunctionDecls(FunctionDecl *New, FunctionDecl *Old,
2917 mergeDeclAttributes(New, Old);
2920 if (Old->isPure())
2924 if (Old->getMostRecentDecl()->isUsed(false))
2929 if (New->getNumParams() == Old->getNumParams())
2931 mergeParamDeclAttributes(New->getParamDecl(i), Old->getParamDecl(i),
2935 return MergeCXXFunctionDecl(New, Old, S);
2938 // and argument types. Per C11 6.2.7/4, only update the type if the old decl
2940 QualType Merged = Context.mergeTypes(Old->getType(), New->getType());
2969 /// scope as a previous declaration 'Old'. Figure out how to merge their types,
2975 void Sema::MergeVarDeclTypes(VarDecl *New, VarDecl *Old,
2977 if (New->isInvalidDecl() || Old->isInvalidDecl())
2985 } else if (Context.hasSameType(New->getType(), Old->getType())) {
2987 return MergeVarDeclExceptionSpecs(New, Old);
2994 else if (Old->getType()->isIncompleteArrayType() &&
2996 const ArrayType *OldArray = Context.getAsArrayType(Old->getType());
3001 } else if (Old->getType()->isArrayType() &&
3003 const ArrayType *OldArray = Context.getAsArrayType(Old->getType());
3007 MergedT = Old->getType();
3009 Old->getType()->isObjCObjectPointerType()) {
3011 Old->getType());
3017 MergedT = Context.mergeTypes(New->getType(), Old->getType());
3026 Old->getType()->isDependentType()) && New->isLocalVarDecl()) {
3027 // If the old type was dependent, we can't merge with it, so the new type
3045 << New->getDeclName() << New->getType() << Old->getType();
3046 Diag(Old->getLocation(), diag::note_previous_definition);
3050 // Don't actually update the type on the new declaration if the old
3078 // If the old declaration was function-local, don't merge with its
3086 /// and scope as a previous declaration 'Old'. Figure out how to resolve this
3100 // Verify the old decl was also a variable or variable template.
3101 VarDecl *Old = nullptr;
3106 Old = OldTemplate ? OldTemplate->getTemplatedDecl() : nullptr;
3108 Old = dyn_cast<VarDecl>(Previous.getFoundDecl());
3110 if (!Old) {
3118 if (!shouldLinkPossiblyHiddenDecl(Old, New))
3132 if (Old->isStaticDataMember() && !New->isOutOfLine()) {
3135 Diag(Old->getLocation(), diag::note_previous_declaration);
3139 mergeDeclAttributes(New, Old);
3143 Old->getStorageClass() == SC_None &&
3144 !Old->hasAttr<WeakImportAttr>()) {
3146 Diag(Old->getLocation(), diag::note_previous_definition);
3152 MergeVarDeclTypes(New, Old, mergeTypeWithPrevious(*this, New, Old, Previous));
3160 getNoteDiagForInvalidRedeclaration(Old, New);
3165 Old->hasExternalFormalLinkage()) {
3186 if (New->hasExternalStorage() && Old->hasLinkage())
3190 Old->getCanonicalDecl()->getStorageClass() == SC_Static) {
3198 !Old->hasLinkage() && Old->isLocalVarDecl()) {
3203 if (Old->hasLinkage() && New->isLocalVarDecl() &&
3216 !(Old->getLexicalDeclContext()->isRecord() &&
3223 if (New->getTLSKind() != Old->getTLSKind()) {
3224 if (!Old->getTLSKind()) {
3245 (Def = Old->getDefinition())) {
3252 if (haveIncompatibleLanguageLinkages(Old, New)) {
3260 if (Old->getMostRecentDecl()->isUsed(false))
3264 New->setPreviousDecl(Old);
3269 New->setAccess(Old->getAccess());
5842 // Both the old and new declarations have C language linkage. This is a
7498 // extension for compatibility with old SWIG code which likes to
8370 if (VarDecl *Old = VDecl->getPreviousDecl()) {
8373 MergeVarDeclTypes(VDecl, Old, /*MergeTypeWithPrevious*/false);