Skip to content
Merged
Changes from 3 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
32 changes: 20 additions & 12 deletions clang/lib/Tooling/Tooling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ static bool ignoreExtraCC1Commands(const driver::Compilation *Compilation) {
OffloadCompilation = true;

if (Jobs.size() > 1) {
for (auto *A : Actions){
for (auto *A : Actions) {
// On MacOSX real actions may end up being wrapped in BindArchAction
if (isa<driver::BindArchAction>(A))
A = *A->input_begin();
Expand Down Expand Up @@ -413,8 +413,8 @@ bool ToolInvocation::run() {
Driver->BuildCompilation(llvm::ArrayRef(Argv)));
if (!Compilation)
return false;
const llvm::opt::ArgStringList *const CC1Args = getCC1Arguments(
&*Diagnostics, Compilation.get());
const llvm::opt::ArgStringList *const CC1Args =
getCC1Arguments(&*Diagnostics, Compilation.get());
if (!CC1Args)
return false;
std::unique_ptr<CompilerInvocation> Invocation(
Expand Down Expand Up @@ -497,9 +497,7 @@ void ClangTool::appendArgumentsAdjuster(ArgumentsAdjuster Adjuster) {
ArgsAdjuster = combineAdjusters(std::move(ArgsAdjuster), std::move(Adjuster));
}

void ClangTool::clearArgumentsAdjusters() {
ArgsAdjuster = nullptr;
}
void ClangTool::clearArgumentsAdjusters() { ArgsAdjuster = nullptr; }

static void injectResourceDir(CommandLineArguments &Args, const char *Argv0,
void *MainAddr) {
Expand Down Expand Up @@ -555,8 +553,9 @@ int ClangTool::run(ToolAction *Action) {
}

size_t NumOfTotalFiles = AbsolutePaths.size();
unsigned ProcessedFileCounter = 0;
unsigned CurrentFileIndex = 0;
for (llvm::StringRef File : AbsolutePaths) {
++CurrentFileIndex;
// Currently implementations of CompilationDatabase::getCompileCommands can
// change the state of the file system (e.g. prepare generated headers), so
// this method needs to run right before we invoke the tool, as the next
Expand All @@ -571,6 +570,7 @@ int ClangTool::run(ToolAction *Action) {
FileSkipped = true;
continue;
}
unsigned CurrentCommandIndexForFile = 0;
for (CompileCommand &CompileCommand : CompileCommandsForFile) {
// If the 'directory' field of the compilation database is empty, display
// an error and use the working directory instead.
Expand Down Expand Up @@ -617,13 +617,21 @@ int ClangTool::run(ToolAction *Action) {
// pass in made-up names here. Make sure this works on other platforms.
injectResourceDir(CommandLine, "clang_tool", &StaticSymbol);

++CurrentCommandIndexForFile;

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