diff options
author | Tom Care <tcare@apple.com> | 2010-07-06 21:43:29 +0000 |
---|---|---|
committer | Tom Care <tcare@apple.com> | 2010-07-06 21:43:29 +0000 |
commit | 3ff08a8e76eeb25ceeed2c7461eccd388f996985 (patch) | |
tree | a9ee816fe14fa19a856f4a5c1debb30d5a6dcdcc /clang/lib/Frontend/CompilerInvocation.cpp | |
parent | 4c1ca2903984f760a2f3de2d51c8c9ba3e669d54 (diff) | |
download | bcm5719-llvm-3ff08a8e76eeb25ceeed2c7461eccd388f996985.tar.gz bcm5719-llvm-3ff08a8e76eeb25ceeed2c7461eccd388f996985.zip |
Added a path-sensitive idempotent operation checker (-analyzer-idempotent-operation). Finds idempotent and/or tautological operations in a path sensitive context, flagging operations that have no effect or a predictable effect.
Example:
{
int a = 1;
int b = 5;
int c = b / a; // a is 1 on all paths
}
- New IdempotentOperationChecker class
- Moved recursive Stmt functions in r107675 to IdempotentOperationChecker
- Minor refactoring of SVal to allow checking for any integer
- Added command line option for check
- Added basic test cases
llvm-svn: 107706
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
-rw-r--r-- | clang/lib/Frontend/CompilerInvocation.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index c19879f35f0..25203412559 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -112,6 +112,8 @@ static void AnalyzerOptsToArgs(const AnalyzerOptions &Opts, Res.push_back("-analyzer-experimental-checks"); if (Opts.EnableExperimentalInternalChecks) Res.push_back("-analyzer-experimental-internal-checks"); + if (Opts.EnableIdempotentOperationChecker) + Res.push_back("-analyzer-idempotent-operation"); } static void CodeGenOptsToArgs(const CodeGenOptions &Opts, @@ -788,6 +790,8 @@ static void ParseAnalyzerArgs(AnalyzerOptions &Opts, ArgList &Args, Opts.EnableExperimentalChecks = Args.hasArg(OPT_analyzer_experimental_checks); Opts.EnableExperimentalInternalChecks = Args.hasArg(OPT_analyzer_experimental_internal_checks); + Opts.EnableIdempotentOperationChecker = + Args.hasArg(OPT_analyzer_idempotent_operation); Opts.TrimGraph = Args.hasArg(OPT_trim_egraph); Opts.MaxNodes = Args.getLastArgIntValue(OPT_analyzer_max_nodes, 150000,Diags); Opts.MaxLoop = Args.getLastArgIntValue(OPT_analyzer_max_loop, 3, Diags); |