]> granicus.if.org Git - clang/commitdiff
Fix source location of the initializer in
authorFariborz Jahanian <fjahanian@apple.com>
Wed, 21 Jul 2010 18:31:47 +0000 (18:31 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Wed, 21 Jul 2010 18:31:47 +0000 (18:31 +0000)
a copy initialization. Back out hack in objc rewriter.
fixes radar 8213998.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109024 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Rewrite/RewriteObjC.cpp
lib/Sema/SemaInit.cpp
lib/Sema/SemaInit.h

index 2743a2bdc190854cc638a3b19c420bc24214c1c0..7c88d49c7b9624ff85c381d2fee94a835b2af35d 100644 (file)
@@ -5098,14 +5098,6 @@ void RewriteObjC::RewriteByRefVar(VarDecl *ND) {
       startLoc = E->getLocStart();
     startLoc = SM->getInstantiationLoc(startLoc);
     endBuf = SM->getCharacterData(startLoc);
-    if (dyn_cast<CXXConstructExpr>(E)) {
-      // Hack alter!
-      // SemaInit sets startLoc to beginning of the initialized variable when
-      // rhs involvs copy construction initialization. Must compensate for this.
-      if (char *atEqual = strchr(endBuf, '='))
-        endBuf = atEqual + 1;
-    }
-    
     ByrefType += " " + Name;
     ByrefType += " = {(void*)";
     ByrefType += utostr(isa);
index 648780f30659af66117e0c3146ad1f7c4fda720e..0361f25913fb075678de9f3f4e8ac276b16197c9 100644 (file)
@@ -3803,7 +3803,8 @@ InitializationSequence::Perform(Sema &S,
       
       // Build a call to the selected constructor.
       ASTOwningVector<&ActionBase::DeleteExpr> ConstructorArgs(S);
-      SourceLocation Loc = Kind.getLocation();
+      SourceLocation Loc = Kind.isCopyInit() ? Kind.getEqualLoc()
+                           : Kind.getLocation();
           
       // Determine the arguments required to actually perform the constructor
       // call.
@@ -3819,11 +3820,11 @@ InitializationSequence::Perform(Sema &S,
         // An explicitly-constructed temporary, e.g., X(1, 2).
         unsigned NumExprs = ConstructorArgs.size();
         Expr **Exprs = (Expr **)ConstructorArgs.take();
-        S.MarkDeclarationReferenced(Kind.getLocation(), Constructor);
+        S.MarkDeclarationReferenced(Loc, Constructor);
         CurInit = S.Owned(new (S.Context) CXXTemporaryObjectExpr(S.Context,
                                                                  Constructor,
                                                               Entity.getType(),
-                                                            Kind.getLocation(),
+                                                                 Loc,
                                                                  Exprs, 
                                                                  NumExprs,
                                                 Kind.getParenRange().getEnd(),
index 4c94aa605812ca39a72d3f796346abc0854d4f4e..52481bb2564f14cbb207a5da40299ce82d36f0b0 100644 (file)
@@ -382,6 +382,8 @@ public:
     return Locations[1];
   }
   
+  bool isCopyInit() const { return Kind == SIK_Copy; }
+  
   /// \brief Retrieve the source range containing the locations of the open
   /// and closing parentheses for value and direct initializations.
   SourceRange getParenRange() const {