aboutsummaryrefslogtreecommitdiff
path: root/clang/unittests/AST/SourceLocationTest.cpp
diff options
context:
space:
mode:
authorMarcel Hlopko <hlopko@google.com>2020-03-13 10:47:37 +0100
committerDmitri Gribenko <gribozavr@gmail.com>2020-03-13 10:47:57 +0100
commitce79c4246919d777346dd3821c087faa1dcc725e (patch)
tree90a13165b9274882e4161a3e3047be5edb83d45c /clang/unittests/AST/SourceLocationTest.cpp
parentdb1f40d1a16f868a86501e30feadbfb285c2e922 (diff)
downloadllvm-ce79c4246919d777346dd3821c087faa1dcc725e.zip
llvm-ce79c4246919d777346dd3821c087faa1dcc725e.tar.gz
llvm-ce79c4246919d777346dd3821c087faa1dcc725e.tar.bz2
[Sema] Fix location of star ('*') inside MemberPointerTypeLoc
Summary: Copy of https://reviews.llvm.org/D72073?id=235842, submitting with ilya-biryukov's permission. Reviewers: gribozavr, gribozavr2 Reviewed By: gribozavr2 Subscribers: mgorny, gribozavr2, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D76061
Diffstat (limited to 'clang/unittests/AST/SourceLocationTest.cpp')
-rw-r--r--clang/unittests/AST/SourceLocationTest.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/clang/unittests/AST/SourceLocationTest.cpp b/clang/unittests/AST/SourceLocationTest.cpp
index d104497..f401f77 100644
--- a/clang/unittests/AST/SourceLocationTest.cpp
+++ b/clang/unittests/AST/SourceLocationTest.cpp
@@ -15,11 +15,12 @@
//
//===----------------------------------------------------------------------===//
-#include "clang/AST/ASTContext.h"
#include "MatchVerifier.h"
+#include "clang/AST/ASTContext.h"
#include "clang/ASTMatchers/ASTMatchFinder.h"
#include "clang/ASTMatchers/ASTMatchers.h"
#include "clang/Tooling/Tooling.h"
+#include "llvm/Testing/Support/Annotations.h"
#include "gtest/gtest.h"
namespace clang {
@@ -842,5 +843,23 @@ TEST(FunctionDecl, ExceptionSpecifications) {
Language::Lang_CXX11));
}
+TEST(Decl, MemberPointerStarLoc) {
+ llvm::Annotations Example(R"cpp(
+ struct X {};
+ int X::$star^* a;
+ )cpp");
+
+ auto AST = tooling::buildASTFromCode(Example.code());
+ SourceManager &SM = AST->getSourceManager();
+ auto &Ctx = AST->getASTContext();
+
+ auto *VD = selectFirst<VarDecl>("vd", match(varDecl().bind("vd"), Ctx));
+ ASSERT_TRUE(VD != nullptr);
+
+ auto TL =
+ VD->getTypeSourceInfo()->getTypeLoc().castAs<MemberPointerTypeLoc>();
+ ASSERT_EQ(SM.getFileOffset(TL.getStarLoc()), Example.point("star"));
+}
+
} // end namespace ast_matchers
} // end namespace clang