diff options
| author | Fariborz Jahanian <fjahanian@apple.com> | 2010-07-21 18:31:47 +0000 | 
|---|---|---|
| committer | Fariborz Jahanian <fjahanian@apple.com> | 2010-07-21 18:31:47 +0000 | 
| commit | 3fd2a555d329a6d6c79918b5ce3ce32798bd8e3d (patch) | |
| tree | f20f0226977e10d6b7f870607517d69f3cefd1fc | |
| parent | 45595cf99f596b270024c0edf424a1c4ac401c0f (diff) | |
| download | bcm5719-llvm-3fd2a555d329a6d6c79918b5ce3ce32798bd8e3d.tar.gz bcm5719-llvm-3fd2a555d329a6d6c79918b5ce3ce32798bd8e3d.zip  | |
Fix source location of the initializer in 
a copy initialization. Back out hack in objc rewriter.
fixes radar 8213998.
llvm-svn: 109024
| -rw-r--r-- | clang/lib/Rewrite/RewriteObjC.cpp | 8 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaInit.cpp | 7 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaInit.h | 2 | 
3 files changed, 6 insertions, 11 deletions
diff --git a/clang/lib/Rewrite/RewriteObjC.cpp b/clang/lib/Rewrite/RewriteObjC.cpp index 2743a2bdc19..7c88d49c7b9 100644 --- a/clang/lib/Rewrite/RewriteObjC.cpp +++ b/clang/lib/Rewrite/RewriteObjC.cpp @@ -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); diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp index 648780f3065..0361f25913f 100644 --- a/clang/lib/Sema/SemaInit.cpp +++ b/clang/lib/Sema/SemaInit.cpp @@ -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(), diff --git a/clang/lib/Sema/SemaInit.h b/clang/lib/Sema/SemaInit.h index 4c94aa60581..52481bb2564 100644 --- a/clang/lib/Sema/SemaInit.h +++ b/clang/lib/Sema/SemaInit.h @@ -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 {  | 

