summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/ExprCXX.cpp
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2010-10-25 08:47:36 +0000
committerChandler Carruth <chandlerc@gmail.com>2010-10-25 08:47:36 +0000
commit0171815ae193d08f56feade3273d9ae59ac3198a (patch)
tree8f4ed1f3ca055873595191fa56b179b820be3246 /clang/lib/AST/ExprCXX.cpp
parent01769904d3ddeb9ffb238a8387663b286624214c (diff)
downloadbcm5719-llvm-0171815ae193d08f56feade3273d9ae59ac3198a.tar.gz
bcm5719-llvm-0171815ae193d08f56feade3273d9ae59ac3198a.zip
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. llvm-svn: 117254
Diffstat (limited to 'clang/lib/AST/ExprCXX.cpp')
-rw-r--r--clang/lib/AST/ExprCXX.cpp42
1 files changed, 21 insertions, 21 deletions
diff --git a/clang/lib/AST/ExprCXX.cpp b/clang/lib/AST/ExprCXX.cpp
index 49e7f99e0de..0cdf8dd075d 100644
--- a/clang/lib/AST/ExprCXX.cpp
+++ b/clang/lib/AST/ExprCXX.cpp
@@ -113,14 +113,16 @@ CXXNewExpr::CXXNewExpr(ASTContext &C, bool globalNew, FunctionDecl *operatorNew,
Expr **constructorArgs, unsigned numConsArgs,
FunctionDecl *operatorDelete, QualType ty,
TypeSourceInfo *AllocatedTypeInfo,
- SourceLocation startLoc, SourceLocation endLoc)
+ SourceLocation startLoc, SourceLocation endLoc,
+ SourceLocation constructorLParen,
+ SourceLocation constructorRParen)
: Expr(CXXNewExprClass, ty, ty->isDependentType(), ty->isDependentType()),
GlobalNew(globalNew),
Initializer(initializer), SubExprs(0), OperatorNew(operatorNew),
OperatorDelete(operatorDelete), Constructor(constructor),
AllocatedTypeInfo(AllocatedTypeInfo), TypeIdParens(TypeIdParens),
- StartLoc(startLoc), EndLoc(endLoc) {
-
+ StartLoc(startLoc), EndLoc(endLoc), ConstructorLParen(constructorLParen),
+ ConstructorRParen(constructorRParen) {
AllocateArgsArray(C, arraySize != 0, numPlaceArgs, numConsArgs);
unsigned i = 0;
if (Array)
@@ -344,16 +346,10 @@ StmtIterator DependentScopeDeclRefExpr::child_end() {
return child_iterator();
}
-SourceRange CXXConstructExpr::getSourceRange() const {
- // FIXME: Should we know where the parentheses are, if there are any?
- for (std::reverse_iterator<Stmt**> I(&Args[NumArgs]), E(&Args[0]); I!=E;++I) {
- // Ignore CXXDefaultExprs when computing the range, as they don't
- // have a range.
- if (!isa<CXXDefaultArgExpr>(*I))
- return SourceRange(Loc, (*I)->getLocEnd());
- }
-
- return SourceRange(Loc);
+SourceRange CXXConstructExpr::getSourceRange() const {
+ return ParenRange.isValid() ?
+ SourceRange(Loc, ParenRange.getEnd()) :
+ SourceRange(Loc);
}
SourceRange CXXOperatorCallExpr::getSourceRange() const {
@@ -535,17 +531,19 @@ CXXTemporaryObjectExpr::CXXTemporaryObjectExpr(ASTContext &C,
TypeSourceInfo *Type,
Expr **Args,
unsigned NumArgs,
- SourceLocation rParenLoc,
+ SourceRange parenRange,
bool ZeroInitialization)
: CXXConstructExpr(C, CXXTemporaryObjectExprClass,
Type->getType().getNonReferenceType(),
Type->getTypeLoc().getBeginLoc(),
- Cons, false, Args, NumArgs, ZeroInitialization),
- RParenLoc(rParenLoc), Type(Type) {
+ Cons, false, Args, NumArgs, ZeroInitialization,
+ CXXConstructExpr::CK_Complete, parenRange),
+ Type(Type) {
}
SourceRange CXXTemporaryObjectExpr::getSourceRange() const {
- return SourceRange(Type->getTypeLoc().getBeginLoc(), RParenLoc);
+ return SourceRange(Type->getTypeLoc().getBeginLoc(),
+ getParenRange().getEnd());
}
CXXConstructExpr *CXXConstructExpr::Create(ASTContext &C, QualType T,
@@ -553,10 +551,11 @@ CXXConstructExpr *CXXConstructExpr::Create(ASTContext &C, QualType T,
CXXConstructorDecl *D, bool Elidable,
Expr **Args, unsigned NumArgs,
bool ZeroInitialization,
- ConstructionKind ConstructKind) {
+ ConstructionKind ConstructKind,
+ SourceRange ParenRange) {
return new (C) CXXConstructExpr(C, CXXConstructExprClass, T, Loc, D,
Elidable, Args, NumArgs, ZeroInitialization,
- ConstructKind);
+ ConstructKind, ParenRange);
}
CXXConstructExpr::CXXConstructExpr(ASTContext &C, StmtClass SC, QualType T,
@@ -564,12 +563,13 @@ CXXConstructExpr::CXXConstructExpr(ASTContext &C, StmtClass SC, QualType T,
CXXConstructorDecl *D, bool elidable,
Expr **args, unsigned numargs,
bool ZeroInitialization,
- ConstructionKind ConstructKind)
+ ConstructionKind ConstructKind,
+ SourceRange ParenRange)
: Expr(SC, T,
T->isDependentType(),
(T->isDependentType() ||
CallExpr::hasAnyValueDependentArguments(args, numargs))),
- Constructor(D), Loc(Loc), Elidable(elidable),
+ Constructor(D), Loc(Loc), ParenRange(ParenRange), Elidable(elidable),
ZeroInitialization(ZeroInitialization), ConstructKind(ConstructKind),
Args(0), NumArgs(numargs)
{
OpenPOWER on IntegriCloud