[cfe-commits] r88990 - /cfe/trunk/lib/Sema/SemaDeclCXX.cpp

Eli Friedman eli.friedman at gmail.com
Mon Nov 16 15:07:59 PST 2009


Author: efriedma
Date: Mon Nov 16 17:07:59 2009
New Revision: 88990

URL: http://llvm.org/viewvc/llvm-project?rev=88990&view=rev
Log:
Simplify the AST a bit by skipping creating member initializers for members
with a trivial constructor.


Modified:
    cfe/trunk/lib/Sema/SemaDeclCXX.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=88990&r1=88989&r2=88990&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Mon Nov 16 17:07:59 2009
@@ -1398,7 +1398,20 @@
         HadError = true;
         continue;
       }
-      
+
+      if (FT.isConstQualified() && Ctor->isTrivial()) {
+        Diag(Constructor->getLocation(), diag::err_unintialized_member_in_ctor)
+          << (int)IsImplicitConstructor << Context.getTagDeclType(ClassDecl)
+          << 1 << (*Field)->getDeclName();
+        Diag((*Field)->getLocation(), diag::note_declared_at);
+        HadError = true;
+      }
+
+      // Don't create initializers for trivial constructors, since they don't
+      // actually need to be run.
+      if (Ctor->isTrivial())
+        continue;
+
       ASTOwningVector<&ActionBase::DeleteExpr> CtorArgs(*this);
       if (CompleteConstructorCall(Ctor, MultiExprArg(*this, 0, 0), 
                                   Constructor->getLocation(), CtorArgs))
@@ -1415,13 +1428,6 @@
 
       AllToInit.push_back(Member);
       MarkDeclarationReferenced(Constructor->getLocation(), Ctor);
-      if (FT.isConstQualified() && Ctor->isTrivial()) {
-        Diag(Constructor->getLocation(), diag::err_unintialized_member_in_ctor)
-          << (int)IsImplicitConstructor << Context.getTagDeclType(ClassDecl)
-          << 1 << (*Field)->getDeclName();
-        Diag((*Field)->getLocation(), diag::note_declared_at);
-        HadError = true;
-      }
     }
     else if (FT->isReferenceType()) {
       Diag(Constructor->getLocation(), diag::err_unintialized_member_in_ctor)





More information about the cfe-commits mailing list