Skip to content

[Tooling] Print the progress when there are multiple files to process #75904

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion clang/lib/Tooling/Tooling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,8 @@ int ClangTool::run(ToolAction *Action) {
<< CWD.getError().message() << "\n";
}

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

// FIXME: We need a callback mechanism for the tool writer to output a
// customized message for each file.
LLVM_DEBUG({ llvm::dbgs() << "Processing: " << File << ".\n"; });
if (NumOfTotalFiles > 1)
llvm::errs() << "[" + std::to_string(++ProcessedFileCounter) + "/" +
std::to_string(NumOfTotalFiles) +
"] Processing file " + File
<< ".\n";
ToolInvocation Invocation(std::move(CommandLine), Action, Files.get(),
PCHContainerOps);
Invocation.setDiagnosticConsumer(DiagConsumer);
Expand Down