aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaExpr.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-01-07 23:12:05 +0000
committerDouglas Gregor <dgregor@apple.com>2010-01-07 23:12:05 +0000
commit828a197317288e3333b0ce6f5cedadd036e3531f (patch)
tree11b4307b3f971868641db8a8d84e4a20c5111516 /lib/Sema/SemaExpr.cpp
parentf292fcf6bd5118499a830e0950429effeb373c28 (diff)
Add an "implicit" bit to CXXThisExpr, so that we can track
implicitness without losing track of the (logical or actual) location where "this" would occur in the source. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@92958 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExpr.cpp')
-rw-r--r--lib/Sema/SemaExpr.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 730375e5cd..216e2e6098 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -565,7 +565,8 @@ Sema::BuildAnonymousStructUnionMemberReference(SourceLocation Loc,
IsDerivedFrom(ThisType, AnonFieldType)) {
// Our base object expression is "this".
BaseObjectExpr = new (Context) CXXThisExpr(Loc,
- MD->getThisType(Context));
+ MD->getThisType(Context),
+ /*isImplicit=*/true);
BaseObjectIsPointer = true;
}
} else {
@@ -1366,7 +1367,10 @@ Sema::BuildImplicitMemberExpr(const CXXScopeSpec &SS,
QualType ThisType = cast<CXXMethodDecl>(CurContext)->getThisType(Context);
Expr *This = 0; // null signifies implicit access
if (IsKnownInstance) {
- This = new (Context) CXXThisExpr(SourceLocation(), ThisType);
+ SourceLocation Loc = R.getNameLoc();
+ if (SS.getRange().isValid())
+ Loc = SS.getRange().getBegin();
+ This = new (Context) CXXThisExpr(Loc, ThisType, /*isImplicit=*/true);
}
return BuildMemberReferenceExpr(ExprArg(*this, This), ThisType,
@@ -2541,7 +2545,10 @@ Sema::BuildMemberReferenceExpr(ExprArg Base, QualType BaseExprType,
if (!IsInstanceMember(MemberDecl))
return BuildDeclarationNameExpr(SS, R.getNameLoc(), MemberDecl);
- BaseExpr = new (Context) CXXThisExpr(SourceLocation(), BaseExprType);
+ SourceLocation Loc = R.getNameLoc();
+ if (SS.getRange().isValid())
+ Loc = SS.getRange().getBegin();
+ BaseExpr = new (Context) CXXThisExpr(Loc, BaseExprType,/*isImplicit=*/true);
}
bool ShouldCheckUse = true;