I'm in the process of updating my tinderboxes to run clang static analysis and 
upload the results.  Currently only yuffie (XQuartz) has data available, and 
I'll be updating my linux tinerboxes in the next few days once yuffie is going 
smoothly.  Hopefully cjb can integrate this a bit nicer into the 
tinderbox.x.org site, but for now, you can see it on my p.fd.o webspace:

http://people.freedesktop.org/~jeremyhu/analyzer/

I've started going through the list (some patches already sent to xorg-devel 
for font-util and iceauth), but help is always welcome.  There are some tests 
where"we know better".  For those, hopefully the _X_UNUSED and _X_NONNULL 
macros will help tag things appropriately.  For the other cases (rand() 
security concerns), we can use ifdef-foo to silence the analyzer:

#ifndef __clang_analyzer__
// Code not to be analyzed
#endif

The changes to jhbuild are minor (comments welcome before I send it off to 
gnome bugzilla).

Thanks,
Jeremy




>From 8784873bb86f92cab7d0341892f5db4343eb68a0 Mon Sep 17 00:00:00 2001
From: Jeremy Huddleston <jerem...@apple.com>
Date: Thu, 28 Apr 2011 00:55:13 -0700
Subject: [PATCH] Support running scan-build (Clang Static Analyzer) with
 autotools projects

http://clang-analyzer.llvm.org

Signed-off-by: Jeremy Huddleston <jerem...@apple.com>
---
 jhbuild/config.py             |    3 ++-
 jhbuild/defaults.jhbuildrc    |    6 ++++++
 jhbuild/modtypes/autotools.py |   12 +++++++++---
 3 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/jhbuild/config.py b/jhbuild/config.py
index f13e303..3e20436 100644
--- a/jhbuild/config.py
+++ b/jhbuild/config.py
@@ -58,7 +58,8 @@ _known_keys = [ 'moduleset', 'modules', 'skip', 'tags', 
'prefix',
                 'jhbuildbot_mastercfg', 'use_local_modulesets',
                 'ignore_suggests', 'modulesets_dir', 'mirror_policy',
                 'module_mirror_policy', 'dvcs_mirror_dir', 'build_targets',
-                'cmakeargs', 'module_cmakeargs' ]
+                'cmakeargs', 'module_cmakeargs',
+                'scan_build', 'module_scan_build', 'scan_buildargs', 
'scan_build_outputdir' ]
 
 env_prepends = {}
 def prependpath(envvar, path):
diff --git a/jhbuild/defaults.jhbuildrc b/jhbuild/defaults.jhbuildrc
index 7abe832..f9c34b7 100644
--- a/jhbuild/defaults.jhbuildrc
+++ b/jhbuild/defaults.jhbuildrc
@@ -89,6 +89,12 @@ interact      = True   # whether to interact with the user.
 quiet_mode    = False  # whether to display running commands output
 progress_bar  = True   # whether to display a progress bar when running in 
quiet mode
 
+# Run clang static analyzer (scan-build), scan_build_outputdir has 
subdirectories for each module id
+scan_build    = False
+module_scan_build = {}
+scan_buildargs = '-v'
+scan_build_outputdir = '/tmp/jhbuild_scan_build'
+
 # checkout modes. For VCS directories, it specifies how the checkout
 # is done. We can also specify checkout modes for specific modules
 checkout_mode = 'update'
diff --git a/jhbuild/modtypes/autotools.py b/jhbuild/modtypes/autotools.py
index 215df91..ff7a068 100644
--- a/jhbuild/modtypes/autotools.py
+++ b/jhbuild/modtypes/autotools.py
@@ -121,13 +121,14 @@ class AutogenModule(Package, DownloadableModule):
         if self.autogen_template:
             template = self.autogen_template
         else:
-            template = ("%(srcdir)s/%(autogen-sh)s --prefix %(prefix)s"
+            template = ("%(scan_build)s%(srcdir)s/%(autogen-sh)s --prefix 
%(prefix)s"
                         " --libdir %(libdir)s %(autogenargs)s ")
 
         autogenargs = self.autogenargs + ' ' + 
self.config.module_autogenargs.get(
                 self.name, self.config.autogenargs)
 
-        vars = {'prefix': buildscript.config.prefix,
+        vars = {'scan_build': self.scan_build_template(buildscript),
+                'prefix': buildscript.config.prefix,
                 'autogen-sh': self.autogen_sh,
                 'autogenargs': autogenargs}
                 
@@ -210,13 +211,18 @@ class AutogenModule(Package, DownloadableModule):
         buildscript.set_action(_('Building'), self)
         makeargs = self.makeargs + ' ' + self.config.module_makeargs.get(
                 self.name, self.config.makeargs)
-        cmd = '%s %s' % (os.environ.get('MAKE', 'make'), makeargs)
+        cmd = '%s%s %s' % (self.scan_build_template(buildscript), 
os.environ.get('MAKE', 'make'), makeargs)
         buildscript.execute(cmd, cwd = self.get_builddir(buildscript),
                 extra_env = self.extra_env)
     do_build.depends = [PHASE_CONFIGURE]
     do_build.error_phases = [PHASE_FORCE_CHECKOUT, PHASE_CONFIGURE,
             PHASE_CLEAN, PHASE_DISTCLEAN]
 
+    def scan_build_template(self, buildscript):
+        if self.name in buildscript.config.module_scan_build or 
buildscript.config.scan_build:
+            return 'scan-build %s -o %s/%s ' % 
(buildscript.config.scan_buildargs, buildscript.config.scan_build_outputdir, 
self.name)
+        return ''
+
     def skip_check(self, buildscript, last_phase):
         if not self.check_target:
             return True
-- 
1.7.4.4
_______________________________________________
xorg-devel@lists.x.org: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to