[PATCH] D42361: [Tooling] Returns non-zero status code when files are skipped.

Eric Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 22 01:06:04 PST 2018


ioeric created this revision.
ioeric added a reviewer: hokein.
Herald added subscribers: cfe-commits, klimek.

Repository:
  rC Clang

https://reviews.llvm.org/D42361

Files:
  include/clang/Tooling/Tooling.h
  lib/Tooling/Tooling.cpp


Index: lib/Tooling/Tooling.cpp
===================================================================
--- lib/Tooling/Tooling.cpp
+++ lib/Tooling/Tooling.cpp
@@ -387,6 +387,7 @@
             llvm::MemoryBuffer::getMemBuffer(MappedFile.second));
 
   bool ProcessingFailed = false;
+  bool FileSkipped = false;
   for (const auto &SourcePath : SourcePaths) {
     std::string File(getAbsolutePath(SourcePath));
 
@@ -406,6 +407,7 @@
       // specify all files I want to run over explicitly, where this should
       // be an error. We'll want to add an option for this.
       llvm::errs() << "Skipping " << File << ". Compile command not found.\n";
+      FileSkipped = true;
       continue;
     }
     for (CompileCommand &CompileCommand : CompileCommandsForFile) {
@@ -465,7 +467,7 @@
                                  Twine(InitialDirectory) + "\n!");
     }
   }
-  return ProcessingFailed ? 1 : 0;
+  return ProcessingFailed ? 1 : (FileSkipped ? 2 : 0);
 }
 
 namespace {
Index: include/clang/Tooling/Tooling.h
===================================================================
--- include/clang/Tooling/Tooling.h
+++ include/clang/Tooling/Tooling.h
@@ -326,6 +326,9 @@
   /// Runs an action over all files specified in the command line.
   ///
   /// \param Action Tool action.
+  ///
+  /// \returns 0 on success; 1 if any error occured; 2 if there is no error but
+  /// some files are skipped due to missing compile commands.
   int run(ToolAction *Action);
 
   /// \brief Create an AST for each file specified in the command line and


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42361.130840.patch
Type: text/x-patch
Size: 1546 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180122/9f71f0c4/attachment.bin>


More information about the cfe-commits mailing list