aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/CompilerInstance.cpp
diff options
context:
space:
mode:
authorVolodymyr Sapsai <vsapsai@apple.com>2023-02-27 19:35:44 -0800
committerVolodymyr Sapsai <vsapsai@apple.com>2023-03-16 11:57:59 -0700
commita845aeb5d6c869146fa24194a7d0182a4787cad8 (patch)
tree4d2815b0469ed6bf449eec9aac3f64ae852bb9cf /clang/lib/Frontend/CompilerInstance.cpp
parentc2a5c415ac4e31af0983418a403a4ce5bd749fd4 (diff)
downloadllvm-a845aeb5d6c869146fa24194a7d0182a4787cad8.zip
llvm-a845aeb5d6c869146fa24194a7d0182a4787cad8.tar.gz
llvm-a845aeb5d6c869146fa24194a7d0182a4787cad8.tar.bz2
[Driver] Allow to collect `-save-stats` data to a file specified in the environment variable.
Using two environment variables `CC_PRINT_INTERNAL_STAT` and `CC_PRINT_INTERNAL_STAT_FILE` to work like `CC_PRINT_PROC_STAT`. The purpose of the change is to allow collecting the internal stats without modifying the build scripts. Write all stats to a single file to simplify aggregating the data. Differential Revision: https://reviews.llvm.org/D144981
Diffstat (limited to 'clang/lib/Frontend/CompilerInstance.cpp')
-rw-r--r--clang/lib/Frontend/CompilerInstance.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/clang/lib/Frontend/CompilerInstance.cpp b/clang/lib/Frontend/CompilerInstance.cpp
index f3510b0..ecf9394 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -1087,9 +1087,12 @@ bool CompilerInstance::ExecuteAction(FrontendAction &Act) {
}
StringRef StatsFile = getFrontendOpts().StatsFile;
if (!StatsFile.empty()) {
+ llvm::sys::fs::OpenFlags FileFlags = llvm::sys::fs::OF_TextWithCRLF;
+ if (getFrontendOpts().AppendStats)
+ FileFlags |= llvm::sys::fs::OF_Append;
std::error_code EC;
- auto StatS = std::make_unique<llvm::raw_fd_ostream>(
- StatsFile, EC, llvm::sys::fs::OF_TextWithCRLF);
+ auto StatS =
+ std::make_unique<llvm::raw_fd_ostream>(StatsFile, EC, FileFlags);
if (EC) {
getDiagnostics().Report(diag::warn_fe_unable_to_open_stats_file)
<< StatsFile << EC.message();