[PATCH] D55433: [clang-tidy] Adding a new modernize use nodiscard checker

MyDeveloperDay via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Dec 15 08:06:36 PST 2018


MyDeveloperDay updated this revision to Diff 178367.
MyDeveloperDay added a comment.

-Refactor the checker to remove the llvm::any_of by using a QualType ast-matcher with hasAnyParameter(hasType(x))

- i.e. ...unless(hasAnyParameter(hasType(isNonConstReferenceOrPointer())))...

-Reduce the SNR ratio of using a macro as the ReplacementString option (e.g. LLVM_NODISCARD), when that macro is not define in-scope

- This was seen when performing clang-tidy on LLVM itself, some of the very low level classes did not have the LLVM_NODISCARD macro (from include/llvm/Support/Compiler.h) defined in scope.
- In these cases the fix-it caused too many additional changes to be needed of including the additional header file in order to build.
- Instead emit a warning to say that it could not be marked as LLVM_NODISCARD and don't apply the fix-it
- Add documentation and unit tests to document and validate the above


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55433/new/

https://reviews.llvm.org/D55433

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseNodiscardCheck.cpp
  clang-tidy/modernize/UseNodiscardCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-use-nodiscard.rst
  test/clang-tidy/modernize-use-nodiscard-clang-unused.cpp
  test/clang-tidy/modernize-use-nodiscard-cxx11.cpp
  test/clang-tidy/modernize-use-nodiscard-gcc-unused.cpp
  test/clang-tidy/modernize-use-nodiscard-no-macro-inscope-cxx11.cpp
  test/clang-tidy/modernize-use-nodiscard-no-macro.cpp
  test/clang-tidy/modernize-use-nodiscard.cpp
  test/clang-tidy/modernize-use-nodiscard.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D55433.178367.patch
Type: text/x-patch
Size: 27877 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181215/997f1eaf/attachment-0001.bin>


More information about the cfe-commits mailing list