summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAbramo Bagnara <abramo.bagnara@bugseng.com>2012-11-08 13:52:58 +0000
committerAbramo Bagnara <abramo.bagnara@bugseng.com>2012-11-08 13:52:58 +0000
commit9b836fb019bb82970464f4e14b36a6e51dbdc7dd (patch)
tree061235c16af98d9a77f8b5f55672b539d6d0d024
parent26216e4ae31a4f64a232355600bb35f065074360 (diff)
downloadbcm5719-llvm-9b836fb019bb82970464f4e14b36a6e51dbdc7dd.tar.gz
bcm5719-llvm-9b836fb019bb82970464f4e14b36a6e51dbdc7dd.zip
Fixed range of implicit MemberExpr.
llvm-svn: 167581
-rw-r--r--clang/lib/AST/Expr.cpp7
-rw-r--r--clang/unittests/AST/SourceLocationTest.cpp8
2 files changed, 13 insertions, 2 deletions
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index 61dd8bd5a6f..9dec1e8131d 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -1327,9 +1327,12 @@ SourceLocation MemberExpr::getLocStart() const {
return MemberLoc;
}
SourceLocation MemberExpr::getLocEnd() const {
+ SourceLocation EndLoc = getMemberNameInfo().getEndLoc();
if (hasExplicitTemplateArgs())
- return getRAngleLoc();
- return getMemberNameInfo().getEndLoc();
+ EndLoc = getRAngleLoc();
+ else if (EndLoc.isInvalid())
+ EndLoc = getBase()->getLocEnd();
+ return EndLoc;
}
void CastExpr::CheckCastConsistency() const {
diff --git a/clang/unittests/AST/SourceLocationTest.cpp b/clang/unittests/AST/SourceLocationTest.cpp
index 7d6e0c3dade..c1651bc586f 100644
--- a/clang/unittests/AST/SourceLocationTest.cpp
+++ b/clang/unittests/AST/SourceLocationTest.cpp
@@ -254,5 +254,13 @@ TEST(CXXNewExpr, ArrayRange) {
EXPECT_TRUE(Verifier.match("void f() { new int[10]; }", newExpr()));
}
+TEST(MemberExpr, ImplicitMemberRange) {
+ RangeVerifier<MemberExpr> Verifier;
+ Verifier.expectRange(2, 30, 2, 30);
+ EXPECT_TRUE(Verifier.match("struct S { operator int() const; };\n"
+ "int foo(const S& s) { return s; }",
+ memberExpr()));
+}
+
} // end namespace ast_matchers
} // end namespace clang
OpenPOWER on IntegriCloud