[PATCH] D101346: [AST] Fix getExprLoc reported for cxxDependentScopeMemberExpr
Stephen Kelly via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 27 02:20:56 PDT 2021
steveire updated this revision to Diff 340762.
steveire added a comment.
Update test
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D101346/new/
https://reviews.llvm.org/D101346
Files:
clang/include/clang/AST/ExprCXX.h
clang/unittests/AST/SourceLocationTest.cpp
Index: clang/unittests/AST/SourceLocationTest.cpp
===================================================================
--- clang/unittests/AST/SourceLocationTest.cpp
+++ clang/unittests/AST/SourceLocationTest.cpp
@@ -634,6 +634,35 @@
friendDecl()));
}
+TEST(CXXDependentScopeMemberExpr, ExprLocation) {
+
+ llvm::Annotations Example(R"cpp(
+template<typename T>
+struct MyContainer
+{
+ template <typename U>
+ void pushBack();
+};
+
+template<typename T>
+void testCall()
+{
+ MyContainer<T> mc;
+ mc.template $member_name^pushBack<int>();
+}
+ )cpp");
+
+ auto AST = tooling::buildASTFromCode(Example.code());
+ SourceManager &SM = AST->getSourceManager();
+ auto &Ctx = AST->getASTContext();
+
+ auto *M = selectFirst<CXXDependentScopeMemberExpr>(
+ "mem", match(cxxDependentScopeMemberExpr().bind("mem"), Ctx));
+ ASSERT_TRUE(M != nullptr);
+
+ ASSERT_EQ(SM.getFileOffset(M->getExprLoc()), Example.point("member_name"));
+}
+
TEST(FriendDecl, FriendTemplateClassRange) {
RangeVerifier<FriendDecl> Verifier;
Verifier.expectRange(2, 1, 3, 14);
Index: clang/include/clang/AST/ExprCXX.h
===================================================================
--- clang/include/clang/AST/ExprCXX.h
+++ clang/include/clang/AST/ExprCXX.h
@@ -3774,6 +3774,8 @@
return MemberNameInfo.getEndLoc();
}
+ SourceLocation getExprLoc() const LLVM_READONLY { return getMemberLoc(); }
+
static bool classof(const Stmt *T) {
return T->getStmtClass() == CXXDependentScopeMemberExprClass;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101346.340762.patch
Type: text/x-patch
Size: 1552 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210427/1bc3b810/attachment.bin>
More information about the cfe-commits
mailing list