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/Driver.py b/tools/ccc/ccclib/Driver.py
index 65b5316..de4596b 100644
--- a/tools/ccc/ccclib/Driver.py
+++ b/tools/ccc/ccclib/Driver.py
@@ -333,6 +333,7 @@
sys.exit(1)
def buildNormalPipeline(self, args):
+ hasAnalyze = args.getLastArg(self.parser.analyzeOption)
hasCombine = args.getLastArg(self.parser.combineOption)
hasSyntaxOnly = args.getLastArg(self.parser.syntaxOnlyOption)
hasDashC = args.getLastArg(self.parser.cOption)
@@ -406,6 +407,9 @@
if hasDashE or hasDashM or hasDashMM:
finalPhase = Phases.Phase.eOrderPreprocess
finalPhaseOpt = hasDashE
+ elif hasAnalyze:
+ finalPhase = Phases.Phase.eOrderCompile
+ finalPhaseOpt = hasAnalyze
elif hasSyntaxOnly:
finalPhase = Phases.Phase.eOrderCompile
finalPhaseOpt = hasSyntaxOnly
@@ -455,6 +459,10 @@
linkPhase])
elif klass.onlyPrecompile:
sequence.append(Phases.PrecompilePhase())
+ elif hasAnalyze:
+ sequence.append(Phases.AnalyzePhase())
+ elif hasSyntaxOnly:
+ sequence.append(Phases.SyntaxOnlyPhase())
else:
sequence.extend([Phases.CompilePhase(),
Phases.AssemblePhase(),
@@ -487,11 +495,18 @@
current = Phases.JobAction(transition,
[current],
Types.PCHType)
+ elif isinstance(transition, Phases.AnalyzePhase):
+ output = Types.PlistType
+ current = Phases.JobAction(transition,
+ [current],
+ output)
+ elif isinstance(transition, Phases.SyntaxOnlyPhase):
+ output = Types.NothingType
+ current = Phases.JobAction(transition,
+ [current],
+ output)
elif isinstance(transition, Phases.CompilePhase):
- if hasSyntaxOnly:
- output = Types.NothingType
- else:
- output = Types.AsmTypeNoPP
+ output = Types.AsmTypeNoPP
current = Phases.JobAction(transition,
[current],
output)