From 222e2a7620e6520ffaf4fc4e69d79c18da31542e Mon Sep 17 00:00:00 2001 From: "Zancanaro; Carlo" Date: Mon, 24 Sep 2012 09:58:17 +1000 Subject: Add the clang library to the repo (with some of my changes, too). --- .../Analysis/idempotent-operations-limited-loops.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 clang/test/Analysis/idempotent-operations-limited-loops.c (limited to 'clang/test/Analysis/idempotent-operations-limited-loops.c') 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 0000000..71e7c27 --- /dev/null +++ b/clang/test/Analysis/idempotent-operations-limited-loops.c @@ -0,0 +1,21 @@ +// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-opt-analyze-nested-blocks -analyzer-checker=core,experimental.deadcode.IdempotentOperations -analyzer-max-loop 3 -verify %s +// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-opt-analyze-nested-blocks -analyzer-checker=core,experimental.deadcode.IdempotentOperations -analyzer-max-loop 4 -verify %s +// RUN: %clang_cc1 -analyze -analyzer-store=region -analyzer-constraints=range -fblocks -analyzer-opt-analyze-nested-blocks -analyzer-checker=core,experimental.deadcode.IdempotentOperations %s -verify + +void always_warning() { int *p = 0; *p = 0xDEADBEEF; } // expected-warning{{Dereference of null pointer (loaded from variable 'p')}} + +// This test case previously caused a bogus idempotent operation warning +// due to us not properly culling warnings due to incomplete analysis of loops. +int pr8403() +{ + int i; + for(i=0; i<10; i++) + { + int j; + for(j=0; j+1