Deleted Added
full compact
SemaDeclCXX.cpp (195099) SemaDeclCXX.cpp (195341)
1//===------ SemaDeclCXX.cpp - Semantic Analysis for C++ Declarations ------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//

--- 244 unchanged lines hidden (view full) ---

253 Diag(OldParam->getLocation(), diag::note_previous_definition);
254 Invalid = true;
255 } else if (OldParam->getDefaultArg()) {
256 // Merge the old default argument into the new parameter
257 NewParam->setDefaultArg(OldParam->getDefaultArg());
258 }
259 }
260
1//===------ SemaDeclCXX.cpp - Semantic Analysis for C++ Declarations ------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//

--- 244 unchanged lines hidden (view full) ---

253 Diag(OldParam->getLocation(), diag::note_previous_definition);
254 Invalid = true;
255 } else if (OldParam->getDefaultArg()) {
256 // Merge the old default argument into the new parameter
257 NewParam->setDefaultArg(OldParam->getDefaultArg());
258 }
259 }
260
261 if (CheckEquivalentExceptionSpec(
262 Old->getType()->getAsFunctionProtoType(), Old->getLocation(),
263 New->getType()->getAsFunctionProtoType(), New->getLocation())) {
264 Invalid = true;
265 }
266
261 return Invalid;
262}
263
264/// CheckCXXDefaultArguments - Verify that the default arguments for a
265/// function declaration are well-formed according to C++
266/// [dcl.fct.default].
267void Sema::CheckCXXDefaultArguments(FunctionDecl *FD) {
268 unsigned NumParams = FD->getNumParams();

--- 207 unchanged lines hidden (view full) ---

476 } else {
477 // Okay, add this new base class.
478 KnownBaseTypes[NewBaseType] = Bases[idx];
479 Bases[NumGoodBases++] = Bases[idx];
480 }
481 }
482
483 // Attach the remaining base class specifiers to the derived class.
267 return Invalid;
268}
269
270/// CheckCXXDefaultArguments - Verify that the default arguments for a
271/// function declaration are well-formed according to C++
272/// [dcl.fct.default].
273void Sema::CheckCXXDefaultArguments(FunctionDecl *FD) {
274 unsigned NumParams = FD->getNumParams();

--- 207 unchanged lines hidden (view full) ---

482 } else {
483 // Okay, add this new base class.
484 KnownBaseTypes[NewBaseType] = Bases[idx];
485 Bases[NumGoodBases++] = Bases[idx];
486 }
487 }
488
489 // Attach the remaining base class specifiers to the derived class.
484 Class->setBases(Bases, NumGoodBases);
490 Class->setBases(Context, Bases, NumGoodBases);
485
486 // Delete the remaining (good) base class specifiers, since their
487 // data has been copied into the CXXRecordDecl.
488 for (unsigned idx = 0; idx < NumGoodBases; ++idx)
489 delete Bases[idx];
490
491 return Invalid;
492}

--- 148 unchanged lines hidden (view full) ---

641 }
642 return DeclPtrTy::make(Member);
643}
644
645/// ActOnMemInitializer - Handle a C++ member initializer.
646Sema::MemInitResult
647Sema::ActOnMemInitializer(DeclPtrTy ConstructorD,
648 Scope *S,
491
492 // Delete the remaining (good) base class specifiers, since their
493 // data has been copied into the CXXRecordDecl.
494 for (unsigned idx = 0; idx < NumGoodBases; ++idx)
495 delete Bases[idx];
496
497 return Invalid;
498}

--- 148 unchanged lines hidden (view full) ---

