From: Abramo Bagnara Date: Thu, 8 Nov 2012 13:52:58 +0000 (+0000) Subject: Fixed range of implicit MemberExpr. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9b836fb019bb82970464f4e14b36a6e51dbdc7dd;p=platform%2Fupstream%2Fllvm.git Fixed range of implicit MemberExpr. llvm-svn: 167581 --- diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp index 61dd8bd..9dec1e8 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 7d6e0c3..c1651bc 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 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