[cfe-commits] r162827 - in /cfe/trunk: include/clang/Basic/DiagnosticDriverKinds.td include/clang/Driver/CC1Options.td include/clang/Frontend/AnalyzerOptions.h include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h lib/Frontend/CompilerInvocation.cpp lib/StaticAnalyzer/Core/AnalysisManager.cpp lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
Anna Zaks
ganna at apple.com
Wed Aug 29 10:15:35 PDT 2012
On Aug 28, 2012, at 10:55 PM, Ted Kremenek wrote:
> Author: kremenek
> Date: Wed Aug 29 00:55:00 2012
> New Revision: 162827
>
> URL: http://llvm.org/viewvc/llvm-project?rev=162827&view=rev
> Log:
> Add new -cc1 driver option -analyzer-config, which allows one to specify
> a comma separated collection of key:value pairs (which are strings). This
> allows a general way to provide analyzer configuration data from the command line.
>
> No clients yet.
>
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
> cfe/trunk/include/clang/Driver/CC1Options.td
> cfe/trunk/include/clang/Frontend/AnalyzerOptions.h
> cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h
> cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
> cfe/trunk/lib/Frontend/CompilerInvocation.cpp
> cfe/trunk/lib/StaticAnalyzer/Core/AnalysisManager.cpp
> cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=162827&r1=162826&r2=162827&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Wed Aug 29 00:55:00 2012
> @@ -141,5 +141,9 @@
>
> def note_drv_command_failed_diag_msg : Note<
> "diagnostic msg: %0">;
> -
> +
> +def err_analyzer_config_no_value : Error<
> + "analyzer-config option '%0' has a key but no value">;
> +def err_analyzer_config_multiple_values : Error<
> + "analyzer-config option '%0' should contain only one ':'">;
> }
>
> Modified: cfe/trunk/include/clang/Driver/CC1Options.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=162827&r1=162826&r2=162827&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Driver/CC1Options.td (original)
> +++ cfe/trunk/include/clang/Driver/CC1Options.td Wed Aug 29 00:55:00 2012
> @@ -119,6 +119,11 @@
> def analyzer_checker_help : Flag<"-analyzer-checker-help">,
> HelpText<"Display the list of analyzer checkers that are available">;
>
> +def analyzer_config : Separate<"-analyzer-config">,
> + HelpText<"Choose analyzer checkers to enable">;
analyzer checkers -> analyzer options
> +def analyzer_config_EQ : Joined<"-analyzer-config=">,
> + Alias<analyzer_config>;
> +
> //===----------------------------------------------------------------------===//
> // Migrator Options
> //===----------------------------------------------------------------------===//
>
> Modified: cfe/trunk/include/clang/Frontend/AnalyzerOptions.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/AnalyzerOptions.h?rev=162827&r1=162826&r2=162827&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/Frontend/AnalyzerOptions.h (original)
> +++ cfe/trunk/include/clang/Frontend/AnalyzerOptions.h Wed Aug 29 00:55:00 2012
> @@ -17,6 +17,7 @@
>
> #include <string>
> #include <vector>
> +#include "llvm/ADT/StringMap.h"
>
> namespace clang {
> class ASTConsumer;
> @@ -78,6 +79,7 @@
> public:
> /// \brief Pair of checker name and enable/disable.
> std::vector<std::pair<std::string, bool> > CheckersControlList;
> + llvm::StringMap<std::string> Config;
Use the ConfigTable typedef for the type?
> AnalysisStores AnalysisStoreOpt;
> AnalysisConstraints AnalysisConstraintsOpt;
> AnalysisDiagClients AnalysisDiagOpt;
>
> Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h?rev=162827&r1=162826&r2=162827&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h (original)
> +++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h Wed Aug 29 00:55:00 2012
> @@ -81,6 +81,11 @@
> /// strategy. We get better code coverage when retry is enabled.
> bool NoRetryExhausted;
>
> + typedef llvm::StringMap<std::string> ConfigTable;
> +
> + /// \brief A key-value table of use-specified configuration values.
> + const ConfigTable &Config;
> +
> public:
> AnalysisManager(ASTContext &ctx,DiagnosticsEngine &diags,
> const LangOptions &lang,
> @@ -88,6 +93,7 @@
> StoreManagerCreator storemgr,
> ConstraintManagerCreator constraintmgr,
> CheckerManager *checkerMgr,
> + const ConfigTable &Config,
> unsigned maxnodes, unsigned maxvisit,
> bool vizdot, bool vizubi, AnalysisPurgeMode purge,
> bool eager, bool trim,
>
> Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h?rev=162827&r1=162826&r2=162827&view=diff
> ==============================================================================
> --- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h (original)
> +++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h Wed Aug 29 00:55:00 2012
> @@ -64,6 +64,10 @@
> return Eng.getStoreManager();
> }
>
> + const AnalysisManager::ConfigTable &getConfig() const {
> + return Eng.getAnalysisManager().Config;
> + }
> +
> /// \brief Returns the previous node in the exploded graph, which includes
> /// the state of the program before the checker ran. Note, checkers should
> /// not retain the node in their state since the nodes might get invalidated.
>
> Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=162827&r1=162826&r2=162827&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
> +++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Wed Aug 29 00:55:00 2012
> @@ -1154,6 +1154,36 @@
> for (unsigned i = 0, e = checkers.size(); i != e; ++i)
> Opts.CheckersControlList.push_back(std::make_pair(checkers[i], enable));
> }
> +
> + // Go through the analyzer configuration options.
> + for (arg_iterator it = Args.filtered_begin(OPT_analyzer_config),
> + ie = Args.filtered_end(); it != ie; ++it) {
> + const Arg *A = *it;
> + A->claim();
> + // We can have a list of comma separated config names, e.g:
> + // '-analyzer-config=key1:val1,key2:val2'
> + StringRef configList = A->getValue(Args);
> + SmallVector<StringRef, 4> configVals;
> + configList.split(configVals, ",");
> + for (unsigned i = 0, e = configVals.size(); i != e; ++i) {
> + StringRef key, val;
> + llvm::tie(key, val) = configVals[i].split(":");
> + if (val.empty()) {
> + Diags.Report(SourceLocation(),
> + diag::err_analyzer_config_no_value) << configVals[i];
> + Success = false;
> + break;
> + }
> + if (val.find(':') != StringRef::npos) {
> + Diags.Report(SourceLocation(),
> + diag::err_analyzer_config_multiple_values)
> + << configVals[i];
> + Success = false;
> + break;
> + }
> + Opts.Config[key] = val;
> + }
> + }
>
> return Success;
> }
>
> Modified: cfe/trunk/lib/StaticAnalyzer/Core/AnalysisManager.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/AnalysisManager.cpp?rev=162827&r1=162826&r2=162827&view=diff
> ==============================================================================
> --- cfe/trunk/lib/StaticAnalyzer/Core/AnalysisManager.cpp (original)
> +++ cfe/trunk/lib/StaticAnalyzer/Core/AnalysisManager.cpp Wed Aug 29 00:55:00 2012
> @@ -20,6 +20,7 @@
> StoreManagerCreator storemgr,
> ConstraintManagerCreator constraintmgr,
> CheckerManager *checkerMgr,
> + const ConfigTable &Config,
> unsigned maxnodes, unsigned maxvisit,
> bool vizdot, bool vizubi,
> AnalysisPurgeMode purge,
> @@ -36,7 +37,7 @@
> Ctx(ctx), Diags(diags), LangOpts(lang),
> PathConsumers(PDC),
> CreateStoreMgr(storemgr), CreateConstraintMgr(constraintmgr),
> - CheckerMgr(checkerMgr),
> + CheckerMgr(checkerMgr),
> MaxNodes(maxnodes), MaxVisit(maxvisit),
> VisualizeEGDot(vizdot), VisualizeEGUbi(vizubi), PurgeDead(purge),
> EagerlyAssume(eager), TrimGraph(trim),
> @@ -45,7 +46,8 @@
> InlineMaxStackDepth(inlineMaxStack),
> InlineMaxFunctionSize(inlineMaxFunctionSize),
> InliningMode(IMode),
> - NoRetryExhausted(NoRetry)
> + NoRetryExhausted(NoRetry),
> + Config(Config)
> {
> AnaCtxMgr.getCFGBuildOptions().setAllAlwaysAdd();
> }
>
> Modified: cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp?rev=162827&r1=162826&r2=162827&view=diff
> ==============================================================================
> --- cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp (original)
> +++ cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp Wed Aug 29 00:55:00 2012
> @@ -255,11 +255,16 @@
> CreateStoreMgr,
> CreateConstraintMgr,
> checkerMgr.get(),
> - Opts.MaxNodes, Opts.MaxLoop,
> - Opts.VisualizeEGDot, Opts.VisualizeEGUbi,
> - Opts.AnalysisPurgeOpt, Opts.EagerlyAssume,
> + Opts.Config,
> + Opts.MaxNodes,
> + Opts.MaxLoop,
> + Opts.VisualizeEGDot,
> + Opts.VisualizeEGUbi,
> + Opts.AnalysisPurgeOpt,
> + Opts.EagerlyAssume,
> Opts.TrimGraph,
> - Opts.UnoptimizedCFG, Opts.CFGAddImplicitDtors,
> + Opts.UnoptimizedCFG,
> + Opts.CFGAddImplicitDtors,
> Opts.EagerlyTrimEGraph,
> Opts.IPAMode,
> Opts.InlineMaxStackDepth,
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list