diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index fd9b63599723..70bdd5b99cb7 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -830,7 +830,7 @@ static void ParseAnalyzerArgs(AnalyzerOptions &Opts, ArgList &Args, Args.hasArg(OPT_analyzer_experimental_internal_checks); 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); + Opts.MaxLoop = Args.getLastArgIntValue(OPT_analyzer_max_loop, 4, Diags); Opts.InlineCall = Args.hasArg(OPT_analyzer_inline_call); Opts.IdempotentOps = Args.hasArg(OPT_analysis_WarnIdempotentOps); } diff --git a/clang/test/Analysis/idempotent-operations-limited-loops.c b/clang/test/Analysis/idempotent-operations-limited-loops.c new file mode 100644 index 000000000000..e3043ee014ac --- /dev/null +++ b/clang/test/Analysis/idempotent-operations-limited-loops.c @@ -0,0 +1,29 @@ +void always_warning() { int *p = 0; *p = 0xDEADBEEF; } + +// FIXME: False positive due to loop unrolling. This should be fixed. + +int pr8403() +{ + int i; + for(i=0; i<10; i++) + { + int j; + for(j=0; j+1&1 | FileCheck --check-prefix=Loops3 %s +// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-opt-analyze-nested-blocks -analyzer-check-objc-mem -analyzer-check-idempotent-operations -analyzer-max-loop 4 %s 2>&1 | FileCheck --check-prefix=Loops4 %s +// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-opt-analyze-nested-blocks -analyzer-check-objc-mem -analyzer-check-idempotent-operations %s 2>&1 | FileCheck --check-prefix=LoopsDefault %s + +// CHECK-Loops3: :1:37: warning: Dereference of null pointer +// CHECK-Loops3: :11:27: warning: The left operand to '+' is always 0 +// CHECK-Loops3: 2 warnings generated +// CHECK-Loops4: :1:37: warning: Dereference of null pointer +// CHECK-Loops4: 1 warning generated. +// CHECK-LoopsDefault: :1:37: warning: Dereference of null pointer +// CHECK-LoopsDefault: 1 warning generated. +