[cfe-dev] [Analyzer - UnreachableCodeChecker] Why analyzer suppress the warnings coming from macro?
Wong Henry via cfe-dev
cfe-dev at lists.llvm.org
Sun Sep 3 20:29:55 PDT 2017
Hi all,
I have some questions about UnreachableCodeChecker. It seems that UnreachableCodeChecker suppresses some dead code warnings coming from macros.
Given the below code sippet:
-------------------------------------------------
1 #include <stdio.h>
2 #define MACRO(cond) \
3 if (cond) { printf("dead code\n"); } <---- dead code
4
5 void foo()
6 {
7 MACRO(0)
8 }
-------------------------------------------------
It is reasonable to suppress the dead code warning in the above code sample. But it is unreasonable to suppress some other dead code warnings.
For example:
-------------------------------------------------
1 #include <stdio.h>
2 #define MACRO(cond) \
3 if (0) { printf("dead code\n"); } <---- dead code
4
5 void foo()
6 {
7 MACRO(0)
8 }
-------------------------------------------------
No matter what 'cond' is, the 'printf' is always unreachable. So I have the following two questions:
(1) What caused UnreachableCodeChecker to be designed like that?
(2) If I want to make some improvements, what kind of work should I do, for example, only suppress dead code warnings that depend on macro arguments and suppresses common patterns in macros like 'do {...} while (0)'.
Cheers,
Henry Wong
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170904/b7b7b71f/attachment.html>
More information about the cfe-dev
mailing list