[cfe-commits] r167581 - in /cfe/trunk: lib/AST/Expr.cpp unittests/AST/SourceLocationTest.cpp
Abramo Bagnara
abramo.bagnara at bugseng.com
Thu Nov 8 05:52:58 PST 2012
Author: abramo
Date: Thu Nov 8 07:52:58 2012
New Revision: 167581
URL: http://llvm.org/viewvc/llvm-project?rev=167581&view=rev
Log:
Fixed range of implicit MemberExpr.
Modified:
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/unittests/AST/SourceLocationTest.cpp
Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=167581&r1=167580&r2=167581&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Thu Nov 8 07:52:58 2012
@@ -1327,9 +1327,12 @@
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 {
Modified: cfe/trunk/unittests/AST/SourceLocationTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/AST/SourceLocationTest.cpp?rev=167581&r1=167580&r2=167581&view=diff
==============================================================================
--- cfe/trunk/unittests/AST/SourceLocationTest.cpp (original)
+++ cfe/trunk/unittests/AST/SourceLocationTest.cpp Thu Nov 8 07:52:58 2012
@@ -254,5 +254,13 @@
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
More information about the cfe-commits
mailing list