diff options
author | Samuel Benzaquen <sbenza@google.com> | 2014-10-22 20:31:05 +0000 |
---|---|---|
committer | Samuel Benzaquen <sbenza@google.com> | 2014-10-22 20:31:05 +0000 |
commit | 43dcf2172a01b2b7939427ace44d105ab0d0028f (patch) | |
tree | 36e6b35799de1dc3449f2ceee56b339d11a4b1d0 /clang/unittests/ASTMatchers/ASTMatchersTest.cpp | |
parent | 2633341b4ae11b6a46c38896553105022af5f990 (diff) | |
download | bcm5719-llvm-43dcf2172a01b2b7939427ace44d105ab0d0028f.tar.gz bcm5719-llvm-43dcf2172a01b2b7939427ace44d105ab0d0028f.zip |
Add support for profiling the matchers used.
Summary:
Add support for profiling the matchers used.
This will be connected with clang-tidy to generate a report to determine
and debug slow checks.
Reviewers: alexfh
Subscribers: klimek, cfe-commits
Differential Revision: http://reviews.llvm.org/D5911
llvm-svn: 220418
Diffstat (limited to 'clang/unittests/ASTMatchers/ASTMatchersTest.cpp')
-rw-r--r-- | clang/unittests/ASTMatchers/ASTMatchersTest.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp b/clang/unittests/ASTMatchers/ASTMatchersTest.cpp index d458431ecbb..b2c2a386e85 100644 --- a/clang/unittests/ASTMatchers/ASTMatchersTest.cpp +++ b/clang/unittests/ASTMatchers/ASTMatchersTest.cpp @@ -4421,6 +4421,25 @@ TEST(IsEqualTo, MatchesNodesByIdentity) { new VerifyAncestorHasChildIsEqual<IfStmt>())); } +TEST(MatchFinder, CheckProfiling) { + MatchFinder::MatchFinderOptions Options; + llvm::StringMap<llvm::TimeRecord> Records; + Options.CheckProfiling.emplace(Records); + MatchFinder Finder(std::move(Options)); + + struct NamedCallback : public MatchFinder::MatchCallback { + void run(const MatchFinder::MatchResult &Result) override {} + StringRef getID() const override { return "MyID"; } + } Callback; + Finder.addMatcher(decl(), &Callback); + std::unique_ptr<FrontendActionFactory> Factory( + newFrontendActionFactory(&Finder)); + ASSERT_TRUE(tooling::runToolOnCode(Factory->create(), "int x;")); + + EXPECT_EQ(1u, Records.size()); + EXPECT_EQ("MyID", Records.begin()->getKey()); +} + class VerifyStartOfTranslationUnit : public MatchFinder::MatchCallback { public: VerifyStartOfTranslationUnit() : Called(false) {} |