[cfe-commits] r89629 - in /cfe/trunk: include/clang/Driver/CC1Options.td lib/Driver/CC1Options.cpp lib/Frontend/CompilerInvocation.cpp tools/clang-cc/Options.cpp
Daniel Dunbar
daniel at zuster.org
Sun Nov 22 14:08:20 PST 2009
Author: ddunbar
Date: Sun Nov 22 16:08:20 2009
New Revision: 89629
URL: http://llvm.org/viewvc/llvm-project?rev=89629&view=rev
Log:
Add clang -cc1 parsing of analyzer options.
Modified:
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/lib/Driver/CC1Options.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/tools/clang-cc/Options.cpp
Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=89629&r1=89628&r2=89629&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Sun Nov 22 16:08:20 2009
@@ -25,6 +25,70 @@
def triple : Separate<"-triple">,
HelpText<"Specify target triple (e.g. i686-apple-darwin9)">;
+// Analyzer Options
+
+def analysis_CFGDump : Flag<"-cfg-dump">,
+ HelpText<"Display Control-Flow Graphs">;
+def analysis_CFGView : Flag<"-cfg-view">,
+ HelpText<"View Control-Flow Graphs using GraphViz">;
+def analysis_DisplayLiveVariables : Flag<"-dump-live-variables">,
+ HelpText<"Print results of live variable analysis">;
+def analysis_SecuritySyntacticChecks : Flag<"-warn-security-syntactic">,
+ HelpText<"Perform quick security checks that require no data flow">;
+def analysis_WarnDeadStores : Flag<"-warn-dead-stores">,
+ HelpText<"Warn about stores to dead variables">;
+def analysis_WarnUninitVals : Flag<"-warn-uninit-values">,
+ HelpText<"Warn about uses of uninitialized variables">;
+def analysis_WarnObjCMethSigs : Flag<"-warn-objc-methodsigs">,
+ HelpText<"Warn about Objective-C method signatures with type incompatibilities">;
+def analysis_WarnObjCDealloc : Flag<"-warn-objc-missing-dealloc">,
+ HelpText<"Warn about Objective-C classes that lack a correct implementation of -dealloc">;
+def analysis_WarnObjCUnusedIvars : Flag<"-warn-objc-unused-ivars">,
+ HelpText<"Warn about private ivars that are never used">;
+def analysis_CheckerCFRef : Flag<"-checker-cfref">,
+ HelpText<"Run the [Core] Foundation reference count checker">;
+def analysis_WarnSizeofPointer : Flag<"-warn-sizeof-pointer">,
+ HelpText<"Warn about unintended use of sizeof() on pointer expressions">;
+def analysis_InlineCall : Flag<"-inline-call">,
+ HelpText<"Experimental transfer function inling callees when its definition is available.">;
+
+def analyzer_store : Separate<"-analyzer-store">,
+ HelpText<"Source Code Analysis - Abstract Memory Store Models">;
+def analyzer_store_EQ : Joined<"-analyzer-store=">, Alias<analyzer_store>;
+
+def analyzer_constraints : Separate<"-analyzer-constraints">,
+ HelpText<"Source Code Analysis - Symbolic Constraint Engines">;
+def analyzer_constraints_EQ : Joined<"-analyzer-constraints=">,
+ Alias<analyzer_constraints>;
+
+def analyzer_output : Separate<"-analyzer-output">,
+ HelpText<"Source Code Analysis - Output Options">;
+def analyzer_output_EQ : Joined<"-analyzer-output=">,
+ Alias<analyzer_output>;
+
+def analyzer_opt_analyze_headers : Flag<"-analyzer-opt-analyze-headers">,
+ HelpText<"Force the static analyzer to analyze functions defined in header files">;
+def analyzer_display_progress : Flag<"-analyzer-display-progress">,
+ HelpText<"Emit verbose output about the analyzer's progress">;
+def analyzer_experimental_checks : Flag<"-analyzer-experimental-checks">,
+ HelpText<"Use experimental path-sensitive checks">;
+def analyzer_experimental_internal_checks :
+ Flag<"-analyzer-experimental-internal-checks">,
+ HelpText<"Use new default path-sensitive checks currently in testing">;
+def analyze_function : Separate<"-analyze-function">,
+ HelpText<"Run analysis on specific function">;
+def analyze_function_EQ : Joined<"-analyze-function=">, Alias<analyze_function>;
+def analyzer_eagerly_assume : Flag<"-analyzer-eagerly-assume">,
+ HelpText<"Eagerly assume the truth/falseness of some symbolic constraints">;
+def analyzer_no_purge_dead : Flag<"-analyzer-no-purge-dead">,
+ HelpText<"Don't remove dead symbols, bindings, and constraints before processing a statement">;
+def trim_egraph : Flag<"-trim-egraph">,
+ HelpText<"Only show error-related paths in the analysis graph">;
+def analyzer_viz_egraph_graphviz : Flag<"-analyzer-viz-egraph-graphviz">,
+ HelpText<"Display exploded graph using GraphViz">;
+def analyzer_viz_egraph_ubigraph : Flag<"-analyzer-viz-egraph-ubigraph">,
+ HelpText<"Display exploded graph using Ubigraph">;
+
// CodeGen Options
def disable_llvm_optzns : Flag<"-disable-llvm-optzns">,
Modified: cfe/trunk/lib/Driver/CC1Options.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/CC1Options.cpp?rev=89629&r1=89628&r2=89629&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/CC1Options.cpp (original)
+++ cfe/trunk/lib/Driver/CC1Options.cpp Sun Nov 22 16:08:20 2009
@@ -14,6 +14,7 @@
#include "clang/Driver/Option.h"
#include "clang/Frontend/CompilerInvocation.h"
#include "llvm/ADT/OwningPtr.h"
+#include "llvm/ADT/StringSwitch.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/System/Host.h"
@@ -79,6 +80,73 @@
//
+static void ParseAnalyzerArgs(AnalyzerOptions &Opts, ArgList &Args) {
+ Opts.AnalysisList.clear();
+#define ANALYSIS(NAME, CMDFLAG, DESC, SCOPE) \
+ if (Args.hasArg(cc1options::OPT_analysis_##NAME)) \
+ Opts.AnalysisList.push_back(NAME);
+#include "clang/Frontend/Analyses.def"
+
+ if (Arg *A = Args.getLastArg(cc1options::OPT_analyzer_store)) {
+ llvm::StringRef Name = A->getValue(Args);
+ AnalysisStores Value = llvm::StringSwitch<AnalysisStores>(Name)
+#define ANALYSIS_STORE(NAME, CMDFLAG, DESC, CREATFN) \
+ .Case(CMDFLAG, NAME##Model)
+#include "clang/Frontend/Analyses.def"
+ .Default(NumStores);
+ // FIXME: Error handling.
+ if (Value == NumStores)
+ llvm::errs() << "error: invalid analysis store '" << Name << "'\n";
+ else
+ Opts.AnalysisStoreOpt = Value;
+ }
+
+ if (Arg *A = Args.getLastArg(cc1options::OPT_analyzer_constraints)) {
+ llvm::StringRef Name = A->getValue(Args);
+ AnalysisConstraints Value = llvm::StringSwitch<AnalysisConstraints>(Name)
+#define ANALYSIS_CONSTRAINTS(NAME, CMDFLAG, DESC, CREATFN) \
+ .Case(CMDFLAG, NAME##Model)
+#include "clang/Frontend/Analyses.def"
+ .Default(NumConstraints);
+ // FIXME: Error handling.
+ if (Value == NumConstraints)
+ llvm::errs() << "error: invalid analysis constraints '" << Name << "'\n";
+ else
+ Opts.AnalysisConstraintsOpt = Value;
+ }
+
+ if (Arg *A = Args.getLastArg(cc1options::OPT_analyzer_output)) {
+ llvm::StringRef Name = A->getValue(Args);
+ AnalysisDiagClients Value = llvm::StringSwitch<AnalysisDiagClients>(Name)
+#define ANALYSIS_DIAGNOSTICS(NAME, CMDFLAG, DESC, CREATFN, AUTOCREAT) \
+ .Case(CMDFLAG, PD_##NAME)
+#include "clang/Frontend/Analyses.def"
+ .Default(NUM_ANALYSIS_DIAG_CLIENTS);
+ // FIXME: Error handling.
+ if (Value == NUM_ANALYSIS_DIAG_CLIENTS)
+ llvm::errs() << "error: invalid analysis output '" << Name << "'\n";
+ else
+ Opts.AnalysisDiagOpt = Value;
+ }
+
+ Opts.VisualizeEGDot =
+ Args.hasArg(cc1options::OPT_analyzer_viz_egraph_graphviz);
+ Opts.VisualizeEGUbi =
+ Args.hasArg(cc1options::OPT_analyzer_viz_egraph_ubigraph);
+ Opts.AnalyzeAll = Args.hasArg(cc1options::OPT_analyzer_opt_analyze_headers);
+ Opts.AnalyzerDisplayProgress =
+ Args.hasArg(cc1options::OPT_analyzer_display_progress);
+ Opts.PurgeDead = !Args.hasArg(cc1options::OPT_analyzer_no_purge_dead);
+ Opts.EagerlyAssume = Args.hasArg(cc1options::OPT_analyzer_eagerly_assume);
+ Opts.AnalyzeSpecificFunction =
+ getLastArgValue(Args, cc1options::OPT_analyze_function);
+ Opts.EnableExperimentalChecks =
+ Args.hasArg(cc1options::OPT_analyzer_experimental_checks);
+ Opts.EnableExperimentalInternalChecks =
+ Args.hasArg(cc1options::OPT_analyzer_experimental_internal_checks);
+ Opts.TrimGraph = Args.hasArg(cc1options::OPT_trim_egraph);
+}
+
static void ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args) {
// -Os implies -O2
if (Args.hasArg(cc1options::OPT_Os))
@@ -160,6 +228,7 @@
<< " value )\n";
}
+ ParseAnalyzerArgs(Res.getAnalyzerOpts(), *InputArgs);
ParseCodeGenArgs(Res.getCodeGenOpts(), *InputArgs);
ParseDependencyOutputArgs(Res.getDependencyOutputOpts(), *InputArgs);
ParseTargetArgs(Res.getTargetOpts(), *InputArgs);
Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=89629&r1=89628&r2=89629&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Sun Nov 22 16:08:20 2009
@@ -17,7 +17,7 @@
default:
llvm::llvm_unreachable("Unknown analysis store!");
#define ANALYSIS(NAME, CMDFLAG, DESC, SCOPE)\
- case NAME: return CMDFLAG;
+ case NAME: return "-" CMDFLAG;
#include "clang/Frontend/Analyses.def"
}
}
@@ -89,7 +89,7 @@
if (Opts.EnableExperimentalChecks)
Res.push_back("-analyzer-experimental-checks");
if (Opts.EnableExperimentalInternalChecks)
- Res.push_back("-analyzer-experimental-internal-checls");
+ Res.push_back("-analyzer-experimental-internal-checks");
}
static void CodeGenOptsToArgs(const CodeGenOptions &Opts,
Modified: cfe/trunk/tools/clang-cc/Options.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-cc/Options.cpp?rev=89629&r1=89628&r2=89629&view=diff
==============================================================================
--- cfe/trunk/tools/clang-cc/Options.cpp (original)
+++ cfe/trunk/tools/clang-cc/Options.cpp Sun Nov 22 16:08:20 2009
@@ -81,7 +81,7 @@
AnalyzeAll("analyzer-opt-analyze-headers",
llvm::cl::desc("Force the static analyzer to analyze "
"functions defined in header files"));
-
+
static llvm::cl::opt<bool>
AnalyzerDisplayProgress("analyzer-display-progress",
llvm::cl::desc("Emit verbose output about the analyzer's progress"));
@@ -93,7 +93,7 @@
static llvm::cl::opt<bool>
AnalyzerExperimentalInternalChecks("analyzer-experimental-internal-checks",
llvm::cl::desc("Use new default path-sensitive checks currently in testing"));
-
+
static llvm::cl::opt<std::string>
AnalyzeSpecificFunction("analyze-function",
llvm::cl::desc("Run analysis on specific function"));
More information about the cfe-commits
mailing list