For the following code located in const-ret-type.cpp: const int* const volatile foo() {} The following invocation of clang-tidy produces the following output: $ clang-tidy -checks=-*,readability-const-return-type const-ret-type.cpp 2 warnings generated. const-ret-type.cpp:1:1: warning: return type 'const int *const volatile' is 'const'-qualified at the top level, ... const int* const volatile foo() {} ^~~~~~ Suppressed 1 warnings (1 with check filters). While the expected diagnostic should be: const int* const volatile foo() {} ^~~~~~ The readability-const-return-type checker incorrectly flags the first `const` token, but it's actually the other `const` token that precedes `volatile` that qualifies the return type. Applying the suggested fixit can result in a miscompilation. The culprit is in the implementation of the utils::lexer::getConstQualifyingToken function. I have a patch ready and I plan to submit it for review shortly.
A fix is up for a review: https://reviews.llvm.org/D71666
fixede with https://reviews.llvm.org/rGf58f39137c6e5a324ef684b1d72bddae244aa94d Thank you for the patch!