summaryrefslogtreecommitdiffstats
path: root/clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp
diff options
context:
space:
mode:
authorSamuel Benzaquen <sbenza@google.com>2014-10-01 15:08:07 +0000
committerSamuel Benzaquen <sbenza@google.com>2014-10-01 15:08:07 +0000
commitf28d997083c5387220e41ca28cff12f6ae479357 (patch)
tree654c2c81ee9d3144aad15f8586505d047fde5f0e /clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp
parentc4c202a9a750912a76c9cb7cea2114426672071e (diff)
downloadbcm5719-llvm-f28d997083c5387220e41ca28cff12f6ae479357.tar.gz
bcm5719-llvm-f28d997083c5387220e41ca28cff12f6ae479357.zip
Refactor Matcher<T> and DynTypedMatcher to reduce overhead of casts.
Summary: This change introduces DynMatcherInterface and changes the internal representation of DynTypedMatcher and Matcher<T> to use a generic interface instead. It removes unnecessary indirections and virtual function calls when converting matchers by implicit and dynamic casts. DynTypedMatcher now remembers the stricter type in the chain of casts and checks it before calling into DynMatcherInterface. This change improves our clang-tidy related benchmark by ~14%. Also, it opens the door for more optimizations of this kind that are coming in future changes. As a side effect of removing these template instantiations, it also speeds up compilation of Dynamic/Registry.cpp by ~17% and reduces the number of symbols generated by ~30%. Reviewers: klimek Subscribers: klimek, cfe-commits Differential Revision: http://reviews.llvm.org/D5542 llvm-svn: 218769
Diffstat (limited to 'clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp')
-rw-r--r--clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp b/clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp
index 860db7ef46a..ed507d57333 100644
--- a/clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp
+++ b/clang/unittests/ASTMatchers/Dynamic/ParserTest.cpp
@@ -28,7 +28,7 @@ public:
uint64_t expectMatcher(StringRef MatcherName) {
ast_matchers::internal::Matcher<Stmt> M = stmt();
ExpectedMatchers.insert(std::make_pair(MatcherName, M));
- return M.getID();
+ return M.getID().second;
}
void parse(StringRef Code) {
@@ -125,8 +125,12 @@ TEST(ParserTest, ParseMatcher) {
EXPECT_EQ("", Sema.Errors[i]);
}
+ EXPECT_NE(ExpectedFoo, ExpectedBar);
+ EXPECT_NE(ExpectedFoo, ExpectedBaz);
+ EXPECT_NE(ExpectedBar, ExpectedBaz);
+
EXPECT_EQ(1ULL, Sema.Values.size());
- EXPECT_EQ(ExpectedFoo, getSingleMatcher(Sema.Values[0])->getID());
+ EXPECT_EQ(ExpectedFoo, getSingleMatcher(Sema.Values[0])->getID().second);
EXPECT_EQ(3ULL, Sema.Matchers.size());
const MockSema::MatcherInfo Bar = Sema.Matchers[0];
@@ -145,8 +149,8 @@ TEST(ParserTest, ParseMatcher) {
EXPECT_EQ("Foo", Foo.MatcherName);
EXPECT_TRUE(matchesRange(Foo.NameRange, 1, 2, 2, 12));
EXPECT_EQ(2ULL, Foo.Args.size());
- EXPECT_EQ(ExpectedBar, getSingleMatcher(Foo.Args[0].Value)->getID());
- EXPECT_EQ(ExpectedBaz, getSingleMatcher(Foo.Args[1].Value)->getID());
+ EXPECT_EQ(ExpectedBar, getSingleMatcher(Foo.Args[0].Value)->getID().second);
+ EXPECT_EQ(ExpectedBaz, getSingleMatcher(Foo.Args[1].Value)->getID().second);
EXPECT_EQ("Yo!", Foo.BoundID);
}
OpenPOWER on IntegriCloud