Skip to content

Commit 3a2cf86

Browse files
author
Eric Liu
committed
[Tooling] Returns non-zero status code when files are skipped.
Reviewers: hokein, bkramer Reviewed By: bkramer Subscribers: bkramer, klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D42361 llvm-svn: 324113
1 parent 1a745a4 commit 3a2cf86

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

clang/include/clang/Tooling/Tooling.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,9 @@ class ClangTool {
330330
/// Runs an action over all files specified in the command line.
331331
///
332332
/// \param Action Tool action.
333+
///
334+
/// \returns 0 on success; 1 if any error occured; 2 if there is no error but
335+
/// some files are skipped due to missing compile commands.
333336
int run(ToolAction *Action);
334337

335338
/// \brief Create an AST for each file specified in the command line and

clang/lib/Tooling/Tooling.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ int ClangTool::run(ToolAction *Action) {
388388
llvm::MemoryBuffer::getMemBuffer(MappedFile.second));
389389

390390
bool ProcessingFailed = false;
391+
bool FileSkipped = false;
391392
for (const auto &SourcePath : SourcePaths) {
392393
std::string File(getAbsolutePath(SourcePath));
393394

@@ -401,12 +402,8 @@ int ClangTool::run(ToolAction *Action) {
401402
std::vector<CompileCommand> CompileCommandsForFile =
402403
Compilations.getCompileCommands(File);
403404
if (CompileCommandsForFile.empty()) {
404-
// FIXME: There are two use cases here: doing a fuzzy
405-
// "find . -name '*.cc' |xargs tool" match, where as a user I don't care
406-
// about the .cc files that were not found, and the use case where I
407-
// specify all files I want to run over explicitly, where this should
408-
// be an error. We'll want to add an option for this.
409405
llvm::errs() << "Skipping " << File << ". Compile command not found.\n";
406+
FileSkipped = true;
410407
continue;
411408
}
412409
for (CompileCommand &CompileCommand : CompileCommandsForFile) {
@@ -466,7 +463,7 @@ int ClangTool::run(ToolAction *Action) {
466463
Twine(InitialDirectory) + "\n!");
467464
}
468465
}
469-
return ProcessingFailed ? 1 : 0;
466+
return ProcessingFailed ? 1 : (FileSkipped ? 2 : 0);
470467
}
471468

472469
namespace {

0 commit comments

Comments
 (0)