llvm-project/clang-tools-extra/clang-tidy
Roman Lebedev 2634bd5995 [clang-tidy] Avoid C arrays check
Summary:
[[ https://bugs.llvm.org/show_bug.cgi?id=39224 | PR39224 ]]
As discussed, we can't always do the transform automatically due to that array-to-pointer decay of C array.
In order to detect whether we can do said transform, we'd need to be able to see all usages of said array,
which is, i would say, rather impossible if e.g. it is in the header.
Thus right now no fixit exists.

Exceptions: `extern "C"` code.

References:
* [[ https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#es27-use-stdarray-or-stack_array-for-arrays-on-the-stack | CPPCG ES.27: Use std::array or stack_array for arrays on the stack ]]
* [[ https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#slcon1-prefer-using-stl-array-or-vector-instead-of-a-c-array | CPPCG SL.con.1: Prefer using STL array or vector instead of a C array ]]
* HICPP `4.1.1 Ensure that a function argument does not undergo an array-to-pointer conversion`
* MISRA `5-2-12 An identifier with array type passed as a function argument shall not decay to a pointer`

Reviewers: aaron.ballman, JonasToth, alexfh, hokein, xazax.hun

Reviewed By: JonasToth

Subscribers: Eugene.Zelenko, mgorny, rnkovacs, cfe-commits

Tags: #clang-tools-extra

Differential Revision: https://reviews.llvm.org/D53771

llvm-svn: 346835
2018-11-14 09:01:08 +00:00
..
abseil [clant-tidy] abseil: Add clangTooling to CMakeLists.txt 2018-10-24 20:31:58 +00:00
android [Clang-tidy] Alphabetical sort of files/checks. Add space after clang-tidy in source code headers. 2018-09-20 00:02:55 +00:00
boost Port getLocStart -> getBeginLoc 2018-08-09 22:42:26 +00:00
bugprone [clang-tidy] new check: bugprone-too-small-loop-variable 2018-11-12 16:01:39 +00:00
cert Reapply Logging: make os_log buffer size an integer constant expression. 2018-11-02 13:14:11 +00:00
cppcoreguidelines [clang-tidy] Avoid C arrays check 2018-11-14 09:01:08 +00:00
fuchsia Port getLocEnd -> getEndLoc 2018-08-09 22:43:02 +00:00
google Fix clang -Wimplicit-fallthrough warnings across llvm, NFC 2018-11-01 19:54:45 +00:00
hicpp [clang-tidy] Avoid C arrays check 2018-11-14 09:01:08 +00:00
llvm Port getLocEnd -> getEndLoc 2018-08-09 22:43:02 +00:00
misc [clang-tidy] Non-private member variables in classes (MISRA, CppCoreGuidelines, HICPP) 2018-10-18 20:16:44 +00:00
modernize [clang-tidy] Avoid C arrays check 2018-11-14 09:01:08 +00:00
mpi [clang-tidy] Add dependency to clangAnalysis after rC343160 2018-09-27 04:23:24 +00:00
objc Fix the issue that not recognizing single acronym with prefix as ObjC property name. 2018-11-01 17:36:18 +00:00
performance Ignore implicit things like ConstantExpr. 2018-11-09 01:32:30 +00:00
plugin [clang-tidy] Untangle layering in ClangTidyDiagnosticConsumer somewhat. NFC 2018-11-08 17:42:16 +00:00
portability
readability Implement the readability-const-return-type check. 2018-10-31 19:11:38 +00:00
tool [clang-tidy] Get ClangTidyContext out of the business of storing diagnostics. NFC 2018-11-02 10:01:59 +00:00
utils [clang-tidy] Fixed code sample in a comment. NFC 2018-11-02 15:29:37 +00:00
zircon [clang-tidy] Add Zircon module to clang-tidy 2018-03-14 23:47:50 +00:00
CMakeLists.txt [clang-tidy] Build it even without static analyzer 2018-10-01 20:24:22 +00:00
ClangTidy.cpp [clang-tidy] Untangle layering in ClangTidyDiagnosticConsumer somewhat. NFC 2018-11-08 17:42:16 +00:00
ClangTidy.h [clang-tidy] Get ClangTidyContext out of the business of storing diagnostics. NFC 2018-11-02 10:01:59 +00:00
ClangTidyDiagnosticConsumer.cpp [clang-tidy] Untangle layering in ClangTidyDiagnosticConsumer somewhat. NFC 2018-11-08 17:42:16 +00:00
ClangTidyDiagnosticConsumer.h [clang-tidy] Untangle layering in ClangTidyDiagnosticConsumer somewhat. NFC 2018-11-08 17:42:16 +00:00
ClangTidyModule.cpp
ClangTidyModule.h
ClangTidyModuleRegistry.h
ClangTidyOptions.cpp Lift VFS from clang to llvm (NFC) 2018-10-10 13:27:25 +00:00
ClangTidyOptions.h Lift VFS from clang to llvm (NFC) 2018-10-10 13:27:25 +00:00
ClangTidyProfiling.cpp [clang-tidy] Store checks profiling info as JSON files 2018-06-06 15:07:51 +00:00
ClangTidyProfiling.h [clang-tidy] Store checks profiling info as JSON files 2018-06-06 15:07:51 +00:00
add_new_check.py [Clang-tidy] Alphabetical sort of files/checks. Add space after clang-tidy in source code headers. 2018-09-20 00:02:55 +00:00
rename_check.py [clang-tidy] Use :doc: for check links in Release Notes. 2018-03-21 17:06:13 +00:00