[cfe-dev] Is it possible to avoid FP when there is #ifdef in the code
Vedant Kumar via cfe-dev
cfe-dev at lists.llvm.org
Wed Aug 26 17:04:12 PDT 2015
I don't think it's fair to call this a false positive, unless the "XYZ" macro is defined.
The analyzer has to run the preprocessor to handle basic things like #include. Modifying the checker to do what you propose would require going from the AST -> source code, scanning for a preprocessor command, altering it, re-parsing it, re-running the checker etc.
It would be easier to add a line like "(void) x;" to suppress the warning.
best
vedant
On Aug 26, 2015, at 1:35 AM, Daniel Marjamäki via cfe-dev <cfe-dev at lists.llvm.org> wrote:
>
> Hello!
>
> Sometimes there are false positives when #ifdef is used and for instance usage of some macro/parameter is hidden.
>
> I am running Clang in a project where we get several such FPs.
>
> Example code:
>
> void f(int x) {
> // ..code..
> #ifdef XYZ
> dostuff(x);
> #endif
> // ..code..
> }
>
> Warning:
> 1.c:1:12: warning: unused parameter 'x' [-Wunused-parameter]
> void f(int x) {
> ^
>
>
> Is there anything that can be done in the unused-parameter checker to prevent such FP?
>
> For instance.. is it possible to see if there was a #ifdef in a function and disable the warning in that function.
>
> Best regards,
> Daniel Marjamäki
>
>
> ..................................................................................................................
> Daniel Marjamäki Senior Engineer
> Evidente ES East AB Warfvinges väg 34 SE-112 51 Stockholm Sweden
>
> Mobile: +46 (0)709 12 42 62
> E-mail: Daniel.Marjamaki at evidente.se
>
> https://urldefense.proofpoint.com/v2/url?u=http-3A__www.evidente.se&d=BQIGaQ&c=eEvniauFctOgLOKGJOplqw&r=nRkKAYlatRp-Wgk-tAtmRg&m=PTXeK_fIRD2j8WdXUJM6t1ZgnTJCl_jei39eezo4pTA&s=KIaa8a7W1uU-ujhcrdhwjwrMYKCcDD71x-77CQL5wKs&e=
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.llvm.org_cgi-2Dbin_mailman_listinfo_cfe-2Ddev&d=BQIGaQ&c=eEvniauFctOgLOKGJOplqw&r=nRkKAYlatRp-Wgk-tAtmRg&m=PTXeK_fIRD2j8WdXUJM6t1ZgnTJCl_jei39eezo4pTA&s=yZgb9XCd-JGQ_HwN0wTip7nQwkawracR5TZckpNTNmU&e=
More information about the cfe-dev
mailing list