Home | History | Annotate | Download | only in Sema

Lines Matching refs:New

984         // Update the name, so that the caller has the new name.
1299 // the containing DC of TD, because the new context will be some pre-existing
1444 /// whether some new function is actually an overload. It will return
1451 const FunctionDecl *New) {
1460 New->hasAttr<OverloadableAttr>());
1563 /// We've determined that \p New is a redeclaration of \p Old. Check that they
1565 bool Sema::CheckRedeclarationModuleOwnership(NamedDecl *New, NamedDecl *Old) {
1570 if (New->getFriendObjectKind() &&
1571 Old->getOwningModuleForLinkage() != New->getOwningModuleForLinkage()) {
1572 New->setLocalOwningModule(Old->getOwningModule());
1573 makeMergedDefinitionVisible(New);
1577 Module *NewM = New->getOwningModule();
1594 Diag(New->getLocation(), diag::err_mismatched_owning_module)
1595 << New
1601 New->setInvalidDecl();
2063 FunctionDecl *New = FunctionDecl::Create(Context, Parent, Loc, Loc, II, Type,
2066 New->setImplicit();
2067 New->addAttr(BuiltinAttr::CreateImplicit(Context, ID));
2075 Context, New, SourceLocation(), SourceLocation(), nullptr,
2080 New->setParams(Params);
2083 AddKnownFunctionAttributes(New);
2084 return New;
2137 FunctionDecl *New = CreateBuiltin(II, R, ID, Loc);
2138 RegisterLocallyScopedExternCDecl(New, S);
2145 CurContext = New->getDeclContext();
2146 PushOnScopeChains(New, TUScope);
2148 return New;
2194 bool Sema::isIncompatibleTypedef(TypeDecl *Old, TypedefNameDecl *New) {
2200 QualType NewType = New->getUnderlyingType();
2205 Diag(New->getLocation(), diag::err_redefinition_variably_modified_typedef)
2208 notePreviousDefinition(Old, New->getLocation());
2209 New->setInvalidDecl();
2218 Diag(New->getLocation(), diag::err_redefinition_different_typedef)
2221 notePreviousDefinition(Old, New->getLocation());
2222 New->setInvalidDecl();
2228 /// MergeTypedefNameDecl - We just parsed a typedef 'New' which has the
2231 /// diagnostics as appropriate. If there was an error, set New to be invalid.
2233 void Sema::MergeTypedefNameDecl(Scope *S, TypedefNameDecl *New,
2235 // If the new decl is known invalid already, don't bother doing any
2237 if (New->isInvalidDecl()) return;
2242 const IdentifierInfo *TypeID = New->getIdentifier();
2249 QualType T = New->getUnderlyingType();
2259 New->setTypeForDecl(Context.getObjCIdType().getTypePtr());
2265 Context.setObjCClassRedefinitionType(New->getUnderlyingType());
2267 New->setTypeForDecl(Context.getObjCClassType().getTypePtr());
2272 Context.setObjCSelRedefinitionType(New->getUnderlyingType());
2274 New->setTypeForDecl(Context.getObjCSelType().getTypePtr());
2283 Diag(New->getLocation(), diag::err_redefinition_different_kind)
2284 << New->getDeclName();
2288 notePreviousDefinition(OldD, New->getLocation());
2290 return New->setInvalidDecl();
2295 return New->setInvalidDecl();
2299 auto *NewTag = New->getAnonDeclWithTypedefName();
2306 New->setTypeForDecl(OldTD->getTypeForDecl());
2308 New->setModedTypeSourceInfo(OldTD->getTypeSourceInfo(),
2311 New->setTypeSourceInfo(OldTD->getTypeSourceInfo());
2333 if (isIncompatibleTypedef(Old, New))
2339 New->setPreviousDecl(Typedef);
2340 mergeDeclAttributes(New, Old);
2378 Diag(New->getLocation(), diag::err_redefinition)
2379 << New->getDeclName();
2380 notePreviousDefinition(Old, New->getLocation());
2381 return New->setInvalidDecl();
2396 Context.getSourceManager().isInSystemHeader(New->getLocation())))
2399 Diag(New->getLocation(), diag::ext_redefinition_of_typedef)
2400 << New->getDeclName();
2401 notePreviousDefinition(Old, New->getLocation());
2433 /// Merge alignment attributes from \p Old to \p New, taking into account the
2436 /// \return \c true if any attributes were added to \p New.
2437 static bool mergeAlignedAttrs(Sema &S, NamedDecl *New, Decl *Old) {
2463 // Look for alignas attributes on New.
2466 for (auto *I : New->specific_attrs<AlignedAttr>()) {
2488 if (ValueDecl *VD = dyn_cast<ValueDecl>(New))
2491 Ty = S.Context.getTagDeclType(cast<TagDecl>(New));
2507 if (OldAlignasAttr && !NewAlignasAttr && isAttributeTargetADefinition(New)) {
2516 S.Diag(New->getLocation(), diag::err_alignas_missing_on_definition)
2528 New->addAttr(Clone);
2537 New->addAttr(Clone);
2557 // new declaration D if the new declaration doesn't itself have that attribute
2559 // If you're adding a new attribute that requires logic different from
2663 /// there are no new attributes in this declaration.
2664 static void checkNewAttributesAfterDef(Sema &S, Decl *New, const Decl *Old) {
2665 if (!New->hasAttrs())
2669 if (!Def || Def == New)
2672 AttrVec &NewAttributes = New->getAttrs();
2677 if (FunctionDecl *FD = dyn_cast<FunctionDecl>(New)) {
2688 VarDecl *VD = cast<VarDecl>(New);
2756 cast<VarDecl>(New)->isInline() &&
2757 !cast<VarDecl>(New)->isInlineSpecified()) {
2831 /// mergeDeclAttributes - Copy attributes from the Old decl to the New one.
2832 void Sema::mergeDeclAttributes(NamedDecl *New, Decl *Old,
2837 New->addAttr(NewAttr);
2842 New->addAttr(NewAttr);
2845 if (!Old->hasAttrs() && !New->hasAttrs())
2852 const auto *NewConstInit = New->getAttr<ConstInitAttr>();
2855 auto *NewVD = cast<VarDecl>(New);
2858 // the new declaration into the redeclaration chain yet.
2884 checkNewAttributesAfterDef(*this, New, Old);
2886 if (AsmLabelAttr *NewA = New->getAttr<AsmLabelAttr>()) {
2890 Diag(New->getLocation(), diag::err_different_asm_label);
2896 Diag(New->getLocation(), diag::err_late_asm_label_name)
2897 << isa<FunctionDecl>(Old) << New->getAttr<AsmLabelAttr>()->getRange();
2902 if (const auto *NewAbiTagAttr = New->getAttr<AbiTagAttr>()) {
2920 if (New->hasAttr<SectionAttr>() && !Old->hasAttr<SectionAttr>()) {
2921 if (auto *VD = dyn_cast<VarDecl>(New)) {
2923 Diag(New->getLocation(), diag::warn_attribute_section_on_redeclaration);
2930 const auto *NewCSA = New
2932 !NewCSA->isImplicit() && isa<CXXMethodDecl>(New)) {
2933 Diag(New->getLocation(), diag::warn_mismatched_section)
2941 bool foundAny = New->hasAttrs();
2945 if (!foundAny) New->setAttrs(AttrVec());
2970 if (mergeDeclAttribute(*this, New, I, LocalAMK))
2974 if (mergeAlignedAttrs(*this, New, Old))
2977 if (!foundAny) New->dropAttrs();
2981 /// to the new one.
3068 getNoteDiagForInvalidRedeclaration(const T *Old, const T *New) {
3076 OldLocation = New->getLocation();
3101 static bool haveIncompatibleLanguageLinkages(const T *Old, const T *New) {
3107 if (OldLinkage == CXXLanguageLinkage && New->isInExternCContext())
3109 if (OldLinkage == CLanguageLinkage && New->isInExternCXXContext())
3122 ExpectedDecl *New) {
3143 New->getDeclContext()->getRedeclContext()) &&
3144 !(isExternC(Old) && isExternC(New)))
3148 S.Diag(New->getLocation(), diag::err_using_decl_conflict_reverse);
3214 /// MergeFunctionDecl - We just parsed a function 'New' from
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
3225 bool Sema::MergeFunctionDecl(FunctionDecl *New, NamedDecl *&OldD,
3231 if (New->getFriendObjectKind()) {
3232 Diag(New->getLocation(), diag::err_using_decl_friend);
3241 if (checkUsingShadowRedecl<FunctionDecl>(*this, Shadow, New))
3245 Diag(New->getLocation(), diag::err_redefinition_different_kind)
3246 << New->getDeclName();
3247 notePreviousDefinition(OldD, New->getLocation());
3252 // If the old declaration was found in an inline namespace and the new
3254 adjustDeclContextForDeclaratorDecl(New, Old);
3262 Diag(New->getLocation(), diag::err_builtin_redeclare) << Old->getDeclName();
3271 getNoteDiagForInvalidRedeclaration(Old, New);
3277 if (!isa<CXXMethodDecl>(New) && !isa<CXXMethodDecl>(Old) &&
3278 New->getStorageClass() == SC_Static &&
3280 !New->getTemplateSpecializationInfo() &&
3283 Diag(New->getLocation(), diag::ext_static_non_static) << New;
3286 Diag(New->getLocation(), diag::err_static_non_static) << New;
3292 if (New->hasAttr<InternalLinkageAttr>() &&
3294 Diag(New->getLocation(), diag::err_internal_linkage_redeclaration)
3295 << New->getDeclName();
3296 notePreviousDefinition(Old, New->getLocation());
3297 New->dropAttr<InternalLinkageAttr>();
3300 if (CheckRedeclarationModuleOwnership(New, Old))
3305 if (OldOvl != New->hasAttr<OverloadableAttr>() && !Old->isImplicit()) {
3306 Diag(New->getLocation(), diag::err_attribute_overloadable_mismatch)
3307 << New << OldOvl;
3332 New->addAttr(OverloadableAttr::CreateImplicit(Context));
3334 New->dropAttr<OverloadableAttr>();
3352 QualType NewQType = Context.getCanonicalType(New->getType());
3364 bool NewCCExplicit = getCallingConvAttributedType(New->getType());
3371 // Builtin attribute isn't propagated to the new one yet at this point,
3377 Diag(New->getLocation(), diag::warn_cconv_unsupported)
3385 Diag(New->getLocation(), diag::err_cconv_change)
3407 Diag(New->getLocation(), diag::err_regparm_mismatch)
3421 Diag(New->getLocation(), diag::err_function_attribute_mismatch)
3435 New->getAttr<AnyX86NoCallerSavedRegistersAttr>();
3436 Diag(New->getLocation(), diag::err_function_attribute_mismatch) << Attr;
3446 const FunctionType *AdjustedType = New->getType()->getAs<FunctionType>();
3448 New->setType(QualType(AdjustedType, 0));
3449 NewQType = Context.getCanonicalType(New->getType());
3454 if (!Old->isInlined() && New->isInlined() &&
3455 !New->hasAttr<GNUInlineAttr>() &&
3458 !Old->isDefined() && !New->isThisDeclarationADefinition())
3464 if (New->hasAttr<GNUInlineAttr>() &&
3471 if (Old->getNumParams() > 0 && Old->getNumParams() == New->getNumParams() &&
3472 !hasIdenticalPassObjectSizeAttrs(Old, New)) {
3473 Diag(New->getLocation(), diag::err_different_pass_object_size_params)
3474 << New->getDeclName();
3486 // both Old and New if it resolved exception specifications, so grab the
3489 // but do not necessarily update the type of New.
3490 if (CheckEquivalentExceptionSpec(Old, New))
3493 NewQType = Context.getCanonicalType(New->getType());
3501 QualType NewDeclaredReturnType = New->getDeclaredReturnType();
3503 canFullyTypeCheckRedeclaration(New, Old, NewDeclaredReturnType,
3511 if (New->isCXXClassMember() && New->isOutOfLine())
3512 Diag(New->getLocation(), diag::err_member_def_does_not_match_ret_type)
3513 << New << New->getReturnTypeSourceRange();
3515 Diag(New->getLocation(), diag::err_ovl_diff_return_type)
3516 << New->getReturnTypeSourceRange();
3532 New->setType(
3533 SubstAutoType(New->getType(),
3544 CXXMethodDecl *NewMethod = dyn_cast<CXXMethodDecl>(New);
3563 Diag(New->getLocation(), diag::err_ovl_static_nonstatic_member);
3583 Diag(New->getLocation(), NewDiag);
3585 Diag(New->getLocation(), diag::err_member_redeclared_in_instantiation)
3586 << New << New->getType();
3602 << New << getSpecialMember(OldMethod);
3617 const CXX11NoReturnAttr *NRA = New->getAttr<CXX11NoReturnAttr>();
3628 const CarriesDependencyAttr *CDA = New->getAttr<CarriesDependencyAttr>();
3651 if (haveIncompatibleLanguageLinkages(Old, New)) {
3660 if (New->getFriendObjectKind() != Decl::FOK_None) {
3661 Diag(New->getLocation(), diag::ext_retained_language_linkage) << New;
3664 Diag(New->getLocation(), diag::err_different_language_linkage) << New;
3676 return MergeCompatibleFunctionDecls(New, Old, S, MergeTypeWithOld);
3681 if (!canFullyTypeCheckRedeclaration(New, Old, NewQType, OldQType))
3697 // new declaration does not. Merge in the prototype.
3703 New->setType(NewQType);
3704 New->setHasInheritedPrototype();
3709 ParmVarDecl *Param = ParmVarDecl::Create(Context, New, SourceLocation(),
3718 New->setParams(Params);
3721 return MergeCompatibleFunctionDecls(New, Old, S, MergeTypeWithOld);
3741 Old->hasPrototype() && !New->hasPrototype() &&
3742 New->getType()->getAs<FunctionProtoType>() &&
3743 Old->getNumParams() == New->getNumParams()) {
3749 = New->getType()->getAs<FunctionProtoType>();
3758 ParmVarDecl *NewParm = New->getParamDecl(Idx);
3785 New->setType(Context.getFunctionType(MergedReturn, ArgTypes,
3787 return MergeCompatibleFunctionDecls(New, Old, S, MergeTypeWithOld);
3803 Diag(New->getLocation(), diag::warn_redecl_library_builtin) << New;
3812 Diag(New->getLocation(), diag::err_conflicting_types) << New->getDeclName();
3822 /// the new declaration, once we know that New is in fact a
3826 bool Sema::MergeCompatibleFunctionDecls(FunctionDecl *New, FunctionDecl *Old,
3829 mergeDeclAttributes(New, Old);
3833 New->setPure();
3837 New->setIsUsed();
3841 if (New->getNumParams() == Old->getNumParams())
3842 for (unsigned i = 0, e = New->getNumParams(); i != e; ++i) {
3843 ParmVarDecl *NewParam = New->getParamDecl(i);
3850 return MergeCXXFunctionDecl(New, Old, S);
3855 QualType Merged = Context.mergeTypes(Old->getType(), New->getType());
3857 New->setType(Merged);
3885 static void diagnoseVarDeclTypeMismatch(Sema &S, VarDecl *New, VarDecl* Old) {
3886 assert(!S.Context.hasSameType(New->getType(), Old->getType()));
3888 S.Diag(New->getLocation(), New->isThisDeclarationADefinition()
3891 << New->getDeclName() << New->getType() << Old->getType();
3896 = getNoteDiagForInvalidRedeclaration(Old, New);
3898 New->setInvalidDecl();
3901 /// MergeVarDeclTypes - We parsed a variable 'New' which has the same name and
3908 void Sema::MergeVarDeclTypes(VarDecl *New, VarDecl *Old,
3910 if (New->isInvalidDecl() || Old->isInvalidDecl())
3915 if (New->getType()->isUndeducedType()) {
3916 // We don't know what the new type is until the initializer is attached.
3918 } else if (Context.hasSameType(New->getType(), Old->getType())) {
3920 return MergeVarDeclExceptionSpecs(New, Old);
3927 else if (Old->getType()->isArrayType() && New->getType()->isArrayType()) {
3929 const ArrayType *NewArray = Context.getAsArrayType(New->getType());
3931 // We are merging a variable declaration New into Old. If it has an array
3941 if (!Context.hasSameType(New->getType(), PrevVDTy))
3942 return diagnoseVarDeclTypeMismatch(*this, New, PrevVD);
3949 MergedT = New->getType();
3951 // FIXME: Check visibility. New is hidden but has a complete type. If New
3960 else if (New->getType()->isObjCObjectPointerType() &&
3962 MergedT = Context.mergeObjCGCQualifiers(New->getType(),
3969 MergedT = Context.mergeTypes(New->getType(), Old->getType());
3977 if ((New->getType()->isDependentType() ||
3978 Old->getType()->isDependentType()) && New->isLocalVarDecl()) {
3979 // If the old type was dependent, we can't merge with it, so the new type
3982 if (!New->getType()->isDependentType() && MergeTypeWithOld)
3983 New->setType(Context.DependentTy);
3986 return diagnoseVarDeclTypeMismatch(*this, New, Old);
3989 // Don't actually update the type on the new declaration if the old
3992 New->setType(MergedT);
4024 /// MergeVarDecl - We just parsed a variable 'New' which has the same name
4032 void Sema::MergeVarDecl(VarDecl *New, LookupResult &Previous) {
4033 // If the new decl is already invalid, don't do any other checking.
4034 if (New->isInvalidDecl())
4037 if (!shouldLinkPossiblyHiddenDecl(Previous, New))
4040 VarTemplateDecl *NewTemplate = New->getDescribedVarTemplate();
4053 return New->setInvalidDecl();
4059 if (checkUsingShadowRedecl<VarDecl>(*this, Shadow, New))
4060 return New->setInvalidDecl();
4064 Diag(New->getLocation(), diag::err_redefinition_different_kind)
4065 << New->getDeclName();
4067 New->getLocation());
4068 return New->setInvalidDecl();
4071 // If the old declaration was found in an inline namespace and the new
4073 adjustDeclContextForDeclaratorDecl(New, Old);
4080 return New->setInvalidDecl();
4086 if (Old->isStaticDataMember() && !New->isOutOfLine()) {
4087 Diag(New->getLocation(), diag::err_duplicate_member)
4088 << New->getIdentifier();
4090 New->setInvalidDecl();
4093 mergeDeclAttributes(New, Old);
4096 if (New->hasAttr<WeakImportAttr>() &&
4099 Diag(New->getLocation(), diag::warn_weak_import) << New->getDeclName();
4100 notePreviousDefinition(Old, New->getLocation());
4101 // Remove weak_import attribute on new declaration.
4102 New->dropAttr<WeakImportAttr>();
4105 if (New->hasAttr<InternalLinkageAttr>() &&
4107 Diag(New
4108 << New->getDeclName();
4109 notePreviousDefinition(Old, New->getLocation());
4110 New->dropAttr<InternalLinkageAttr>();
4116 MergeVarDeclTypes(New, MostRecent,
4117 mergeTypeWithPrevious(*this, New, MostRecent, Previous));
4118 if (New->isInvalidDecl())
4122 MergeVarDeclTypes(New, Old, mergeTypeWithPrevious(*this, New, Old, Previous));
4123 if (New->isInvalidDecl())
4129 getNoteDiagForInvalidRedeclaration(Old, New);
4132 if (New->getStorageClass() == SC_Static &&
4133 !New->isStaticDataMember() &&
4136 Diag(New->getLocation(), diag::ext_static_non_static)
4137 << New->getDeclName();
4140 Diag(New->getLocation(), diag::err_static_non_static)
4141 << New->getDeclName();
4143 return New->setInvalidDecl();
4155 if (New->hasExternalStorage() && Old->hasLinkage())
4157 else if (New->getCanonicalDecl()->getStorageClass() != SC_Static &&
4158 !New->isStaticDataMember() &&
4160 Diag(New->getLocation(), diag::err_non_static_static) << New->getDeclName();
4162 return New->setInvalidDecl();
4166 if (New->hasExternalStorage() &&
4168 Diag(New->getLocation(), diag::err_extern_non_extern) << New->getDeclName();
4170 return New->setInvalidDecl();
4172 if (Old->hasLinkage() && New->isLocalVarDeclOrParm() &&
4173 !New->hasExternalStorage()) {
4174 Diag(New->getLocation(), diag::err_non_extern_extern) << New->getDeclName();
4176 return New->setInvalidDecl();
4179 if (CheckRedeclarationModuleOwnership(New, Old))
4186 if (!New->hasExternalStorage() && !New->isFileVarDecl() &&
4189 !New->getLexicalDeclContext()->isRecord())) {
4190 Diag(New->getLocation(), diag::err_redefinition) << New->getDeclName();
4192 return New->setInvalidDecl();
4195 if (New->isInline() && !Old->getMostRecentDecl()->isInline()) {
4200 Diag(New->getLocation(), diag::err_inline_decl_follows_def) << New;
4207 if (!Old->isInline() && New->isInline() && Old->isUsed(false) &&
4208 !Old->getDefinition() && !New->isThisDeclarationADefinition())
4212 if (New->getTLSKind() != Old->getTLSKind()) {
4214 Diag(New->getLocation(), diag::err_thread_non_thread) << New->getDeclName();
4216 } else if (!New->getTLSKind()) {
4217 Diag(New->getLocation(), diag::err_non_thread_thread) << New->getDeclName();
4224 Diag(New->getLocation(), diag::err_thread_thread_different_kind)
4225 << New->getDeclName() << (New->getTLSKind() == VarDecl::TLS_Dynamic);
4232 New->isThisDeclarationADefinition() == VarDecl::Definition) {
4236 Diag(New->getLocation(),
4239 if (checkVarDeclRedefinition(Def, New))
4244 if (haveIncompatibleLanguageLinkages(Old, New)) {
4245 Diag(New->getLocation(), diag::err_different_language_linkage) << New;
4247 New->setInvalidDecl();
4253 New->setIsUsed();
4256 New->setPreviousDecl(Old);
4261 New->setAccess(Old->getAccess());
4263 NewTemplate->setAccess(New->getAccess());
4266 New->setImplicitlyInline();
4269 void Sema::notePreviousDefinition(const NamedDecl *Old, SourceLocation New) {
4271 auto FNewDecLoc = SrcMgr.getDecomposedLoc(New);
4324 /// We've just determined that \p Old and \p New both appear to be definitions
4326 bool Sema::checkVarDeclRedefinition(VarDecl *Old, VarDecl *New) {
4328 (New->getFormalLinkage() == InternalLinkage ||
4329 New->isInline() ||
4330 New->getDescribedVarTemplate() ||
4331 New->getNumTemplateParameterLists() ||
4332 New->getDeclContext()->isDependentContext())) {
4335 New->demoteThisDefinitionToDeclaration();
4343 Diag(New->getLocation(), diag::err_redefinition) << New;
4344 notePreviousDefinition(Old, New->getLocation());
4345 New->setInvalidDecl();
4905 new (SemaRef.Context)NamedDecl*[Chaining.size()];
5526 // Store the new type back in the decl spec.
5876 // (class or enum). In this case, the new declaration will hide the
5889 NamedDecl *New;
5898 New = ActOnTypedefDeclarator(S, D, DC, TInfo, Previous);
5900 New = ActOnFunctionDeclarator(S, D, DC, TInfo, Previous,
5904 New = ActOnVariableDeclarator(S, D, DC, TInfo, Previous, TemplateParamLists,
5908 if (!New)
5913 if (New->getDeclName() && AddToScope)
5914 PushOnScopeChains(New, S);
5917 checkDeclIsAllowedInOpenMPTarget(nullptr, New);
5919 return New;
6251 /// new declaration by the same name is being introduced. If the new
6259 /// \param DC the context in which the new declaration is being
6263 /// for a new delcaration with the same name.
6290 // Find the innermost enclosing namespace for the new and
7383 // scope and are out-of-semantic-context declarations (if the new
7789 // Both the old and new declarations have C language linkage. This is a
8293 /// the new declaration name does not cause new errors.
8357 // Retry building the function declaration with the new previous
9737 // ignore this, we allow the redeclaration behavior here to create new
10073 /// \param NewD The new declaration.
10075 /// \param NewT The portion of the type of the new declaration to check.
10101 /// Checks if the new declaration declared in dependent context must be
10500 /// Check the validity of a new function declaration being added to an existing
10567 [](const IdentifierInfo *Cur, const IdentifierInfo *New) {
10568 return Cur->getName() == New->getName();
10588 [](const IdentifierInfo *Cur, const IdentifierInfo *New) {
10589 return Cur->getName() == New->getName();
10721 /// Perform semantic checking of a new function declaration.
10723 /// Performs semantic analysis of the new function declaration
10731 /// \param IsMemberSpecialization whether this new function declaration is
10759 // there's no more work to do here; we'll just add the new
13725 ParmVarDecl *New =
13730 New->setInvalidDecl();
13734 New->setScopeInfo(S->getFunctionPrototypeDepth() - 1,
13738 S->AddDecl(New);
13740 IdResolver.AddDecl(New);
13742 ProcessDeclAttributes(S, New, D);
13745 Diag(New->getLocation(), diag::err_module_private_local)
13746 << 1 << New << SourceRange(D.getDeclSpec().getModulePrivateSpecLoc())
13749 if (New->hasAttr<BlocksAttr>()) {
13750 Diag(New->getLocation(), diag::err_block_on_nonlocal);
13754 deduceOpenCLAddressSpace(New);
13756 return New;
13846 ParmVarDecl *New = ParmVarDecl::Create(Context, DC, StartLoc, NameLoc, Name,
13850 // Make a note if we created a new pack in the scope of a lambda, so that
13853 if (New->isParameterPack())
13855 LSI->LocalPacks.push_back(New);
13857 if (New->getType().hasNonTrivialToPrimitiveDestructCUnion() ||
13858 New->getType().hasNonTrivialToPrimitiveCopyCUnion())
13859 checkNonTrivialCUnion(New->getType(), New->getLocation(),
13868 New->setInvalidDecl();
13879 New->setType(T);
13892 New->setInvalidDecl();
13897 CheckPPCMMAType(New->getOriginalType(), New->getLocation())) {
13898 New->setInvalidDecl();
13901 return New;
14060 // a template, skip the new definition.
14200 // and capture any new variables. In addition when calculating potential
14209 // Enter a new function scope
14911 /// (C++2a [basic.stc.dynamic.allocation], C++2a [new.delete]),
14945 // because there is an opt-out switch for it (-fno-assume-sane-operator-new)
14973 // (3.2) Otherwise, if the allocation function is named operator new[],
14975 // new-extended alignment ([basic.align]) and is no larger than the
14978 // have new-extended alignment and is of the requested size.
15286 /// \returns true if the new tag kind is acceptable, false otherwise.
15591 /// Create a new tag decl in C/ObjC. Since the ODR-like semantics for ObjC/C
15600 TagDecl *New = nullptr;
15603 New = EnumDecl::Create(Context, SearchDC, KWLoc, Loc, Name, nullptr,
15609 EnumDecl *ED = cast<EnumDecl>(New);
15617 New = RecordDecl::Create(Context, Kind, SearchDC, KWLoc, Loc, Name,
15621 if (RecordDecl *RD = dyn_cast<RecordDecl>(New)) {
15636 New->setLexicalDeclContext(CurContext);
15637 return New;
15996 // FIXME: Diagnose these attributes. For now, we create a new
16005 // a friend visible or it makes a type visible in a new module.
16006 // In either case, create a new declaration. We only do this if
16013 // This is in the injected scope, create a new declaration in
16052 // complete parsing the new one and do the structural
16055 SkipBody->New = createTagFromNewDecl();
16096 // tag. We're going to create a new Decl for it.
16108 // have a definition. Just create a new decl.
16111 // If we get here, this is a definition of a new tag type in a nested
16113 // new decl/type. We set PrevDecl to NULL so that the entities
16117 // If we get here, we're going to create a new Decl. If PrevDecl
16119 // PrevDecl. If it's NULL, we have a new definition.
16169 // new scope, so clear out the previous declaration.
16185 // Otherwise, create a new declaration. If there is a previous
16188 TagDecl *New;
16193 New = EnumDecl::Create(Context, SearchDC, KWLoc, Loc, Name,
16198 StdAlignValT = cast<EnumDecl>(New);
16203 if (IsFixed && cast<EnumDecl>(New)->isFixed()) {
16209 << New;
16222 EnumDecl *ED = cast<EnumDecl>(New);
16237 New = CXXRecordDecl::Create(Context, Kind, SearchDC, KWLoc, Loc, Name,
16241 StdBadAlloc = cast<CXXRecordDecl>(New);
16243 New = RecordDecl::Create(Context, Kind, SearchDC, KWLoc, Loc, Name,
16251 Diag(New->getLocation(), diag::err_type_defined_in_type_specifier)
16252 << Context.getTagDeclType(New);
16258 Diag(New->getLocation(), diag::err_type_defined_in_enum)
16259 << Context.getTagDeclType(New);
16273 New->setQualifierInfo(SS.getWithLocInContext(Context));
16275 New->setTemplateParameterListsInfo(Context, TemplateParameterLists);
16282 if (RecordDecl *RD = dyn_cast<RecordDecl>(New)) {
16300 Diag(New->getLocation(), diag::err_module_private_specialization)
16307 New->setModulePrivate();
16312 if (isMemberSpecialization && CheckMemberSpecialization(New, Previous))
16329 Diag(Loc, diag::warn_decl_in_param_list) << Context.getTagDeclType(New);
16334 New->setInvalidDecl();
16338 New->setLexicalDeclContext(CurContext);
16345 New->setObjectOfFriendDecl(getLangOpts().MSVCCompat);
16349 SetMemberAccessSpecifier(New, PrevDecl, AS);
16352 CheckRedeclarationModuleOwnership(New, PrevDecl);
16355 New->startDefinition();
16357 ProcessDeclAttributeList(S, New, Attrs);
16358 AddPragmaAttributes(S, New);
16365 New->setAccess(PrevDecl->getAccess());
16367 DeclContext *DC = New->getDeclContext()->getRedeclContext();
16368 DC->makeDeclVisibleInContext(New);
16371 PushOnScopeChains(New, EnclosingScope, /* AddToContext = */ false);
16374 PushOnScopeChains(New, S, true);
16376 CurContext->addDecl(New);
16380 if (IdentifierInfo *II = New->getIdentifier())
16381 if (!New->isInvalidDecl() &&
16382 New->getDeclContext()->getRedeclContext()->isTranslationUnit() &&
16384 Context.setFILEDecl(New);
16387 mergeDeclAttributes(New, PrevDecl);
16389 if (auto *CXXRD = dyn_cast<CXXRecordDecl>(New))
16394 AddPushedVisibilityAttribute(New);
16396 if (isMemberSpecialization && !New->isInvalidDecl())
16397 CompleteMemberSpecialization(New, Previous);
16403 if (New->isBeingDefined())
16404 if (auto RD = dyn_cast<RecordDecl>(New))
16410 return New;
16430 if (!hasStructuralCompatLayout(Prev, SkipBody.New))
16755 /// Build a new FieldDecl and check its well-formedness.
16757 /// This routine builds a new FieldDecl given the fields name, type,
16762 /// \returns a new FieldDecl.
17164 // All conditions are met. Add a new bitfield to the tail end of ivars.
17185 // new fields here we should reset the layout of the interface since
17912 EnumConstantDecl *New =
17914 if (!New)
17920 CheckShadow(New, PrevDecl, R);
17938 ProcessDeclAttributeList(S, New, Attrs);
17939 AddPragmaAttributes(S, New);
17942 New->setAccess(TheEnumDecl->getAccess());
17943 PushOnScopeChains(New, S);
17945 ActOnDocumentableDecl(New);
17947 return New;
18061 // Create new vector and push values onto it.
18113 // Only single-bit enumerators introduce new flag values.
18370 FileScopeAsmDecl *New = FileScopeAsmDecl::Create(Context, CurContext,
18373 CurContext->addDecl(New);
18374 return New;