Skip to content

CHECKER: add field sensitivity to checker #2676

@edwintorok

Description

@edwintorok
Bugzilla Link 2304
Resolution FIXED
Resolved on Dec 20, 2009 16:48
Version unspecified
OS Linux
Blocks llvm/llvm-bugzilla-archive#4979 llvm/llvm-bugzilla-archive#2713 llvm/llvm-bugzilla-archive#4358 llvm/llvm-bugzilla-archive#4399 llvm/llvm-bugzilla-archive#4620
CC @tkremenek,@nashidau

Extended Description

Using SVN r4294967285:

$ ~/llvm-svn/llvm/tools/clang/utils/ccc-analyzer xtest.c -c
xtest.c
ANALYZE: xtest.c foo
xtest.c:10:2: warning: [CHECKER] Branch condition evaluates to an uninitialized value.
if(pt->partno == 1 || !found) {
^ ~~~~~~
ANALYZE: xtest.c bar
1 diagnostic generated.

$ cat xtest.c
struct x {
int partno;
};
int foo(struct x *pt)
{
int found;
if(pt->partno != 1) {
found = 0;
}
if(pt->partno == 1 || !found) {
return 1;
}
return 0;
}

int bar(int partno)
{
int found;
if(partno != 1) {
found = 0;
}
if(partno == 1 || !found) {
return 1;
}
return 0;
}

The HTML output produced says that the branch if(pt->partno...) is untaken.
Notice that if I use a struct it gives a warning, if I don't use the struct it doesn't give a warning. found is not used uninitialized, because when
partno is 1 the !found condition is not evaluated anymore.
Also if partno was 1 on the first if, it still is that on the 2nd one.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions