[PATCH] D52670: [clang-tidy] Add new 'readability-uppercase-literal-suffix' check (CERT DCL16-C, MISRA C:2012, 7.3, MISRA C++:2008, 2-13-4)

Roman Lebedev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Sep 29 12:09:40 PDT 2018


lebedev.ri updated this revision to Diff 167620.
lebedev.ri marked 13 inline comments as done.
lebedev.ri added a comment.

Thank you for taking a look!

- Rebased
- Added an alias in `hicpp` module
- Addressed //most// of the review comments.

In https://reviews.llvm.org/D52670#1249898, @JonasToth wrote:

> Thanks for working on this!




> Related as well: http://www.codingstandard.com/rule/4-2-1-ensure-that-the-u-suffix-is-applied-to-a-literal-used-in-a-context-requiring-an-unsigned-integral-expression/
>  I think its wort a alias is hicpp as well

Hmm, after digging but, i think you meant to link to https://www.codingstandard.com/rule/4-3-1-do-not-convert-an-expression-of-wider-floating-point-type-to-a-narrower-floating-point-type/
With some leeway, i think it does talk about the suffix being uppercase.
Added.

> Please add tests that use user-defined literals and ensure there are no collision and that they are not diagnosed. Some examples: https://en.cppreference.com/w/cpp/language/user_literal

All those are `UserDefinedLiteral`, so we should be good..  https://godbolt.org/z/PcGi0B
Also, it seems the suffix can't be set for these constants: https://godbolt.org/z/YHTqke
So i'm not sure what to test. Can you give an example of a test?


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D52670

Files:
  clang-tidy/cert/CERTTidyModule.cpp
  clang-tidy/cert/CMakeLists.txt
  clang-tidy/hicpp/HICPPTidyModule.cpp
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/MagicNumbersCheck.cpp
  clang-tidy/readability/MagicNumbersCheck.h
  clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp
  clang-tidy/readability/UppercaseLiteralSuffixCheck.h
  clang-tidy/utils/ASTUtils.cpp
  clang-tidy/utils/ASTUtils.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-uppercase-literal-suffix.rst
  test/clang-tidy/readability-uppercase-literal-suffix-floating-point.cpp
  test/clang-tidy/readability-uppercase-literal-suffix-hexadecimal-floating-point.cpp
  test/clang-tidy/readability-uppercase-literal-suffix-integer.cpp
  test/clang-tidy/readability-uppercase-literal-suffix.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52670.167620.patch
Type: text/x-patch
Size: 36514 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180929/b614ea19/attachment-0001.bin>


More information about the cfe-commits mailing list