llvm-project/clang-tools-extra/clang-tidy
Fangrui Song b9ca972b1f [clang-tidy] Add portability-std-allocator-const check
Report use of `std::vector<const T>` (and similar containers of const
elements). These are now allowed in standard C++ due to undefined
`std::allocator<const T>`. They do not compile with libstdc++ or MSVC.
Future libc++ will remove the extension (D120996).
See docs/clang-tidy/checks/portability-std-allocator-const.rst for detail.

I have attempted clean-up in a large code base. Here are some statistics:

* 98% are related to the container `std::vector`, among `deque/forward_list/list/multiset/queue/set/stack/vector`.
* 24% are related to `std::vector<const std::string>`.
* Both `std::vector<const absl::string_view>` and `std::vector<const int>` contribute 2%. The other contributors spread over various class types.

The check can be useful to other large code bases and may serve as an example
for future libc++ strictness improvement.

Note: on MSVC where -fdelayed-template-parsing is the default, the check cannot
catch cases in uninstantiated templates.

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D123655
2022-04-14 11:13:41 -07:00
..
abseil [libTooling] Generalize string explanation as templated metadata 2022-03-21 20:39:35 +00:00
altera [clang][lex] NFCI: Use FileEntryRef in PPCallbacks::InclusionDirective() 2022-04-14 10:46:12 +02:00
android Use StringRef::contains (NFC) 2021-12-24 22:05:34 -08:00
boost [openmp] Add missing dependencies for OMP.h.inc after d90443b 2020-06-23 11:48:04 -04:00
bugprone [clang][lex] NFCI: Use FileEntryRef in PPCallbacks::InclusionDirective() 2022-04-14 10:46:12 +02:00
cert [clang-tidy][docs] Fix wrong url in DontModifyStdNamespaceCheck 2022-03-13 17:51:00 +01:00
concurrency [clang-tidy] Add new check 'concurrency-thread-canceltype-asynchronous' and alias 'cert-pos47-c'. 2021-02-22 12:42:20 +01:00
cppcoreguidelines [clang-tidy] Fix invalid fix-it for cppcoreguidelines-prefer-member-initializer 2022-04-07 19:13:50 +01:00
darwin [openmp] Add missing dependencies for OMP.h.inc after d90443b 2020-06-23 11:48:04 -04:00
fuchsia Fix false positives in `fuchsia-trailing-return` check involving deduction guides 2021-12-01 15:28:01 -05:00
google Reland "[AST] Add UsingType: a sugar type for types found via UsingDecl" 2021-12-20 18:03:15 +01:00
hicpp [clang-tidy] Applied clang-tidy fixes. NFC 2021-01-29 01:01:19 +01:00
linuxkernel [openmp] Add missing dependencies for OMP.h.inc after d90443b 2020-06-23 11:48:04 -04:00
llvm [clang][lex] NFCI: Use FileEntryRef in PPCallbacks::InclusionDirective() 2022-04-14 10:46:12 +02:00
llvmlibc [clang][lex] NFCI: Use FileEntryRef in PPCallbacks::InclusionDirective() 2022-04-14 10:46:12 +02:00
misc [clang-tidy] Never consider assignments as equivalent in `misc-redundant-expression` check 2022-04-12 16:03:14 +02:00
modernize [clang][lex] NFCI: Use FileEntryRef in PPCallbacks::InclusionDirective() 2022-04-14 10:46:12 +02:00
mpi [clang-tidy][NFC] replace some redundant std::string creations 2022-01-19 18:36:35 +00:00
objc [clang-tidy][objc] Finds and fixes improper usages of XCTAssertEquals and XCTAssertNotEquals. 2021-12-02 18:32:16 -05:00
openmp [clang-tidy][NFC] Remove unnecessary includes throughout clang-tidy header files 2020-06-29 16:05:52 +01:00
performance [clang-tidy] Make performance-inefficient-vector-operation work on members 2022-04-08 14:17:41 +01:00
plugin [clang-tidy] Fix lint warnings in clang-tidy source code (NFC) 2021-11-02 20:14:25 +13:00
portability [clang-tidy] Add portability-std-allocator-const check 2022-04-14 11:13:41 -07:00
readability [clang][lex] NFCI: Use FileEntryRef in PPCallbacks::InclusionDirective() 2022-04-14 10:46:12 +02:00
tool Fix typo in new -config-file option 2022-04-05 16:28:49 -04:00
utils [clang][lex] NFCI: Use FileEntryRef in PPCallbacks::InclusionDirective() 2022-04-14 10:46:12 +02:00
zircon Remove references to the ast_type_traits namespace 2020-12-11 00:58:46 +01:00
CMakeLists.txt Re-land "Cache the locations of NOLINTBEGIN/END blocks" with fix for build bot 2022-01-27 01:03:27 +13:00
ClangTidy.cpp [clang-tidy] Fix lint warnings in clang-tidy source code (NFC) 2021-11-02 20:14:25 +13:00
ClangTidy.h [clang-tidy] Fix lint warnings in clang-tidy source code (NFC) 2021-11-02 20:14:25 +13:00
ClangTidyCheck.cpp [clang-tidy] Add new case type to check variables with Hungarian notation 2021-08-01 15:22:17 -07:00
ClangTidyCheck.h [clang-tools-extra] Remove unused forward declarations (NFC) 2022-01-30 16:05:00 -08:00
ClangTidyDiagnosticConsumer.cpp Re-land "Cache the locations of NOLINTBEGIN/END blocks" with fix for build bot 2022-01-27 01:03:27 +13:00
ClangTidyDiagnosticConsumer.h [clang-tools-extra] Remove unused forward declarations (NFC) 2022-01-30 16:05:00 -08:00
ClangTidyForceLinker.h [clang-tidy] add concurrency module 2020-11-30 12:27:17 +03:00
ClangTidyModule.cpp [clang-tidy][NFC] Use StringMap for ClangTidyCheckFactories::FacoryMap 2020-07-30 22:57:33 +01:00
ClangTidyModule.h [clang-tidy][NFC] Remove unnecessary headers 2020-12-28 15:01:51 +00:00
ClangTidyModuleRegistry.h
ClangTidyOptions.cpp [clang-tidy] Applied clang-tidy fixes. NFC 2021-01-29 01:01:19 +01:00
ClangTidyOptions.h [clang-tidy] Fix lint warnings in clang-tidy source code (NFC) 2021-11-02 20:14:25 +13:00
ClangTidyProfiling.cpp [clang-tidy][NFC] Remove unnecessary headers 2020-12-28 15:01:51 +00:00
ClangTidyProfiling.h [clang-tidy][NFC] Remove unnecessary includes throughout clang-tidy header files 2020-06-29 16:05:52 +01:00
ExpandModularHeadersPPCallbacks.cpp [clang][lex] NFCI: Use FileEntryRef in PPCallbacks::InclusionDirective() 2022-04-14 10:46:12 +02:00
ExpandModularHeadersPPCallbacks.h [clang][lex] NFCI: Use FileEntryRef in PPCallbacks::InclusionDirective() 2022-04-14 10:46:12 +02:00
GlobList.cpp Allow newline characters as separators for checks in Clang-Tidy configurations 2022-03-15 14:30:13 -04:00
GlobList.h [clang-tidy][NFC] Remove Tristate from CachedGlobList 2022-02-23 08:35:31 +00:00
NoLintDirectiveHandler.cpp Re-land "Cache the locations of NOLINTBEGIN/END blocks" with fix for build bot 2022-01-27 01:03:27 +13:00
NoLintDirectiveHandler.h Re-land "Cache the locations of NOLINTBEGIN/END blocks" with fix for build bot 2022-01-27 01:03:27 +13:00
add_new_check.py [clang-tidy] Refactor: Prefer single quoted strings over double quoted strings [NFC] 2022-03-11 15:08:24 -07:00
clang-tidy-config.h.cmake Add an explicit toggle for the static analyzer in clang-tidy 2020-09-10 10:48:17 -04:00
rename_check.py Fix python 2-vs-3 issues in add_new_check.py and rename_check.py 2021-09-11 09:52:50 +02:00