diff options
author | Roman Lebedev <lebedev.ri@gmail.com> | 2018-06-06 15:07:51 +0000 |
---|---|---|
committer | Roman Lebedev <lebedev.ri@gmail.com> | 2018-06-06 15:07:51 +0000 |
commit | 03b77a9a9cc1ca4c9d2187a0be18bf4e122bafec (patch) | |
tree | 465e96f7adb371fc23bee255f6383ed86cb692c1 /clang-tidy/ClangTidy.cpp | |
parent | 3c02061d3fe4036b52b24e6c736baa4cdf7e78b9 (diff) |
[clang-tidy] Store checks profiling info as JSON files
Summary:
Continuation of D46504.
Example output:
```
$ clang-tidy -enable-check-profile -store-check-profile=. -checks=-*,readability-function-size source.cpp
$ # Note that there won't be timings table printed to the console.
$ cat *.json
{
"file": "/path/to/source.cpp",
"timestamp": "2018-05-16 16:13:18.717446360",
"profile": {
"time.clang-tidy.readability-function-size.wall": 1.0421266555786133e+00,
"time.clang-tidy.readability-function-size.user": 9.2088400000005421e-01,
"time.clang-tidy.readability-function-size.sys": 1.2418899999999974e-01
}
}
```
There are two arguments that control profile storage:
* `-store-check-profile=<prefix>`
By default reports are printed in tabulated format to stderr. When this option
is passed, these per-TU profiles are instead stored as JSON.
If the prefix is not an absolute path, it is considered to be relative to the
directory from where you have run :program:`clang-tidy`. All `.` and `..`
patterns in the path are collapsed, and symlinks are resolved.
Example:
Let's suppose you have a source file named `example.cpp`, located in
`/source` directory.
* If you specify `-store-check-profile=/tmp`, then the profile will be saved
to `/tmp/<timestamp>-example.cpp.json`
* If you run :program:`clang-tidy` from within `/foo` directory, and specify
`-store-check-profile=.`, then the profile will still be saved to
`/foo/<timestamp>-example.cpp.json`
Reviewers: alexfh, sbenza, george.karpenkov, NoQ, aaron.ballman
Reviewed By: alexfh, george.karpenkov, aaron.ballman
Subscribers: Quuxplusone, JonasToth, aaron.ballman, llvm-commits, rja, Eugene.Zelenko, xazax.hun, mgrang, cfe-commits
Tags: #clang-tools-extra
Differential Revision: https://reviews.llvm.org/D46602
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@334101 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'clang-tidy/ClangTidy.cpp')
-rw-r--r-- | clang-tidy/ClangTidy.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/clang-tidy/ClangTidy.cpp b/clang-tidy/ClangTidy.cpp index ff205edd..f497fd74 100644 --- a/clang-tidy/ClangTidy.cpp +++ b/clang-tidy/ClangTidy.cpp @@ -363,7 +363,8 @@ ClangTidyASTConsumerFactory::CreateASTConsumer( std::unique_ptr<ClangTidyProfiling> Profiling; if (Context.getEnableProfiling()) { - Profiling = llvm::make_unique<ClangTidyProfiling>(); + Profiling = llvm::make_unique<ClangTidyProfiling>( + Context.getProfileStorageParams()); FinderOptions.CheckProfiling.emplace(Profiling->Records); } @@ -492,7 +493,7 @@ void runClangTidy(clang::tidy::ClangTidyContext &Context, const CompilationDatabase &Compilations, ArrayRef<std::string> InputFiles, llvm::IntrusiveRefCntPtr<vfs::FileSystem> BaseFS, - bool EnableCheckProfile) { + bool EnableCheckProfile, llvm::StringRef StoreCheckProfile) { ClangTool Tool(Compilations, InputFiles, std::make_shared<PCHContainerOperations>(), BaseFS); @@ -533,6 +534,7 @@ void runClangTidy(clang::tidy::ClangTidyContext &Context, Tool.appendArgumentsAdjuster(PerFileExtraArgumentsInserter); Tool.appendArgumentsAdjuster(PluginArgumentsRemover); Context.setEnableProfiling(EnableCheckProfile); + Context.setProfileStoragePrefix(StoreCheckProfile); ClangTidyDiagnosticConsumer DiagConsumer(Context); |