[PATCH] D101346: [AST] Fix getExprLoc reported for cxxDependentScopeMemberExpr

Stephen Kelly via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 27 14:56:54 PDT 2021


steveire updated this revision to Diff 340994.
steveire added a comment.

Fix windows build


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,36 @@
                              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::buildASTFromCodeWithArgs(
+      Example.code(), {"-fno-delayed-template-parsing"});
+  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.340994.patch
Type: text/x-patch
Size: 1603 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210427/83483f96/attachment.bin>


More information about the cfe-commits mailing list