r252797 - [analyzer] Fix scan-build to handle missing output directories.

Devin Coughlin via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 11 12:39:03 PST 2015


Author: dcoughlin
Date: Wed Nov 11 14:39:03 2015
New Revision: 252797

URL: http://llvm.org/viewvc/llvm-project?rev=252797&view=rev
Log:
[analyzer] Fix scan-build to handle missing output directories.

Cwd::abs_path has a somewhat tricky semantics: if it's operand directory does not exist,
it'll return undefined (see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=257568).
This may cause scan-build to silently ignore output directory (specified with -o) and
use /tmp instead of trying to create directory. This tiny patch fixes the problem.

A patch by Yury Gribov!

Differential Revision: http://reviews.llvm.org/D14535

Modified:
    cfe/trunk/tools/scan-build/scan-build

Modified: cfe/trunk/tools/scan-build/scan-build
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-build/scan-build?rev=252797&r1=252796&r2=252797&view=diff
==============================================================================
--- cfe/trunk/tools/scan-build/scan-build (original)
+++ cfe/trunk/tools/scan-build/scan-build Wed Nov 11 14:39:03 2015
@@ -1478,7 +1478,9 @@ sub ProcessArgs {
 
       # Construct an absolute path.  Uses the current working directory
       # as a base if the original path was not absolute.
-      $Options{OutputDir} = abs_path(shift @$Args);
+      my $OutDir = shift @$Args;
+      mkpath($OutDir) unless (-e $OutDir);  # abs_path wants existing dir
+      $Options{OutputDir} = abs_path($OutDir);
 
       next;
     }




More information about the cfe-commits mailing list