From: Devin Coughlin Date: Wed, 11 Nov 2015 20:39:03 +0000 (+0000) Subject: [analyzer] Fix scan-build to handle missing output directories. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=58ac3983f94cf80e33c269e245e57132b76b629d;p=clang [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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@252797 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/tools/scan-build/scan-build b/tools/scan-build/scan-build index 65dc4fe1fa..be6056ccb9 100755 --- a/tools/scan-build/scan-build +++ b/tools/scan-build/scan-build @@ -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; }