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

Chandler Carruth chandlerc at gmail.com
Tue Jun 29 16:50:44 PDT 2010


Author: chandlerc
Date: Tue Jun 29 18:50:44 2010
New Revision: 107226

URL: http://llvm.org/viewvc/llvm-project?rev=107226&view=rev
Log:
Retain the source location of the constructor when building an implicit member
initialization. I tried several ideas but couldn't come up with a test case for
this that didn't rely on a Clang bug to report a diagnostic after template
instantiation of the constructor due to the implicit initializers. Suggestions
welcome. This fixes the source location aspect of PR7402.

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=107226&r1=107225&r2=107226&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Tue Jun 29 18:50:44 2010
@@ -1580,8 +1580,9 @@
   if (Field->isInvalidDecl())
     return true;
 
+  SourceLocation Loc = Constructor->getLocation();
+
   if (ImplicitInitKind == IIK_Copy) {
-    SourceLocation Loc = Constructor->getLocation();
     ParmVarDecl *Param = Constructor->getParamDecl(0);
     QualType ParamType = Param->getType().getNonReferenceType();
     
@@ -1689,7 +1690,7 @@
   if (FieldBaseElementType->isRecordType()) {
     InitializedEntity InitEntity = InitializedEntity::InitializeMember(Field);
     InitializationKind InitKind = 
-      InitializationKind::CreateDefault(Constructor->getLocation());
+      InitializationKind::CreateDefault(Loc);
     
     InitializationSequence InitSeq(SemaRef, InitEntity, InitKind, 0, 0);
     Sema::OwningExprResult MemberInit = 
@@ -1701,10 +1702,9 @@
     
     CXXMemberInit =
       new (SemaRef.Context) CXXBaseOrMemberInitializer(SemaRef.Context,
-                                                       Field, SourceLocation(),
-                                                       SourceLocation(),
+                                                       Field, Loc, Loc,
                                                       MemberInit.takeAs<Expr>(),
-                                                       SourceLocation());
+                                                       Loc);
     return false;
   }
 





More information about the cfe-commits mailing list