647 }
648 return DeclPtrTy::make(Member);
649}
650
651/// ActOnMemInitializer - Handle a C++ member initializer.
652Sema::MemInitResult
653Sema::ActOnMemInitializer(DeclPtrTy ConstructorD,
654 Scope *S,
655 const CXXScopeSpec &SS,
649 IdentifierInfo *MemberOrBase,
656 IdentifierInfo *MemberOrBase,
657 TypeTy *TemplateTypeTy,
650 SourceLocation IdLoc,
651 SourceLocation LParenLoc,
652 ExprTy **Args, unsigned NumArgs,
653 SourceLocation *CommaLocs,
654 SourceLocation RParenLoc) {
655 if (!ConstructorD)
656 return true;
657

--- 14 unchanged lines hidden (view full) ---

672 // constructor���s class and, if not found in that scope, are looked
673 // up in the scope containing the constructor���s
674 // definition. [Note: if the constructor���s class contains a member
675 // with the same name as a direct or virtual base class of the
676 // class, a mem-initializer-id naming the member or base class and
677 // composed of a single identifier refers to the class member. A
678 // mem-initializer-id for the hidden base class may be specified
679 // using a qualified name. ]
658 SourceLocation IdLoc,
659 SourceLocation LParenLoc,
660 ExprTy **Args, unsigned NumArgs,
661 SourceLocation *CommaLocs,
662 SourceLocation RParenLoc) {
663 if (!ConstructorD)
664 return true;
665

--- 14 unchanged lines hidden (view full) ---

680 // constructor���s class and, if not found in that scope, are looked
681 // up in the scope containing the constructor���s
682 // definition. [Note: if the constructor���s class contains a member
683 // with the same name as a direct or virtual base class of the
684 // class, a mem-initializer-id naming the member or base class and
685 // composed of a single identifier refers to the class member. A
686 // mem-initializer-id for the hidden base class may be specified
687 // using a qualified name. ]
680 // Look for a member, first.
681 FieldDecl *Member = 0;
682 DeclContext::lookup_result Result
683 = ClassDecl->lookup(Context, MemberOrBase);
684 if (Result.first != Result.second)
685 Member = dyn_cast<FieldDecl>(*Result.first);
688 if (!SS.getScopeRep() && !TemplateTypeTy) {
689 // Look for a member, first.
690 FieldDecl *Member = 0;
691 DeclContext::lookup_result Result
692 = ClassDecl->lookup(MemberOrBase);
693 if (Result.first != Result.second)
694 Member = dyn_cast<FieldDecl>(*Result.first);
686
695
687 // FIXME: Handle members of an anonymous union.
696 // FIXME: Handle members of an anonymous union.
688
697
689 if (Member) {
690 // FIXME: Perform direct initialization of the member.
691 return new CXXBaseOrMemberInitializer(Member, (Expr **)Args, NumArgs);
698 if (Member) {
699 // FIXME: Perform direct initialization of the member.
700 return new CXXBaseOrMemberInitializer(Member, (Expr **)Args, NumArgs,
701 IdLoc);
702 }
692 }
703 }
693
694 // It didn't name a member, so see if it names a class.
704 // It didn't name a member, so see if it names a class.
695 TypeTy *BaseTy = getTypeName(*MemberOrBase, IdLoc, S, 0/*SS*/);
705 TypeTy *BaseTy = TemplateTypeTy ? TemplateTypeTy
706 : getTypeName(*MemberOrBase, IdLoc, S, &SS);
696 if (!BaseTy)
697 return Diag(IdLoc, diag::err_mem_init_not_member_or_class)
698 << MemberOrBase << SourceRange(IdLoc, RParenLoc);
699
700 QualType BaseType = QualType::getFromOpaquePtr(BaseTy);
707 if (!BaseTy)
708 return Diag(IdLoc, diag::err_mem_init_not_member_or_class)
709 << MemberOrBase << SourceRange(IdLoc, RParenLoc);
710
711 QualType BaseType = QualType::getFromOpaquePtr(BaseTy);
701 if (!BaseType->isRecordType())
712 if (!BaseType->isRecordType() && !BaseType->isDependentType())
702 return Diag(IdLoc, diag::err_base_init_does_not_name_class)
703 << BaseType << SourceRange(IdLoc, RParenLoc);
704
705 // C++ [class.base.init]p2:
706 // [...] Unless the mem-initializer-id names a nonstatic data
707 // member of the constructor���s class or a direct or virtual base
708 // of that class, the mem-initializer is ill-formed. A
709 // mem-initializer-list can initialize a base class using any

--- 34 unchanged lines hidden (view full) ---

744
745 // C++ [base.class.init]p2:
746 // If a mem-initializer-id is ambiguous because it designates both
747 // a direct non-virtual base class and an inherited virtual base
748 // class, the mem-initializer is ill-formed.
749 if (DirectBaseSpec && VirtualBaseSpec)
750 return Diag(IdLoc, diag::err_base_init_direct_and_virtual)
751 << MemberOrBase << SourceRange(IdLoc, RParenLoc);
713 return Diag(IdLoc, diag::err_base_init_does_not_name_class)
714 << BaseType << SourceRange(IdLoc, RParenLoc);
715
716 // C++ [class.base.init]p2:
717 // [...] Unless the mem-initializer-id names a nonstatic data
718 // member of the constructor���s class or a direct or virtual base
719 // of that class, the mem-initializer is ill-formed. A
720 // mem-initializer-list can initialize a base class using any

--- 34 unchanged lines hidden (view full) ---

755
756 // C++ [base.class.init]p2:
757 // If a mem-initializer-id is ambiguous because it designates both
758 // a direct non-virtual base class and an inherited virtual base
759 // class, the mem-initializer is ill-formed.
760 if (DirectBaseSpec && VirtualBaseSpec)
761 return Diag(IdLoc, diag::err_base_init_direct_and_virtual)
762 << MemberOrBase << SourceRange(IdLoc, RParenLoc);
763 // C++ [base.class.init]p2:
764 // Unless the mem-initializer-id names a nonstatic data membeer of the
765 // constructor's class ot a direst or virtual base of that class, the
766 // mem-initializer is ill-formed.
767 if (!DirectBaseSpec && !VirtualBaseSpec)
768 return Diag(IdLoc, diag::err_not_direct_base_or_virtual)
769 << BaseType << ClassDecl->getNameAsCString()
770 << SourceRange(IdLoc, RParenLoc);
771
752
772
753 return new CXXBaseOrMemberInitializer(BaseType, (Expr **)Args, NumArgs);
773 return new CXXBaseOrMemberInitializer(BaseType, (Expr **)Args, NumArgs,
774 IdLoc);
754}
755
756void Sema::ActOnMemInitializers(DeclPtrTy ConstructorDecl,
757 SourceLocation ColonLoc,
758 MemInitTy **MemInits, unsigned NumMemInits) {
759 if (!ConstructorDecl)
760 return;
761
762 CXXConstructorDecl *Constructor
763 = dyn_cast<CXXConstructorDecl>(ConstructorDecl.getAs<Decl>());
764
765 if (!Constructor) {
766 Diag(ColonLoc, diag::err_only_constructors_take_base_inits);
767 return;
768 }
775}
776
777void Sema::ActOnMemInitializers(DeclPtrTy ConstructorDecl,
778 SourceLocation ColonLoc,
779 MemInitTy **MemInits, unsigned NumMemInits) {
780 if (!ConstructorDecl)
781 return;
782
783 CXXConstructorDecl *Constructor
784 = dyn_cast<CXXConstructorDecl>(ConstructorDecl.getAs<Decl>());
785
786 if (!Constructor) {
787 Diag(ColonLoc, diag::err_only_constructors_take_base_inits);
788 return;
789 }
790 llvm::DenseMap<void*, CXXBaseOrMemberInitializer *>Members;
791 bool err = false;
792 for (unsigned i = 0; i < NumMemInits; i++) {
793 CXXBaseOrMemberInitializer *Member =
794 static_cast<CXXBaseOrMemberInitializer*>(MemInits[i]);
795 void *KeyToMember = Member->getBaseOrMember();
796 // For fields injected into the class via declaration of an anonymous union,
797 // use its anonymous union class declaration as the unique key.
798 if (FieldDecl *Field = Member->getMember())
799 if (Field->getDeclContext()->isRecord() &&
800 cast<RecordDecl>(Field->getDeclContext())->isAnonymousStructOrUnion())
801 KeyToMember = static_cast<void *>(Field->getDeclContext());
802 CXXBaseOrMemberInitializer *&PrevMember = Members[KeyToMember];
803 if (!PrevMember) {
804 PrevMember = Member;
805 continue;
806 }
807 if (FieldDecl *Field = Member->getMember())
808 Diag(Member->getSourceLocation(),
809 diag::error_multiple_mem_initialization)
810 << Field->getNameAsString();
811 else {
812 Type *BaseClass = Member->getBaseClass();
813 assert(BaseClass && "ActOnMemInitializers - neither field or base");
814 Diag(Member->getSourceLocation(),
815 diag::error_multiple_base_initialization)
816 << BaseClass->getDesugaredType(true);
817 }
818 Diag(PrevMember->getSourceLocation(), diag::note_previous_initializer)
819 << 0;
820 err = true;
821 }
822 if (!err)
823 Constructor->setBaseOrMemberInitializers(Context,
824 reinterpret_cast<CXXBaseOrMemberInitializer **>(MemInits),
825 NumMemInits);
769}
770
771namespace {
772 /// PureVirtualMethodCollector - traverses a class and its superclasses
773 /// and determines if it has any pure virtual methods.
774 class VISIBILITY_HIDDEN PureVirtualMethodCollector {
775 ASTContext &Context;
776

--- 39 unchanged lines hidden (view full) ---

816 }
817
818 // Next, zero out any pure virtual methods that this class overrides.
819 typedef llvm::SmallPtrSet<const CXXMethodDecl*, 4> MethodSetTy;
820
821 MethodSetTy OverriddenMethods;
822 size_t MethodsSize = Methods.size();
823
826}
827
828namespace {
829 /// PureVirtualMethodCollector - traverses a class and its superclasses
830 /// and determines if it has any pure virtual methods.
831 class VISIBILITY_HIDDEN PureVirtualMethodCollector {
832 ASTContext &Context;
833

--- 39 unchanged lines hidden (view full) ---

873 }
874
875 // Next, zero out any pure virtual methods that this class overrides.
876 typedef llvm::SmallPtrSet<const CXXMethodDecl*, 4> MethodSetTy;
877
878 MethodSetTy OverriddenMethods;
879 size_t MethodsSize = Methods.size();
880
824 for (RecordDecl::decl_iterator i = RD->decls_begin(Context),
825 e = RD->decls_end(Context);
881 for (RecordDecl::decl_iterator i = RD->decls_begin(), e = RD->decls_end();
826 i != e; ++i) {
827 // Traverse the record, looking for methods.
828 if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(*i)) {
829 // If the method is pre virtual, add it to the methods vector.
830 if (MD->isPure()) {
831 Methods.push_back(MD);
832 continue;
833 }

--- 80 unchanged lines hidden (view full) ---

914 class VISIBILITY_HIDDEN AbstractClassUsageDiagnoser
915 : public DeclVisitor<AbstractClassUsageDiagnoser, bool> {
916 Sema &SemaRef;
917 CXXRecordDecl *AbstractClass;
918
919 bool VisitDeclContext(const DeclContext *DC) {
920 bool Invalid = false;
921
882 i != e; ++i) {
883 // Traverse the record, looking for methods.
884 if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(*i)) {
885 // If the method is pre virtual, add it to the methods vector.
886 if (MD->isPure()) {
887 Methods.push_back(MD);
888 continue;
889 }

--- 80 unchanged lines hidden (view full) ---

970 class VISIBILITY_HIDDEN AbstractClassUsageDiagnoser
971 : public DeclVisitor<AbstractClassUsageDiagnoser, bool> {
972 Sema &SemaRef;
973 CXXRecordDecl *AbstractClass;
974
975 bool VisitDeclContext(const DeclContext *DC) {
976 bool Invalid = false;
977
922 for (CXXRecordDecl::decl_iterator I = DC->decls_begin(SemaRef.Context),
923 E = DC->decls_end(SemaRef.Context); I != E; ++I)
978 for (CXXRecordDecl::decl_iterator I = DC->decls_begin(),
979 E = DC->decls_end(); I != E; ++I)
924 Invalid |= Visit(*I);
925
926 return Invalid;
927 }
928
929 public:
930 AbstractClassUsageDiagnoser(Sema& SemaRef, CXXRecordDecl *ac)
931 : SemaRef(SemaRef), AbstractClass(ac) {

--- 59 unchanged lines hidden (view full) ---

991 if (!Collector.empty())
992 RD->setAbstract(true);
993 }
994
995 if (RD->isAbstract())
996 AbstractClassUsageDiagnoser(*this, RD);
997
998 if (RD->hasTrivialConstructor() || RD->hasTrivialDestructor()) {
980 Invalid |= Visit(*I);
981
982 return Invalid;
983 }
984
985 public:
986 AbstractClassUsageDiagnoser(Sema& SemaRef, CXXRecordDecl *ac)
987 : SemaRef(SemaRef), AbstractClass(ac) {

--- 59 unchanged lines hidden (view full) ---

1047 if (!Collector.empty())
1048 RD->setAbstract(true);
1049 }
1050
1051 if (RD->isAbstract())
1052 AbstractClassUsageDiagnoser(*this, RD);
1053
1054 if (RD->hasTrivialConstructor() || RD->hasTrivialDestructor()) {
999 for (RecordDecl::field_iterator i = RD->field_begin(Context),
1000 e = RD->field_end(Context); i != e; ++i) {
1055 for (RecordDecl::field_iterator i = RD->field_begin(), e = RD->field_end();
1056 i != e; ++i) {
1001 // All the nonstatic data members must have trivial constructors.
1002 QualType FTy = i->getType();
1003 while (const ArrayType *AT = Context.getAsArrayType(FTy))
1004 FTy = AT->getElementType();
1005
1006 if (const RecordType *RT = FTy->getAsRecordType()) {
1007 CXXRecordDecl *FieldRD = cast<CXXRecordDecl>(RT->getDecl());
1008

--- 40 unchanged lines hidden (view full) ---

1049 ClassDecl->getLocation(), Name,
1050 Context.getFunctionType(Context.VoidTy,
1051 0, 0, false, 0),
1052 /*isExplicit=*/false,
1053 /*isInline=*/true,
1054 /*isImplicitlyDeclared=*/true);
1055 DefaultCon->setAccess(AS_public);
1056 DefaultCon->setImplicit();
1057 // All the nonstatic data members must have trivial constructors.
1058 QualType FTy = i->getType();
1059 while (const ArrayType *AT = Context.getAsArrayType(FTy))
1060 FTy = AT->getElementType();
1061
1062 if (const RecordType *RT = FTy->getAsRecordType()) {
1063 CXXRecordDecl *FieldRD = cast<CXXRecordDecl>(RT->getDecl());
1064

--- 40 unchanged lines hidden (view full) ---

1105 ClassDecl->getLocation(), Name,
1106 Context.getFunctionType(Context.VoidTy,
1107 0, 0, false, 0),
1108 /*isExplicit=*/false,
1109 /*isInline=*/true,
1110 /*isImplicitlyDeclared=*/true);
1111 DefaultCon->setAccess(AS_public);
1112 DefaultCon->setImplicit();
1057 ClassDecl->addDecl(Context, DefaultCon);
1113 ClassDecl->addDecl(DefaultCon);
1058 }
1059
1060 if (!ClassDecl->hasUserDeclaredCopyConstructor()) {
1061 // C++ [class.copy]p4:
1062 // If the class definition does not explicitly declare a copy
1063 // constructor, one is declared implicitly.
1064
1065 // C++ [class.copy]p5:

--- 15 unchanged lines hidden (view full) ---

1081 HasConstCopyConstructor
1082 = BaseClassDecl->hasConstCopyConstructor(Context);
1083 }
1084
1085 // -- for all the nonstatic data members of X that are of a
1086 // class type M (or array thereof), each such class type
1087 // has a copy constructor whose first parameter is of type
1088 // const M& or const volatile M&.
1114 }
1115
1116 if (!ClassDecl->hasUserDeclaredCopyConstructor()) {
1117 // C++ [class.copy]p4:
1118 // If the class definition does not explicitly declare a copy
1119 // constructor, one is declared implicitly.
1120
1121 // C++ [class.copy]p5:

--- 15 unchanged lines hidden (view full) ---

1137 HasConstCopyConstructor
1138 = BaseClassDecl->hasConstCopyConstructor(Context);
1139 }
1140
1141 // -- for all the nonstatic data members of X that are of a
1142 // class type M (or array thereof), each such class type
1143 // has a copy constructor whose first parameter is of type
1144 // const M& or const volatile M&.
1089 for (CXXRecordDecl::field_iterator Field = ClassDecl->field_begin(Context);
1090 HasConstCopyConstructor && Field != ClassDecl->field_end(Context);
1145 for (CXXRecordDecl::field_iterator Field = ClassDecl->field_begin();
1146 HasConstCopyConstructor && Field != ClassDecl->field_end();
1091 ++Field) {
1092 QualType FieldType = (*Field)->getType();
1093 if (const ArrayType *Array = Context.getAsArrayType(FieldType))
1094 FieldType = Array->getElementType();
1095 if (const RecordType *FieldClassType = FieldType->getAsRecordType()) {
1096 const CXXRecordDecl *FieldClassDecl
1097 = cast<CXXRecordDecl>(FieldClassType->getDecl());
1098 HasConstCopyConstructor

--- 27 unchanged lines hidden (view full) ---

1126 CopyConstructor->setImplicit();
1127
1128 // Add the parameter to the constructor.
1129 ParmVarDecl *FromParam = ParmVarDecl::Create(Context, CopyConstructor,
1130 ClassDecl->getLocation(),
1131 /*IdentifierInfo=*/0,
1132 ArgType, VarDecl::None, 0);
1133 CopyConstructor->setParams(Context, &FromParam, 1);
1147 ++Field) {
1148 QualType FieldType = (*Field)->getType();
1149 if (const ArrayType *Array = Context.getAsArrayType(FieldType))
1150 FieldType = Array->getElementType();
1151 if (const RecordType *FieldClassType = FieldType->getAsRecordType()) {
1152 const CXXRecordDecl *FieldClassDecl
1153 = cast<CXXRecordDecl>(FieldClassType->getDecl());
1154 HasConstCopyConstructor

--- 27 unchanged lines hidden (view full) ---

1182 CopyConstructor->setImplicit();
1183
1184 // Add the parameter to the constructor.
1185 ParmVarDecl *FromParam = ParmVarDecl::Create(Context, CopyConstructor,
1186 ClassDecl->getLocation(),
1187 /*IdentifierInfo=*/0,
1188 ArgType, VarDecl::None, 0);
1189 CopyConstructor->setParams(Context, &FromParam, 1);
1134 ClassDecl->addDecl(Context, CopyConstructor);
1190 ClassDecl->addDecl(CopyConstructor);
1135 }
1136
1137 if (!ClassDecl->hasUserDeclaredCopyAssignment()) {
1138 // Note: The following rules are largely analoguous to the copy
1139 // constructor rules. Note that virtual bases are not taken into account
1140 // for determining the argument type of the operator. Note also that
1141 // operators taking an object instead of a reference are allowed.
1142 //

--- 17 unchanged lines hidden (view full) ---

1160 = cast<CXXRecordDecl>(Base->getType()->getAsRecordType()->getDecl());
1161 HasConstCopyAssignment = BaseClassDecl->hasConstCopyAssignment(Context);
1162 }
1163
1164 // -- for all the nonstatic data members of X that are of a class
1165 // type M (or array thereof), each such class type has a copy
1166 // assignment operator whose parameter is of type const M&,
1167 // const volatile M& or M.
1191 }
1192
1193 if (!ClassDecl->hasUserDeclaredCopyAssignment()) {
1194 // Note: The following rules are largely analoguous to the copy
1195 // constructor rules. Note that virtual bases are not taken into account
1196 // for determining the argument type of the operator. Note also that
1197 // operators taking an object instead of a reference are allowed.
1198 //

--- 17 unchanged lines hidden (view full) ---

1216 = cast<CXXRecordDecl>(Base->getType()->getAsRecordType()->getDecl());
1217 HasConstCopyAssignment = BaseClassDecl->hasConstCopyAssignment(Context);
1218 }
1219
1220 // -- for all the nonstatic data members of X that are of a class
1221 // type M (or array thereof), each such class type has a copy
1222 // assignment operator whose parameter is of type const M&,
1223 // const volatile M& or M.
1168 for (CXXRecordDecl::field_iterator Field = ClassDecl->field_begin(Context);
1169 HasConstCopyAssignment && Field != ClassDecl->field_end(Context);
1224 for (CXXRecordDecl::field_iterator Field = ClassDecl->field_begin();
1225 HasConstCopyAssignment && Field != ClassDecl->field_end();
1170 ++Field) {
1171 QualType FieldType = (*Field)->getType();
1172 if (const ArrayType *Array = Context.getAsArrayType(FieldType))
1173 FieldType = Array->getElementType();
1174 if (const RecordType *FieldClassType = FieldType->getAsRecordType()) {
1175 const CXXRecordDecl *FieldClassDecl
1176 = cast<CXXRecordDecl>(FieldClassType->getDecl());
1177 HasConstCopyAssignment

--- 27 unchanged lines hidden (view full) ---

1205 ParmVarDecl *FromParam = ParmVarDecl::Create(Context, CopyAssignment,
1206 ClassDecl->getLocation(),
1207 /*IdentifierInfo=*/0,
1208 ArgType, VarDecl::None, 0);
1209 CopyAssignment->setParams(Context, &FromParam, 1);
1210
1211 // Don't call addedAssignmentOperator. There is no way to distinguish an
1212 // implicit from an explicit assignment operator.
1226 ++Field) {
1227 QualType FieldType = (*Field)->getType();
1228 if (const ArrayType *Array = Context.getAsArrayType(FieldType))
1229 FieldType = Array->getElementType();
1230 if (const RecordType *FieldClassType = FieldType->getAsRecordType()) {
1231 const CXXRecordDecl *FieldClassDecl
1232 = cast<CXXRecordDecl>(FieldClassType->getDecl());
1233 HasConstCopyAssignment

--- 27 unchanged lines hidden (view full) ---

1261 ParmVarDecl *FromParam = ParmVarDecl::Create(Context, CopyAssignment,
1262 ClassDecl->getLocation(),
1263 /*IdentifierInfo=*/0,
1264 ArgType, VarDecl::None, 0);
1265 CopyAssignment->setParams(Context, &FromParam, 1);
1266
1267 // Don't call addedAssignmentOperator. There is no way to distinguish an
1268 // implicit from an explicit assignment operator.
1213 ClassDecl->addDecl(Context, CopyAssignment);
1269 ClassDecl->addDecl(CopyAssignment);
1214 }
1215
1216 if (!ClassDecl->hasUserDeclaredDestructor()) {
1217 // C++ [class.dtor]p2:
1218 // If a class has no user-declared destructor, a destructor is
1219 // declared implicitly. An implicitly-declared destructor is an
1220 // inline public member of its class.
1221 DeclarationName Name
1222 = Context.DeclarationNames.getCXXDestructorName(ClassType);
1223 CXXDestructorDecl *Destructor
1224 = CXXDestructorDecl::Create(Context, ClassDecl,
1225 ClassDecl->getLocation(), Name,
1226 Context.getFunctionType(Context.VoidTy,
1227 0, 0, false, 0),
1228 /*isInline=*/true,
1229 /*isImplicitlyDeclared=*/true);
1230 Destructor->setAccess(AS_public);
1231 Destructor->setImplicit();
1270 }
1271
1272 if (!ClassDecl->hasUserDeclaredDestructor()) {
1273 // C++ [class.dtor]p2:
1274 // If a class has no user-declared destructor, a destructor is
1275 // declared implicitly. An implicitly-declared destructor is an
1276 // inline public member of its class.
1277 DeclarationName Name
1278 = Context.DeclarationNames.getCXXDestructorName(ClassType);
1279 CXXDestructorDecl *Destructor
1280 = CXXDestructorDecl::Create(Context, ClassDecl,
1281 ClassDecl->getLocation(), Name,
1282 Context.getFunctionType(Context.VoidTy,
1283 0, 0, false, 0),
1284 /*isInline=*/true,
1285 /*isImplicitlyDeclared=*/true);
1286 Destructor->setAccess(AS_public);
1287 Destructor->setImplicit();
1232 ClassDecl->addDecl(Context, Destructor);
1288 ClassDecl->addDecl(Destructor);
1233 }
1234}
1235
1236void Sema::ActOnReenterTemplateScope(Scope *S, DeclPtrTy TemplateD) {
1237 TemplateDecl *Template = TemplateD.getAs<TemplateDecl>();
1238 if (!Template)
1239 return;
1240

--- 526 unchanged lines hidden (view full) ---

1767 return DeclPtrTy::make(UDir);
1768}
1769
1770void Sema::PushUsingDirective(Scope *S, UsingDirectiveDecl *UDir) {
1771 // If scope has associated entity, then using directive is at namespace
1772 // or translation unit scope. We add UsingDirectiveDecls, into
1773 // it's lookup structure.
1774 if (DeclContext *Ctx = static_cast<DeclContext*>(S->getEntity()))
1289 }
1290}
1291
1292void Sema::ActOnReenterTemplateScope(Scope *S, DeclPtrTy TemplateD) {
1293 TemplateDecl *Template = TemplateD.getAs<TemplateDecl>();
1294 if (!Template)
1295 return;
1296

--- 526 unchanged lines hidden (view full) ---

1823 return DeclPtrTy::make(UDir);
1824}
1825
1826void Sema::PushUsingDirective(Scope *S, UsingDirectiveDecl *UDir) {
1827 // If scope has associated entity, then using directive is at namespace
1828 // or translation unit scope. We add UsingDirectiveDecls, into
1829 // it's lookup structure.
1830 if (DeclContext *Ctx = static_cast<DeclContext*>(S->getEntity()))
1775 Ctx->addDecl(Context, UDir);
1831 Ctx->addDecl(UDir);
1776 else
1777 // Otherwise it is block-sope. using-directives will affect lookup
1778 // only to the end of scope.
1779 S->PushUsingDirective(DeclPtrTy::make(UDir));
1780}
1781
1782
1783Sema::DeclPtrTy Sema::ActOnUsingDeclaration(Scope *S,

--- 84 unchanged lines hidden (view full) ---

1868 }
1869
1870 NamespaceAliasDecl *AliasDecl =
1871 NamespaceAliasDecl::Create(Context, CurContext, NamespaceLoc, AliasLoc,
1872 Alias, SS.getRange(),
1873 (NestedNameSpecifier *)SS.getScopeRep(),
1874 IdentLoc, R);
1875
1832 else
1833 // Otherwise it is block-sope. using-directives will affect lookup
1834 // only to the end of scope.
1835 S->PushUsingDirective(DeclPtrTy::make(UDir));
1836}
1837
1838
1839Sema::DeclPtrTy Sema::ActOnUsingDeclaration(Scope *S,

--- 84 unchanged lines hidden (view full) ---

1924 }
1925
1926 NamespaceAliasDecl *AliasDecl =
1927 NamespaceAliasDecl::Create(Context, CurContext, NamespaceLoc, AliasLoc,
1928 Alias, SS.getRange(),
1929 (NestedNameSpecifier *)SS.getScopeRep(),
1930 IdentLoc, R);
1931
1876 CurContext->addDecl(Context, AliasDecl);
1932 CurContext->addDecl(AliasDecl);
1877 return DeclPtrTy::make(AliasDecl);
1878}
1879
1880void Sema::DefineImplicitDefaultConstructor(SourceLocation CurrentLocation,
1881 CXXConstructorDecl *Constructor) {
1882 assert((Constructor->isImplicit() && Constructor->isDefaultConstructor() &&
1883 !Constructor->isUsed()) &&
1884 "DefineImplicitDefaultConstructor - call it for implicit default ctor");
1885
1886 CXXRecordDecl *ClassDecl
1887 = cast<CXXRecordDecl>(Constructor->getDeclContext());
1888 assert(ClassDecl && "DefineImplicitDefaultConstructor - invalid constructor");
1889 // Before the implicitly-declared default constructor for a class is
1890 // implicitly defined, all the implicitly-declared default constructors
1891 // for its base class and its non-static data members shall have been
1892 // implicitly defined.
1893 bool err = false;
1933 return DeclPtrTy::make(AliasDecl);
1934}
1935
1936void Sema::DefineImplicitDefaultConstructor(SourceLocation CurrentLocation,
1937 CXXConstructorDecl *Constructor) {
1938 assert((Constructor->isImplicit() && Constructor->isDefaultConstructor() &&
1939 !Constructor->isUsed()) &&
1940 "DefineImplicitDefaultConstructor - call it for implicit default ctor");
1941
1942 CXXRecordDecl *ClassDecl
1943 = cast<CXXRecordDecl>(Constructor->getDeclContext());
1944 assert(ClassDecl && "DefineImplicitDefaultConstructor - invalid constructor");
1945 // Before the implicitly-declared default constructor for a class is
1946 // implicitly defined, all the implicitly-declared default constructors
1947 // for its base class and its non-static data members shall have been
1948 // implicitly defined.
1949 bool err = false;
1894 for (CXXRecordDecl::base_class_iterator Base = ClassDecl->bases_begin();
1895 Base != ClassDecl->bases_end(); ++Base) {
1950 for (CXXRecordDecl::base_class_iterator Base = ClassDecl->bases_begin(),
1951 E = ClassDecl->bases_end(); Base != E; ++Base) {
1896 CXXRecordDecl *BaseClassDecl
1897 = cast<CXXRecordDecl>(Base->getType()->getAsRecordType()->getDecl());
1898 if (!BaseClassDecl->hasTrivialConstructor()) {
1899 if (CXXConstructorDecl *BaseCtor =
1900 BaseClassDecl->getDefaultConstructor(Context))
1901 MarkDeclarationReferenced(CurrentLocation, BaseCtor);
1902 else {
1903 Diag(CurrentLocation, diag::err_defining_default_ctor)
1904 << Context.getTagDeclType(ClassDecl) << 1
1905 << Context.getTagDeclType(BaseClassDecl);
1906 Diag(BaseClassDecl->getLocation(), diag::note_previous_class_decl)
1907 << Context.getTagDeclType(BaseClassDecl);
1908 err = true;
1909 }
1910 }
1911 }
1952 CXXRecordDecl *BaseClassDecl
1953 = cast<CXXRecordDecl>(Base->getType()->getAsRecordType()->getDecl());
1954 if (!BaseClassDecl->hasTrivialConstructor()) {
1955 if (CXXConstructorDecl *BaseCtor =
1956 BaseClassDecl->getDefaultConstructor(Context))
1957 MarkDeclarationReferenced(CurrentLocation, BaseCtor);
1958 else {
1959 Diag(CurrentLocation, diag::err_defining_default_ctor)
1960 << Context.getTagDeclType(ClassDecl) << 1
1961 << Context.getTagDeclType(BaseClassDecl);
1962 Diag(BaseClassDecl->getLocation(), diag::note_previous_class_decl)
1963 << Context.getTagDeclType(BaseClassDecl);
1964 err = true;
1965 }
1966 }
1967 }
1912 for (CXXRecordDecl::field_iterator Field = ClassDecl->field_begin(Context);
1913 Field != ClassDecl->field_end(Context);
1914 ++Field) {
1968 for (CXXRecordDecl::field_iterator Field = ClassDecl->field_begin(),
1969 E = ClassDecl->field_end(); Field != E; ++Field) {
1915 QualType FieldType = Context.getCanonicalType((*Field)->getType());
1916 if (const ArrayType *Array = Context.getAsArrayType(FieldType))
1917 FieldType = Array->getElementType();
1918 if (const RecordType *FieldClassType = FieldType->getAsRecordType()) {
1919 CXXRecordDecl *FieldClassDecl
1920 = cast<CXXRecordDecl>(FieldClassType->getDecl());
1921 if (!FieldClassDecl->hasTrivialConstructor()) {
1922 if (CXXConstructorDecl *FieldCtor =

--- 36 unchanged lines hidden (view full) ---

1959 CXXRecordDecl *ClassDecl
1960 = cast<CXXRecordDecl>(Destructor->getDeclContext());
1961 assert(ClassDecl && "DefineImplicitDestructor - invalid destructor");
1962 // C++ [class.dtor] p5
1963 // Before the implicitly-declared default destructor for a class is
1964 // implicitly defined, all the implicitly-declared default destructors
1965 // for its base class and its non-static data members shall have been
1966 // implicitly defined.
1970 QualType FieldType = Context.getCanonicalType((*Field)->getType());
1971 if (const ArrayType *Array = Context.getAsArrayType(FieldType))
1972 FieldType = Array->getElementType();
1973 if (const RecordType *FieldClassType = FieldType->getAsRecordType()) {
1974 CXXRecordDecl *FieldClassDecl
1975 = cast<CXXRecordDecl>(FieldClassType->getDecl());
1976 if (!FieldClassDecl->hasTrivialConstructor()) {
1977 if (CXXConstructorDecl *FieldCtor =

--- 36 unchanged lines hidden (view full) ---

2014 CXXRecordDecl *ClassDecl
2015 = cast<CXXRecordDecl>(Destructor->getDeclContext());
2016 assert(ClassDecl && "DefineImplicitDestructor - invalid destructor");
2017 // C++ [class.dtor] p5
2018 // Before the implicitly-declared default destructor for a class is
2019 // implicitly defined, all the implicitly-declared default destructors
2020 // for its base class and its non-static data members shall have been
2021 // implicitly defined.
1967 for (CXXRecordDecl::base_class_iterator Base = ClassDecl->bases_begin();
1968 Base != ClassDecl->bases_end(); ++Base) {
2022 for (CXXRecordDecl::base_class_iterator Base = ClassDecl->bases_begin(),
2023 E = ClassDecl->bases_end(); Base != E; ++Base) {
1969 CXXRecordDecl *BaseClassDecl
1970 = cast<CXXRecordDecl>(Base->getType()->getAsRecordType()->getDecl());
1971 if (!BaseClassDecl->hasTrivialDestructor()) {
1972 if (CXXDestructorDecl *BaseDtor =
1973 const_cast<CXXDestructorDecl*>(BaseClassDecl->getDestructor(Context)))
1974 MarkDeclarationReferenced(CurrentLocation, BaseDtor);
1975 else
1976 assert(false &&
1977 "DefineImplicitDestructor - missing dtor in a base class");
1978 }
1979 }
1980
2024 CXXRecordDecl *BaseClassDecl
2025 = cast<CXXRecordDecl>(Base->getType()->getAsRecordType()->getDecl());
2026 if (!BaseClassDecl->hasTrivialDestructor()) {
2027 if (CXXDestructorDecl *BaseDtor =
2028 const_cast<CXXDestructorDecl*>(BaseClassDecl->getDestructor(Context)))
2029 MarkDeclarationReferenced(CurrentLocation, BaseDtor);
2030 else
2031 assert(false &&
2032 "DefineImplicitDestructor - missing dtor in a base class");
2033 }
2034 }
2035
1981 for (CXXRecordDecl::field_iterator Field = ClassDecl->field_begin(Context);
1982 Field != ClassDecl->field_end(Context);
1983 ++Field) {
2036 for (CXXRecordDecl::field_iterator Field = ClassDecl->field_begin(),
2037 E = ClassDecl->field_end(); Field != E; ++Field) {
1984 QualType FieldType = Context.getCanonicalType((*Field)->getType());
1985 if (const ArrayType *Array = Context.getAsArrayType(FieldType))
1986 FieldType = Array->getElementType();
1987 if (const RecordType *FieldClassType = FieldType->getAsRecordType()) {
1988 CXXRecordDecl *FieldClassDecl
1989 = cast<CXXRecordDecl>(FieldClassType->getDecl());
1990 if (!FieldClassDecl->hasTrivialDestructor()) {
1991 if (CXXDestructorDecl *FieldDtor =

--- 13 unchanged lines hidden (view full) ---

2005 CXXMethodDecl *MethodDecl) {
2006 assert((MethodDecl->isImplicit() && MethodDecl->isOverloadedOperator() &&
2007 MethodDecl->getOverloadedOperator() == OO_Equal &&
2008 !MethodDecl->isUsed()) &&
2009 "DefineImplicitOverloadedAssign - call it for implicit assignment op");
2010
2011 CXXRecordDecl *ClassDecl
2012 = cast<CXXRecordDecl>(MethodDecl->getDeclContext());
2038 QualType FieldType = Context.getCanonicalType((*Field)->getType());
2039 if (const ArrayType *Array = Context.getAsArrayType(FieldType))
2040 FieldType = Array->getElementType();
2041 if (const RecordType *FieldClassType = FieldType->getAsRecordType()) {
2042 CXXRecordDecl *FieldClassDecl
2043 = cast<CXXRecordDecl>(FieldClassType->getDecl());
2044 if (!FieldClassDecl->hasTrivialDestructor()) {
2045 if (CXXDestructorDecl *FieldDtor =

--- 13 unchanged lines hidden (view full) ---

2059 CXXMethodDecl *MethodDecl) {
2060 assert((MethodDecl->isImplicit() && MethodDecl->isOverloadedOperator() &&
2061 MethodDecl->getOverloadedOperator() == OO_Equal &&
2062 !MethodDecl->isUsed()) &&
2063 "DefineImplicitOverloadedAssign - call it for implicit assignment op");
2064
2065 CXXRecordDecl *ClassDecl
2066 = cast<CXXRecordDecl>(MethodDecl->getDeclContext());
2013 assert(ClassDecl && "DefineImplicitOverloadedAssign - invalid constructor");
2014
2015 // C++[class.copy] p12
2016 // Before the implicitly-declared copy assignment operator for a class is
2017 // implicitly defined, all implicitly-declared copy assignment operators
2018 // for its direct base classes and its nonstatic data members shall have
2019 // been implicitly defined.
2020 bool err = false;
2067
2068 // C++[class.copy] p12
2069 // Before the implicitly-declared copy assignment operator for a class is
2070 // implicitly defined, all implicitly-declared copy assignment operators
2071 // for its direct base classes and its nonstatic data members shall have
2072 // been implicitly defined.
2073 bool err = false;
2021 for (CXXRecordDecl::base_class_iterator Base = ClassDecl->bases_begin();
2022 Base != ClassDecl->bases_end(); ++Base) {
2074 for (CXXRecordDecl::base_class_iterator Base = ClassDecl->bases_begin(),
2075 E = ClassDecl->bases_end(); Base != E; ++Base) {
2023 CXXRecordDecl *BaseClassDecl
2024 = cast<CXXRecordDecl>(Base->getType()->getAsRecordType()->getDecl());
2025 if (CXXMethodDecl *BaseAssignOpMethod =
2026 getAssignOperatorMethod(MethodDecl->getParamDecl(0), BaseClassDecl))
2027 MarkDeclarationReferenced(CurrentLocation, BaseAssignOpMethod);
2028 }
2076 CXXRecordDecl *BaseClassDecl
2077 = cast<CXXRecordDecl>(Base->getType()->getAsRecordType()->getDecl());
2078 if (CXXMethodDecl *BaseAssignOpMethod =
2079 getAssignOperatorMethod(MethodDecl->getParamDecl(0), BaseClassDecl))
2080 MarkDeclarationReferenced(CurrentLocation, BaseAssignOpMethod);
2081 }
2029 for (CXXRecordDecl::field_iterator Field = ClassDecl->field_begin(Context);
2030 Field != ClassDecl->field_end(Context);
2031 ++Field) {
2082 for (CXXRecordDecl::field_iterator Field = ClassDecl->field_begin(),
2083 E = ClassDecl->field_end(); Field != E; ++Field) {
2032 QualType FieldType = Context.getCanonicalType((*Field)->getType());
2033 if (const ArrayType *Array = Context.getAsArrayType(FieldType))
2034 FieldType = Array->getElementType();
2035 if (const RecordType *FieldClassType = FieldType->getAsRecordType()) {
2036 CXXRecordDecl *FieldClassDecl
2037 = cast<CXXRecordDecl>(FieldClassType->getDecl());
2038 if (CXXMethodDecl *FieldAssignOpMethod =
2039 getAssignOperatorMethod(MethodDecl->getParamDecl(0), FieldClassDecl))

--- 68 unchanged lines hidden (view full) ---

2108 for (CXXRecordDecl::base_class_iterator Base = ClassDecl->bases_begin();
2109 Base != ClassDecl->bases_end(); ++Base) {
2110 CXXRecordDecl *BaseClassDecl
2111 = cast<CXXRecordDecl>(Base->getType()->getAsRecordType()->getDecl());
2112 if (CXXConstructorDecl *BaseCopyCtor =
2113 BaseClassDecl->getCopyConstructor(Context, TypeQuals))
2114 MarkDeclarationReferenced(CurrentLocation, BaseCopyCtor);
2115 }
2084 QualType FieldType = Context.getCanonicalType((*Field)->getType());
2085 if (const ArrayType *Array = Context.getAsArrayType(FieldType))
2086 FieldType = Array->getElementType();
2087 if (const RecordType *FieldClassType = FieldType->getAsRecordType()) {
2088 CXXRecordDecl *FieldClassDecl
2089 = cast<CXXRecordDecl>(FieldClassType->getDecl());
2090 if (CXXMethodDecl *FieldAssignOpMethod =
2091 getAssignOperatorMethod(MethodDecl->getParamDecl(0), FieldClassDecl))

--- 68 unchanged lines hidden (view full) ---

2160 for (CXXRecordDecl::base_class_iterator Base = ClassDecl->bases_begin();
2161 Base != ClassDecl->bases_end(); ++Base) {
2162 CXXRecordDecl *BaseClassDecl
2163 = cast<CXXRecordDecl>(Base->getType()->getAsRecordType()->getDecl());
2164 if (CXXConstructorDecl *BaseCopyCtor =
2165 BaseClassDecl->getCopyConstructor(Context, TypeQuals))
2166 MarkDeclarationReferenced(CurrentLocation, BaseCopyCtor);
2167 }
2116 for (CXXRecordDecl::field_iterator Field = ClassDecl->field_begin(Context);
2117 Field != ClassDecl->field_end(Context);
2118 ++Field) {
2168 for (CXXRecordDecl::field_iterator Field = ClassDecl->field_begin(),
2169 FieldEnd = ClassDecl->field_end();
2170 Field != FieldEnd; ++Field) {
2119 QualType FieldType = Context.getCanonicalType((*Field)->getType());
2120 if (const ArrayType *Array = Context.getAsArrayType(FieldType))
2121 FieldType = Array->getElementType();
2122 if (const RecordType *FieldClassType = FieldType->getAsRecordType()) {
2123 CXXRecordDecl *FieldClassDecl
2124 = cast<CXXRecordDecl>(FieldClassType->getDecl());
2125 if (CXXConstructorDecl *FieldCopyCtor =
2126 FieldClassDecl->getCopyConstructor(Context, TypeQuals))

--- 8 unchanged lines hidden (view full) ---

2135 QualType DeclInitType,
2136 Expr **Exprs, unsigned NumExprs) {
2137 Expr *Temp = CXXConstructExpr::Create(Context, DeclInitType, Constructor,
2138 false, Exprs, NumExprs);
2139 MarkDeclarationReferenced(VD->getLocation(), Constructor);
2140 VD->setInit(Context, Temp);
2141}
2142
2171 QualType FieldType = Context.getCanonicalType((*Field)->getType());
2172 if (const ArrayType *Array = Context.getAsArrayType(FieldType))
2173 FieldType = Array->getElementType();
2174 if (const RecordType *FieldClassType = FieldType->getAsRecordType()) {
2175 CXXRecordDecl *FieldClassDecl
2176 = cast<CXXRecordDecl>(FieldClassType->getDecl());
2177 if (CXXConstructorDecl *FieldCopyCtor =
2178 FieldClassDecl->getCopyConstructor(Context, TypeQuals))

--- 8 unchanged lines hidden (view full) ---

2187 QualType DeclInitType,
2188 Expr **Exprs, unsigned NumExprs) {
2189 Expr *Temp = CXXConstructExpr::Create(Context, DeclInitType, Constructor,
2190 false, Exprs, NumExprs);
2191 MarkDeclarationReferenced(VD->getLocation(), Constructor);
2192 VD->setInit(Context, Temp);
2193}
2194
2143void Sema::MarcDestructorReferenced(SourceLocation Loc, QualType DeclInitType)
2195void Sema::MarkDestructorReferenced(SourceLocation Loc, QualType DeclInitType)
2144{
2145 CXXRecordDecl *ClassDecl = cast<CXXRecordDecl>(
2146 DeclInitType->getAsRecordType()->getDecl());
2147 if (!ClassDecl->hasTrivialDestructor())
2148 if (CXXDestructorDecl *Destructor =
2149 const_cast<CXXDestructorDecl*>(ClassDecl->getDestructor(Context)))
2150 MarkDeclarationReferenced(Loc, Destructor);
2151}

--- 61 unchanged lines hidden (view full) ---

2213 if (!Constructor)
2214 RealDecl->setInvalidDecl();
2215 else {
2216 VDecl->setCXXDirectInitializer(true);
2217 InitializeVarWithConstructor(VDecl, Constructor, DeclInitType,
2218 (Expr**)Exprs.release(), NumExprs);
2219 // FIXME. Must do all that is needed to destroy the object
2220 // on scope exit. For now, just mark the destructor as used.
2196{
2197 CXXRecordDecl *ClassDecl = cast<CXXRecordDecl>(
2198 DeclInitType->getAsRecordType()->getDecl());
2199 if (!ClassDecl->hasTrivialDestructor())
2200 if (CXXDestructorDecl *Destructor =
2201 const_cast<CXXDestructorDecl*>(ClassDecl->getDestructor(Context)))
2202 MarkDeclarationReferenced(Loc, Destructor);
2203}

--- 61 unchanged lines hidden (view full) ---

2265 if (!Constructor)
2266 RealDecl->setInvalidDecl();
2267 else {
2268 VDecl->setCXXDirectInitializer(true);
2269 InitializeVarWithConstructor(VDecl, Constructor, DeclInitType,
2270 (Expr**)Exprs.release(), NumExprs);
2271 // FIXME. Must do all that is needed to destroy the object
2272 // on scope exit. For now, just mark the destructor as used.
2221 MarcDestructorReferenced(VDecl->getLocation(), DeclInitType);
2273 MarkDestructorReferenced(VDecl->getLocation(), DeclInitType);
2222 }
2223 return;
2224 }
2225
2226 if (NumExprs > 1) {
2227 Diag(CommaLocs[0], diag::err_builtin_direct_init_more_than_one_arg)
2228 << SourceRange(VDecl->getLocation(), RParenLoc);
2229 RealDecl->setInvalidDecl();

--- 47 unchanged lines hidden (view full) ---

2277 const CXXRecordDecl *ClassDecl = cast<CXXRecordDecl>(ClassRec->getDecl());
2278 OverloadCandidateSet CandidateSet;
2279
2280 // Add constructors to the overload set.
2281 DeclarationName ConstructorName
2282 = Context.DeclarationNames.getCXXConstructorName(
2283 Context.getCanonicalType(ClassType.getUnqualifiedType()));
2284 DeclContext::lookup_const_iterator Con, ConEnd;
2274 }
2275 return;
2276 }
2277
2278 if (NumExprs > 1) {
2279 Diag(CommaLocs[0], diag::err_builtin_direct_init_more_than_one_arg)
2280 << SourceRange(VDecl->getLocation(), RParenLoc);
2281 RealDecl->setInvalidDecl();

--- 47 unchanged lines hidden (view full) ---

2329 const CXXRecordDecl *ClassDecl = cast<CXXRecordDecl>(ClassRec->getDecl());
2330 OverloadCandidateSet CandidateSet;
2331
2332 // Add constructors to the overload set.
2333 DeclarationName ConstructorName
2334 = Context.DeclarationNames.getCXXConstructorName(
2335 Context.getCanonicalType(ClassType.getUnqualifiedType()));
2336 DeclContext::lookup_const_iterator Con, ConEnd;
2285 for (llvm::tie(Con, ConEnd) = ClassDecl->lookup(Context, ConstructorName);
2337 for (llvm::tie(Con, ConEnd) = ClassDecl->lookup(ConstructorName);
2286 Con != ConEnd; ++Con) {
2287 CXXConstructorDecl *Constructor = cast<CXXConstructorDecl>(*Con);
2288 if ((Kind == IK_Direct) ||
2289 (Kind == IK_Copy && Constructor->isConvertingConstructor()) ||
2290 (Kind == IK_Default && Constructor->isDefaultConstructor()))
2291 AddOverloadCandidate(Constructor, Args, NumArgs, CandidateSet);
2292 }
2293

--- 593 unchanged lines hidden (view full) ---

2887 return DeclPtrTy();
2888 }
2889
2890 // FIXME: Add all the various semantics of linkage specifications
2891
2892 LinkageSpecDecl *D = LinkageSpecDecl::Create(Context, CurContext,
2893 LangLoc, Language,
2894 LBraceLoc.isValid());
2338 Con != ConEnd; ++Con) {
2339 CXXConstructorDecl *Constructor = cast<CXXConstructorDecl>(*Con);
2340 if ((Kind == IK_Direct) ||
2341 (Kind == IK_Copy && Constructor->isConvertingConstructor()) ||
2342 (Kind == IK_Default && Constructor->isDefaultConstructor()))
2343 AddOverloadCandidate(Constructor, Args, NumArgs, CandidateSet);
2344 }
2345

--- 593 unchanged lines hidden (view full) ---

2939 return DeclPtrTy();
2940 }
2941
2942 // FIXME: Add all the various semantics of linkage specifications
2943
2944 LinkageSpecDecl *D = LinkageSpecDecl::Create(Context, CurContext,
2945 LangLoc, Language,
2946 LBraceLoc.isValid());
2895 CurContext->addDecl(Context, D);
2947 CurContext->addDecl(D);
2896 PushDeclContext(S, D);
2897 return DeclPtrTy::make(D);
2898}
2899
2900/// ActOnFinishLinkageSpecification - Completely the definition of
2901/// the C++ linkage specification LinkageSpec. If RBraceLoc is
2902/// valid, it's the position of the closing '}' brace in a linkage
2903/// specification that uses braces.

--- 97 unchanged lines hidden (view full) ---

3001
3002 if (Invalid)
3003 ExDecl->setInvalidDecl();
3004
3005 // Add the exception declaration into this scope.
3006 if (II)
3007 PushOnScopeChains(ExDecl, S);
3008 else
2948 PushDeclContext(S, D);
2949 return DeclPtrTy::make(D);
2950}
2951
2952/// ActOnFinishLinkageSpecification - Completely the definition of
2953/// the C++ linkage specification LinkageSpec. If RBraceLoc is
2954/// valid, it's the position of the closing '}' brace in a linkage
2955/// specification that uses braces.

--- 97 unchanged lines hidden (view full) ---

3053
3054 if (Invalid)
3055 ExDecl->setInvalidDecl();
3056
3057 // Add the exception declaration into this scope.
3058 if (II)
3059 PushOnScopeChains(ExDecl, S);
3060 else
3009 CurContext->addDecl(Context, ExDecl);
3061 CurContext->addDecl(ExDecl);
3010
3011 ProcessDeclAttributes(S, ExDecl, D);
3012 return DeclPtrTy::make(ExDecl);
3013}
3014
3015Sema::DeclPtrTy Sema::ActOnStaticAssertDeclaration(SourceLocation AssertLoc,
3016 ExprArg assertexpr,
3017 ExprArg assertmessageexpr) {

--- 17 unchanged lines hidden (view full) ---

3035 }
3036 }
3037
3038 assertexpr.release();
3039 assertmessageexpr.release();
3040 Decl *Decl = StaticAssertDecl::Create(Context, CurContext, AssertLoc,
3041 AssertExpr, AssertMessage);
3042
3062
3063 ProcessDeclAttributes(S, ExDecl, D);
3064 return DeclPtrTy::make(ExDecl);
3065}
3066
3067Sema::DeclPtrTy Sema::ActOnStaticAssertDeclaration(SourceLocation AssertLoc,
3068 ExprArg assertexpr,
3069 ExprArg assertmessageexpr) {

--- 17 unchanged lines hidden (view full) ---

3087 }
3088 }
3089
3090 assertexpr.release();
3091 assertmessageexpr.release();
3092 Decl *Decl = StaticAssertDecl::Create(Context, CurContext, AssertLoc,
3093 AssertExpr, AssertMessage);
3094
3043 CurContext->addDecl(Context, Decl);
3095 CurContext->addDecl(Decl);
3044 return DeclPtrTy::make(Decl);
3045}
3046
3047bool Sema::ActOnFriendDecl(Scope *S, SourceLocation FriendLoc, DeclPtrTy Dcl) {
3048 if (!(S->getFlags() & Scope::ClassScope)) {
3049 Diag(FriendLoc, diag::err_friend_decl_outside_class);
3050 return true;
3051 }

--- 164 unchanged lines hidden ---
3096 return DeclPtrTy::make(Decl);
3097}
3098
3099bool Sema::ActOnFriendDecl(Scope *S, SourceLocation FriendLoc, DeclPtrTy Dcl) {
3100 if (!(S->getFlags() & Scope::ClassScope)) {
3101 Diag(FriendLoc, diag::err_friend_decl_outside_class);
3102 return true;
3103 }

--- 164 unchanged lines hidden ---