r186138 - [scan-build] Pass through all -f and -O flags, along with -Wwrite-strings.

Jordan Rose jordan_rose at apple.com
Thu Jul 11 16:56:12 PDT 2013


Author: jrose
Date: Thu Jul 11 18:56:12 2013
New Revision: 186138

URL: http://llvm.org/viewvc/llvm-project?rev=186138&view=rev
Log:
[scan-build] Pass through all -f and -O flags, along with -Wwrite-strings.

These flags control language options and user-visible macros, so it's
important to preserve them when analyzing. Rather than try to keep up
with all the -f flags, we'll pass them all through and then ban the ones
we don't want (like -fsyntax-only).

-Wwrite-strings is really an f-flag in disguise: it implies -fconst-strings.

Patch by Keaton Mowry, modified by me.

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

Modified: cfe/trunk/tools/scan-build/ccc-analyzer
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/scan-build/ccc-analyzer?rev=186138&r1=186137&r2=186138&view=diff
==============================================================================
--- cfe/trunk/tools/scan-build/ccc-analyzer (original)
+++ cfe/trunk/tools/scan-build/ccc-analyzer Thu Jul 11 18:56:12 2013
@@ -325,11 +325,6 @@ sub Analyze {
 
 my %CompileOptionMap = (
   '-nostdinc' => 0,
-  '-fblocks' => 0,
-  '-fno-builtin' => 0,
-  '-fobjc-gc-only' => 0,
-  '-fobjc-gc' => 0,
-  '-ffreestanding' => 0,
   '-include' => 1,
   '-idirafter' => 1,
   '-imacros' => 1,
@@ -346,10 +341,8 @@ my %LinkerOptionMap = (
 );
 
 my %CompilerLinkerOptionMap = (
-  '-fobjc-arc' => 0,
-  '-fno-objc-arc' => 0,
-  '-fobjc-abi-version' => 0, # This is really a 1 argument, but always has '='
-  '-fobjc-legacy-dispatch' => 0,
+  '-Wwrite-strings' => 0
+  '-ftrapv-handler' => 1, # specifically call out separated -f flag
   '-mios-simulator-version-min' => 0, # This really has 1 argument, but always has '='
   '-isysroot' => 1,
   '-arch' => 1,
@@ -357,7 +350,6 @@ my %CompilerLinkerOptionMap = (
   '-m64' => 0,
   '-stdlib' => 0, # This is really a 1 argument, but always has '='
   '-v' => 0,
-  '-fpascal-strings' => 0,
   '-mmacosx-version-min' => 0, # This is really a 1 argument, but always has '='
   '-miphoneos-version-min' => 0 # This is really a 1 argument, but always has '='
 );
@@ -574,6 +566,9 @@ foreach (my $i = 0; $i < scalar(@ARGV);
     if ($Arg eq '-O') { push @LinkOpts,'-O1'; }
     elsif ($Arg eq '-Os') { push @LinkOpts,'-O2'; }
     else { push @LinkOpts,$Arg; }
+
+    # Must pass this along for the __OPTIMIZE__ macro
+    if ($Arg =~ /^-O/) { push @CompileOpts,$Arg; }
     next;
   }
   
@@ -582,12 +577,6 @@ foreach (my $i = 0; $i < scalar(@ARGV);
     next;
   }
   
-#  if ($Arg =~ /^-f/) {
-#    # FIXME: Not sure if the remaining -fxxxx options have no arguments.
-#    push @CompileOpts,$Arg;
-#    push @LinkOpts,$Arg;  # FIXME: Not sure if these are link opts.
-#  }
-  
   # Get the compiler/link mode.
   if ($Arg =~ /^-F(.+)$/) {
     my $Tmp = $Arg;
@@ -611,6 +600,12 @@ foreach (my $i = 0; $i < scalar(@ARGV);
     next;
   }
   
+  if ($Arg =~ /^-f/) {
+    push @CompileOpts,$Arg;
+    push @LinkOpts,$Arg;
+    next;
+  }
+  
   # Handle -Wno-.  We don't care about extra warnings, but
   # we should suppress ones that we don't want to see.
   if ($Arg =~ /^-Wno-/) {





More information about the cfe-commits mailing list