Skip to content

Commit 923ff55

Browse files
authored
[Tooling] Print the progress when there are multiple files to process (#75904)
Running clang tools on a single file can be slow. It is even worse when running multiple files, to improve the user experience, we print the processing status.
1 parent 3fbef5b commit 923ff55

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

clang/lib/Tooling/Tooling.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,8 @@ int ClangTool::run(ToolAction *Action) {
554554
<< CWD.getError().message() << "\n";
555555
}
556556

557+
size_t NumOfTotalFiles = AbsolutePaths.size();
558+
unsigned ProcessedFileCounter = 0;
557559
for (llvm::StringRef File : AbsolutePaths) {
558560
// Currently implementations of CompilationDatabase::getCompileCommands can
559561
// change the state of the file system (e.g. prepare generated headers), so
@@ -609,7 +611,11 @@ int ClangTool::run(ToolAction *Action) {
609611

610612
// FIXME: We need a callback mechanism for the tool writer to output a
611613
// customized message for each file.
612-
LLVM_DEBUG({ llvm::dbgs() << "Processing: " << File << ".\n"; });
614+
if (NumOfTotalFiles > 1)
615+
llvm::errs() << "[" + std::to_string(++ProcessedFileCounter) + "/" +
616+
std::to_string(NumOfTotalFiles) +
617+
"] Processing file " + File
618+
<< ".\n";
613619
ToolInvocation Invocation(std::move(CommandLine), Action, Files.get(),
614620
PCHContainerOps);
615621
Invocation.setDiagnosticConsumer(DiagConsumer);

0 commit comments

Comments
 (0)