[PATCH] D45444: [clang-tidy] implement new check for const-correctness

Shuai Wang via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Aug 10 13:12:18 PDT 2018


shuaiwang added a comment.

In https://reviews.llvm.org/D45444#1191874, @JonasToth wrote:

> > Could you give a concrete example of this?
>
> vi llvm/lib/Demangle/ItaniumDemangle.cpp +1762
>
> /home/jonas/opt/llvm/lib/Demangle/ItaniumDemangle.cpp:1762:7: warning:
>  variable 'num' of type 'char [FloatData<Float>::max_demangled_size]' can
>  be declared 'const' [cppcoreguidelines-const-correctness]
>        char num[FloatData<Float>::max_demangled_size] = {0};
>       ^
>  /home/jonas/opt/llvm/lib/Demangle/ItaniumDemangle.cpp:1763:7: warning:
>  variable 'n' of type 'int' can be declared 'const'
>  [cppcoreguidelines-const-correctness]
>        int n = snprintf(num, sizeof(num), FloatData<Float>::spec, value);
>       ^


Looks like related to template.
the exact type of `num` depends on `Float`
and the `CallExpr` is not even resolved because we don't know the type of the arguments yet (adl, overload resolution, etc.)
So the AST doesn't contain any array to pointer decay.

I guess we should suppress the check in such cases.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D45444





More information about the cfe-commits mailing list