rizsotto / scan-build

Clang's scan-build re-implementation in python
Other
362 stars 34 forks source link

'attribute ignored' message from analyzer #9

Closed rizsotto closed 10 years ago

rizsotto commented 10 years ago

hi All,

would like to know is it possible to get the same warning while run the analyzer as it was produce by simple compilation?

when i give this input test.c

typedef int __attribute__((visibility("default"))) bar;

and run Clang against it, i get this warning...

$ clang -c test.c 
test.c:1:28: warning: 'visibility' attribute ignored [-Wignored-attributes]
typedef int __attribute__((visibility("default"))) bar;
                          ^
1 warning generated.

but when i run the analyzer, i got nothing like that

$ clang -### --analyze -x c test.c 

then i execute the last line of this output

$ "clang" "-cc1" ....

and it does not generate the warning. my question would be: is it possible to get that warning by passing some extra flags? or it will never appear during the analysis? thanks for any help.

rizsotto commented 10 years ago

comment from Nikola Smiljanić:

Try playing with -ccc-print-phases. I'm not sure if there's a way to start both analyzer and compiler action. Compiler action is what reports the warning, you can enable just this action with -fsyntax-only. But passing both --analyze and -fsyntax-only doesn't seem to work.

rizsotto commented 10 years ago

no solution here... all i can see that the compiler phase make the warning.

this suppose to generate the warning.

$ clang -ccc-print-phases -x c not_used_attributes.c 
0: input, "not_used_attributes.c", c
1: preprocessor, {0}, cpp-output
2: compiler, {1}, assembler
3: assembler, {2}, object
4: linker, {3}, image

while the analyzer is silent.

$ clang --analyze -ccc-print-phases -x c not_used_attributes.c 
0: input, "not_used_attributes.c", c
1: preprocessor, {0}, cpp-output
2: analyzer, {1}, plist

and syntax check also generate the expected warning.

$ clang -fsyntax-only -ccc-print-phases -x c not_used_attributes.c 
0: input, "not_used_attributes.c", c
1: preprocessor, {0}, cpp-output
2: compiler, {1}, none