diff options
| author | Douglas Gregor <dgregor@apple.com> | 2010-07-01 22:02:46 +0000 | 
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2010-07-01 22:02:46 +0000 | 
| commit | 4e8b5fb1eb7138482b61fda9188ef19bcc14918f (patch) | |
| tree | 413fd0209fa025693a969727fc5ed0cb55f38f04 /clang/lib/Sema/SemaDeclCXX.cpp | |
| parent | 03bcd6ecc8e71af76a3ca1277adb4c2440265893 (diff) | |
| download | bcm5719-llvm-4e8b5fb1eb7138482b61fda9188ef19bcc14918f.tar.gz bcm5719-llvm-4e8b5fb1eb7138482b61fda9188ef19bcc14918f.zip | |
Move the implicit declaration of a default constructor into a separate
routine; no functionality change.
llvm-svn: 107434
Diffstat (limited to 'clang/lib/Sema/SemaDeclCXX.cpp')
| -rw-r--r-- | clang/lib/Sema/SemaDeclCXX.cpp | 68 | 
1 files changed, 36 insertions, 32 deletions
| diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index 56e965f81fe..714814afc17 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -2656,41 +2656,11 @@ namespace {  /// The scope, if provided, is the class scope.  void Sema::AddImplicitlyDeclaredMembersToClass(Scope *S,                                                  CXXRecordDecl *ClassDecl) { -  CanQualType ClassType -    = Context.getCanonicalType(Context.getTypeDeclType(ClassDecl)); -    // FIXME: Implicit declarations have exception specifications, which are    // the union of the specifications of the implicitly called functions. -  if (!ClassDecl->hasUserDeclaredConstructor()) { -    // C++ [class.ctor]p5: -    //   A default constructor for a class X is a constructor of class X -    //   that can be called without an argument. If there is no -    //   user-declared constructor for class X, a default constructor is -    //   implicitly declared. An implicitly-declared default constructor -    //   is an inline public member of its class. -    DeclarationName Name -      = Context.DeclarationNames.getCXXConstructorName(ClassType); -    CXXConstructorDecl *DefaultCon = -      CXXConstructorDecl::Create(Context, ClassDecl, -                                 ClassDecl->getLocation(), Name, -                                 Context.getFunctionType(Context.VoidTy, -                                                         0, 0, false, 0, -                                                         /*FIXME*/false, false, -                                                         0, 0, -                                                       FunctionType::ExtInfo()), -                                 /*TInfo=*/0, -                                 /*isExplicit=*/false, -                                 /*isInline=*/true, -                                 /*isImplicitlyDeclared=*/true); -    DefaultCon->setAccess(AS_public); -    DefaultCon->setImplicit(); -    DefaultCon->setTrivial(ClassDecl->hasTrivialConstructor()); -    if (S) -      PushOnScopeChains(DefaultCon, S, true); -    else -      ClassDecl->addDecl(DefaultCon); -  } +  if (!ClassDecl->hasUserDeclaredConstructor()) +    DeclareImplicitDefaultConstructor(S, ClassDecl);    if (!ClassDecl->hasUserDeclaredCopyConstructor())      DeclareImplicitCopyConstructor(S, ClassDecl); @@ -4168,6 +4138,40 @@ namespace {    };  } +CXXConstructorDecl *Sema::DeclareImplicitDefaultConstructor(Scope *S, +                                                    CXXRecordDecl *ClassDecl) { +  // C++ [class.ctor]p5: +  //   A default constructor for a class X is a constructor of class X +  //   that can be called without an argument. If there is no +  //   user-declared constructor for class X, a default constructor is +  //   implicitly declared. An implicitly-declared default constructor +  //   is an inline public member of its class. +  CanQualType ClassType +    = Context.getCanonicalType(Context.getTypeDeclType(ClassDecl)); +  DeclarationName Name +    = Context.DeclarationNames.getCXXConstructorName(ClassType); +  CXXConstructorDecl *DefaultCon +    = CXXConstructorDecl::Create(Context, ClassDecl, +                                 ClassDecl->getLocation(), Name, +                                 Context.getFunctionType(Context.VoidTy, +                                                         0, 0, false, 0, +                                                         /*FIXME*/false, false, +                                                         0, 0, +                                                       FunctionType::ExtInfo()), +                                 /*TInfo=*/0, +                                 /*isExplicit=*/false, +                                 /*isInline=*/true, +                                 /*isImplicitlyDeclared=*/true); +  DefaultCon->setAccess(AS_public); +  DefaultCon->setImplicit(); +  DefaultCon->setTrivial(ClassDecl->hasTrivialConstructor()); +  if (S) +    PushOnScopeChains(DefaultCon, S, true); +  else +    ClassDecl->addDecl(DefaultCon); +  return DefaultCon; +} +  void Sema::DefineImplicitDefaultConstructor(SourceLocation CurrentLocation,                                              CXXConstructorDecl *Constructor) {    assert((Constructor->isImplicit() && Constructor->isDefaultConstructor() && | 

