ccc: Add --analyze driver mode (for running static analyzer).
- For now forces generation of plist files, need to think about the
right interface.
- Changed -fsyntax-only mode to be its own phase (more consistent).
- Add -WA, for passing options verbatim to analyzer.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@62649 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/tools/ccc/ccclib/Tools.py b/tools/ccc/ccclib/Tools.py
index 2bb694c..11a6047 100644
--- a/tools/ccc/ccclib/Tools.py
+++ b/tools/ccc/ccclib/Tools.py
@@ -3,6 +3,7 @@
import Arguments
import Jobs
+import Phases
import Types
class Tool(object):
@@ -39,9 +40,10 @@
cmd_args.extend(arglist.render(arch))
if isinstance(output, Jobs.PipedJob):
cmd_args.extend(['-o', '-'])
- elif output is None:
+ elif isinstance(phase.phase, Phases.SyntaxOnlyPhase):
cmd_args.append('-fsyntax-only')
else:
+ assert output
cmd_args.extend(arglist.render(output))
if (isinstance(self, GCC_LinkTool) and
@@ -163,18 +165,22 @@
cmd_args))
class Clang_CompileTool(Tool):
- def __init__(self):
+ def __init__(self, toolChain):
super(Clang_CompileTool, self).__init__('clang',
(Tool.eFlagsPipedInput |
Tool.eFlagsPipedOutput |
Tool.eFlagsIntegratedCPP))
+ self.toolChain = toolChain
def constructJob(self, phase, arch, jobs, inputs,
output, outputType, arglist, linkingOutput):
cmd_args = []
patchOutputNameForPTH = False
- if output is None:
+
+ if isinstance(phase.phase, Phases.AnalyzePhase):
+ cmd_args.append('-analyze')
+ elif isinstance(phase.phase, Phases.SyntaxOnlyPhase):
cmd_args.append('-fsyntax-only')
elif outputType is Types.AsmTypeNoPP:
cmd_args.append('-S')
@@ -198,6 +204,22 @@
else:
raise ValueError,"Unexpected output type for clang tool."
+ if isinstance(phase.phase, Phases.AnalyzePhase):
+ # Add default argument set.
+ #
+ # FIXME: Move into clang?
+ cmd_args.extend(['-warn-dead-stores',
+ '-checker-cfref',
+ '-warn-objc-methodsigs',
+ '-warn-objc-missing-dealloc',
+ '-warn-objc-unused-ivars'])
+
+ cmd_args.append('-analyzer-output-plist')
+
+ # Add -WA, arguments when running as analyzer.
+ for arg in arglist.getArgs(arglist.parser.WAOption):
+ cmd_args.extend(arglist.renderAsInput(arg))
+
arglist.addAllArgs(cmd_args, arglist.parser.vOption)
arglist.addAllArgs2(cmd_args, arglist.parser.DOption, arglist.parser.UOption)
arglist.addAllArgs2(cmd_args, arglist.parser.IOption, arglist.parser.FOption)
@@ -252,7 +274,7 @@
suffix = '.pth'
cmd_args.append('-o')
cmd_args.append(base + suffix)
- else:
+ elif output:
cmd_args.extend(arglist.render(output))
for input in inputs: