[PATCH] D52153: scan-build: Add support of the option --exclude like in scan-build-py

Phabricator via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Sep 16 23:34:51 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL342359: scan-build: Add support of the option --exclude like in scan-build-py (authored by sylvestre, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

https://reviews.llvm.org/D52153

Files:
  cfe/trunk/tools/scan-build/bin/scan-build


Index: cfe/trunk/tools/scan-build/bin/scan-build
===================================================================
--- cfe/trunk/tools/scan-build/bin/scan-build
+++ cfe/trunk/tools/scan-build/bin/scan-build
@@ -58,6 +58,7 @@
   KeepEmpty => 0,            # Don't remove output directory even with 0 results.
   EnableCheckers => {},
   DisableCheckers => {},
+  Excludes => [],
   UseCC => undef,            # C compiler to use for compilation.
   UseCXX => undef,           # C++ compiler to use for compilation.
   AnalyzerTarget => undef,
@@ -420,6 +421,20 @@
          # The file no longer exists: use the original path.
          $BugFile = $1;
       }
+
+      # Get just the path
+      my $p = dirname($BugFile);
+      # Check if the path is found in the list of exclude
+      if (grep { $p =~ m/$_/ } @{$Options{Excludes}}) {
+         if ($Options{Verbose}) {
+             Diag("File '$BugFile' deleted: part of an ignored directory.\n");
+         }
+
+       # File in an ignored directory. Remove it
+       unlink("$Dir/$FName");
+       return;
+      }
+
       UpdatePrefix($BugFile);
     }
     elsif (/<!-- BUGPATHLENGTH (.*) -->$/) {
@@ -1194,6 +1209,12 @@
    command. Specifying this option causes the exit status of scan-build to be 1
    if it found potential bugs and 0 otherwise.
 
+ --exclude <path>
+
+   Do not run static analyzer against files found in this
+   directory (You can specify this option multiple times).
+   Could be useful when project contains 3rd party libraries.
+
  --use-cc [compiler path]
  --use-cc=[compiler path]
 
@@ -1698,6 +1719,15 @@
       next;
     }
 
+    if ($arg eq "--exclude") {
+      shift @$Args;
+      my $arg = shift @$Args;
+      # Remove the trailing slash if any
+      $arg =~ s|/$||;
+      push @{$Options{Excludes}}, $arg;
+      next;
+    }
+
     if ($arg eq "-load-plugin") {
       shift @$Args;
       push @{$Options{PluginsToLoad}}, shift @$Args;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52153.165714.patch
Type: text/x-patch
Size: 1943 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180917/bcb8846c/attachment.bin>


More information about the cfe-commits mailing list