diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2010-10-25 08:47:36 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2010-10-25 08:47:36 +0000 |
commit | 428edafa9eb80e01dd40aab31d4166a787a741e1 (patch) | |
tree | 618b88a0399873548adeeeb442cb87be3426862d /lib/Sema/SemaInit.cpp | |
parent | 8c5e5d6d8a316af5a9842169f541cac49717887d (diff) |
Improve the tracking of source locations for parentheses in constructor calls.
This adds them where missing, and traces them through PCH. We fix at least one
bug in the extents found by the Index library, and make a lot of refactoring
tools which care about the exact formulation of a constructor call easier to
write. Also some minor cleanups to more consistently follow the friend pattern
instead of the setter pattern when rebuilding a serialized AST.
Patch originally by Samuel Benzaquen.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@117254 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaInit.cpp')
-rw-r--r-- | lib/Sema/SemaInit.cpp | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp index 1e48930f97..fb482bf56a 100644 --- a/lib/Sema/SemaInit.cpp +++ b/lib/Sema/SemaInit.cpp @@ -3444,7 +3444,8 @@ static ExprResult CopyObject(Sema &S, CurInit = S.BuildCXXConstructExpr(Loc, T, Constructor, Elidable, move_arg(ConstructorArgs), /*ZeroInit*/ false, - CXXConstructExpr::CK_Complete); + CXXConstructExpr::CK_Complete, + SourceRange()); // If we're supposed to bind temporaries, do so. if (!CurInit.isInvalid() && shouldBindAsTemporary(Entity)) @@ -3707,7 +3708,8 @@ InitializationSequence::Perform(Sema &S, CurInit = S.BuildCXXConstructExpr(Loc, Step->Type, Constructor, move_arg(ConstructorArgs), /*ZeroInit*/ false, - CXXConstructExpr::CK_Complete); + CXXConstructExpr::CK_Complete, + SourceRange()); if (CurInit.isInvalid()) return ExprError(); @@ -3870,7 +3872,7 @@ InitializationSequence::Perform(Sema &S, TSInfo, Exprs, NumExprs, - Kind.getParenRange().getEnd(), + Kind.getParenRange(), ConstructorInitRequiresZeroInit)); } else { CXXConstructExpr::ConstructionKind ConstructKind = @@ -3882,6 +3884,11 @@ InitializationSequence::Perform(Sema &S, CXXConstructExpr::CK_NonVirtualBase; } + // Only get the parenthesis range if it is a direct construction. + SourceRange parenRange = + Kind.getKind() == InitializationKind::IK_Direct ? + Kind.getParenRange() : SourceRange(); + // If the entity allows NRVO, mark the construction as elidable // unconditionally. if (Entity.allowsNRVO()) @@ -3889,13 +3896,15 @@ InitializationSequence::Perform(Sema &S, Constructor, /*Elidable=*/true, move_arg(ConstructorArgs), ConstructorInitRequiresZeroInit, - ConstructKind); + ConstructKind, + parenRange); else CurInit = S.BuildCXXConstructExpr(Loc, Entity.getType(), Constructor, move_arg(ConstructorArgs), ConstructorInitRequiresZeroInit, - ConstructKind); + ConstructKind, + parenRange); } if (CurInit.isInvalid()) return ExprError(); |