summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy/modernize
Commit message (Collapse)AuthorAgeFilesLines
* [clangd] Fix modernize-loop-convert "multiple diag in flight" crash.Haojian Wu2020-06-101-9/+8
| | | | | | | | | | | | | | | | | Summary: this maybe not ideal, but it is trivial and does fix the crash. Fixes https://github.com/clangd/clangd/issues/156. Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D78715 (cherry picked from commit a466e4be3831848d7ff6ffbe4f57d99de8fb66af)
* [clang-tidy] Match InitListExpr in modernize-use-default-member-initMalcolm Parsons2020-01-141-1/+1
| | | | | | | | | | | | | | | | | | Summary: modernize-use-default-member-init wasn't warning about redundant initialisers when the initialiser was an InitListExpr. Add initListExpr to the matcher. Fixes: PR44439 Reviewers: aaron.ballman, alexfh, JonasToth Reviewed By: aaron.ballman Subscribers: xazax.hun, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D72691
* [clang-tidy] Ignore implicit casts in modernize-use-default-member-initMalcolm Parsons2020-01-141-1/+1
| | | | | | | | | | | | | | | | | | Summary: Initialising a pointer from nullptr involves an implicit cast. Ignore it after getting initialiser from InitListExpr. Fixes: PR44440 Reviewers: aaron.ballman, alexfh, JonasToth Reviewed By: JonasToth Subscribers: xazax.hun, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D72630
* MakeUniqueCheck.cpp: explicit the fact that there is an autofix for this checkerSylvestre Ledru2020-01-101-0/+2
|
* [clang-tidy] modernize-use-using uses AST and now supports struct defintions ↵Mitchell Balan2020-01-072-84/+69
| | | | | | | | | | | | | | | | | | | | | | | | | | | | and multiple types in a typedef Summary: It now handles `typedef`s that include comma-separated multiple types, and handles embedded struct definitions, which previously could not be automatically converted. For example, with this patch `modernize-use-using` now can convert: typedef struct { int a; } R_t, *R_p; to: using R_t = struct { int a; }; using R_p = R_t*; `-ast-dump` showed that the `CXXRecordDecl` definitions and multiple `TypedefDecl`s come consecutively in the tree, so `check()` stores information between calls to determine when it is receiving a second or additional `TypedefDecl` within a single `typedef`, or when the current `TypedefDecl` refers to an embedded `CXXRecordDecl` like a `struct`. Reviewers: alexfh, aaron.ballman Patch by: poelmanc Subscribers: riccibruno, sammccall, cfe-commits, aaron.ballman Tags: clang-tools-extra, clang Differential Revision: https://reviews.llvm.org/D70270
* NFC: Fix trivial typos in commentsKazuaki Ishizaki2020-01-044-4/+4
|
* Fix trivial typos in comments; NFCKazuaki Ishizaki2020-01-023-3/+3
|
* AvoidBindCheck.cpp: Fix unused variables warningHans Wennborg2019-12-031-2/+2
|
* AvoidBindCheck.cpp: Fix GCC 5.3 build errorsHans Wennborg2019-12-031-17/+17
| | | | | | | | | | | | | It was failing with: clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp:61:29: error: declaration of ‘clang::tidy::modernize::{anonymous}::CaptureMode clang::tidy::modernize::{anonymous}::BindArgument::CaptureMode’ [-fpermissive] CaptureMode CaptureMode = CM_None; ^ clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp:38:6: error: changes meaning of ‘CaptureMode’ from ‘enum clang::tidy::modernize::{anonymous}::CaptureMode’ [-fpermissive] enum CaptureMode { CM_None, CM_ByRef, CM_ByValue, CM_InitExpression }; ^
* [clang-tidy] Rewrite modernize-avoid-bind check.Zachary Turner2019-12-022-60/+544
| | | | | | | | | | | | | | | | | | | This represents largely a full re-write of modernize-avoid-bind, adding significant new functionality in the process. In particular: * Both boost::bind and std::bind are now supported * Function objects are supported in addition to functions * Member functions are supported * Nested calls are supported using capture-init syntax * std::ref() and boost::ref() are now recognized, and will capture by reference. * Rather than capturing with a global =, we now build up an individual capture list that is both necessary and sufficient for the call. * Fixits are supported in a much larger variety of scenarios than before. All previous tests pass under the re-write, but a large number of new tests have been added as well. Differential Revision: https://reviews.llvm.org/D70368
* [clang-tidy] modernize-use-equals-default avoid adding redundant semicolonsMitchell Balan2019-11-201-2/+10
| | | | | | | | | | | | | | | | | | | Summary: `modernize-use-equals-default` replaces default constructors/destructors with `= default;`. When the optional semicolon after a member function is present, this results in two consecutive semicolons. This patch checks to see if the next non-comment token after the code to be replaced is a semicolon, and if so offers a replacement of `= default` rather than `= default;`. This patch adds trailing comments and semicolons to about 5 existing tests. Reviewers: malcolm.parsons, angelgarcia, aaron.ballman, alexfh Patch by: poelmanc Subscribers: MyDeveloperDay, JonasToth, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70144
* [NFC] Refactor representation of materialized temporariesTyker2019-11-192-2/+2
| | | | | | | | | | | | | | | Summary: this patch refactor representation of materialized temporaries to prevent an issue raised by rsmith in https://reviews.llvm.org/D63640#inline-612718 Reviewers: rsmith, martong, shafik Reviewed By: rsmith Subscribers: thakis, sammccall, ilya-biryukov, rnkovacs, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D69360
* [clang-tidy] modernize-use-override new option AllowOverrideAndFinalMitchell Balan2019-11-192-4/+9
| | | | | | | | | | | | | | | | | | | Summary: In addition to adding `override` wherever possible, clang-tidy's `modernize-use-override` nicely removes `virtual` when `override` or `final` is specified, and further removes override when final is specified. While this is great default behavior, when code needs to be compiled with gcc at high warning levels that include `gcc -Wsuggest-override` or `gcc -Werror=suggest-override`, clang-tidy's removal of the redundant `override` keyword causes gcc to emit a warning or error. This discrepancy / conflict has been noted by others including a comment on Stack Overflow and by Mozilla's Firefox developers. This patch adds an AllowOverrideAndFinal option defaulting to 0 - thus preserving current behavior - that when enabled allows both `override` and `final` to co-exist, while still fixing all other issues. The patch includes a test file verifying all combinations of virtual/override/final, and mentions the new option in the release notes. Reviewers: alexfh, djasper, JonasToth Patch by: poelmanc Subscribers: JonasToth, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70165
* Revert "[clang-tidy] Fix readability-redundant-string-init for c++17/c++2a"Mitchell Balan2019-11-192-9/+4
| | | | This reverts commit 06f3dabe4a2e85a32ade27c0769b6084c828a206.
* Revert "[NFC] Refactor representation of materialized temporaries"Nico Weber2019-11-172-2/+2
| | | | | | This reverts commit 08ea1ee2db5f9d6460fef1d79d0d1d1a5eb78982. It broke ./ClangdTests/FindExplicitReferencesTest.All on the bots, see comments on https://reviews.llvm.org/D69360
* [NFC] Refactor representation of materialized temporariesTyker2019-11-162-2/+2
| | | | | | | | | | | | | | | Summary: this patch refactor representation of materialized temporaries to prevent an issue raised by rsmith in https://reviews.llvm.org/D63640#inline-612718 Reviewers: rsmith, martong, shafik Reviewed By: rsmith Subscribers: rnkovacs, arphaman, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D69360
* [clang-tidy] Fix readability-redundant-string-init for c++17/c++2aMitchell Balan2019-11-152-4/+9
| | | | | | | | | | | | | | | | | | | Summary: `readability-redundant-string-init` was one of several clang-tidy checks documented as failing for C++17. (The failure mode in C++17 is that it changes `std::string Name = ""`; to `std::string Name = Name;`, which actually compiles but crashes at run-time.) Analyzing the AST with `clang -Xclang -ast-dump` showed that the outer `CXXConstructExprs` that previously held the correct SourceRange were being elided in C++17/2a, but the containing `VarDecl` expressions still had all the relevant information. So this patch changes the fix to get its source ranges from `VarDecl`. It adds one test `std::string g = "u", h = "", i = "uuu", j = "", k;` to confirm proper warnings and fixit replacements in a single `DeclStmt` where some strings require replacement and others don't. The readability-redundant-string-init.cpp and readability-redundant-string-init-msvc.cpp tests now pass for C++11/14/17/2a. Reviewers: gribozavr, etienneb, alexfh, hokein, aaron.ballman, gribozavr2 Patch by: poelmanc Subscribers: NoQ, MyDeveloperDay, Eugene.Zelenko, dylanmckay, cfe-commits Tags: #clang, #clang-tools-extra Differential Revision: https://reviews.llvm.org/D69238
* [clang-tidy] modernize-use-using work with multi-argument templatesMitchell Balan2019-11-151-11/+31
| | | | | | | | | | | | | | | | | | | | | | | Summary: If clang-tidy's modernize-use-using feature finds any commas that are not within parentheses, it won't create a fix. That means it won't change lines like: typedef std::pair<int, int> Point; to using Point = std::pair<int, int>; or even: typedef std::map<std::string, Foo> MyMap; typedef std::vector<int,MyCustomAllocator<int>> MyVector; This patch allows the fix to apply to lines with commas if they are within parentheses or angle brackets that were not themselves within parentheses. Reviewers: alexfh, hokein, aaron.ballman Patch by: poelmanc Subscribers: jonathanmeier, cfe-commits Tags: #clang, #clang-tools-extra Differential Revision: https://reviews.llvm.org/D67460
* Fix modernize-use-nodiscard for classes marked [[nodiscard]]Aaron Ballman2019-10-301-1/+3
| | | | | | | Current implementation suggests to add [[nodiscard]] to methods even if the return type is marked already as [[nodiscard]]. Patch by Eugene Sedykh.
* clang-tidy - silence static analyzer getAs<> null dereference warnings. NFCI.Simon Pilgrim2019-10-171-4/+4
| | | | | | The static analyzer is warning about potential null dereferences, but in these cases we should be able to use castAs<> directly and if not assert will fire for us. llvm-svn: 375102
* Remove \brief commands from doxygen comments.Dmitri Gribenko2019-08-2213-110/+110
| | | | | | | | | | | | | | | | | | | | | | | Summary: We've been running doxygen with the autobrief option for a couple of years now. This makes the \brief markers into our comments redundant. Since they are a visual distraction and we don't want to encourage more \brief markers in new code either, this patch removes them all. Patch produced by for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done [This is analogous to LLVM r331272 and CFE r331834] Subscribers: srhines, nemanjai, javed.absar, kbarton, MaskRay, jkorous, arphaman, jfb, kadircet, jsji, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66578 llvm-svn: 369643
* [clang-tools-extra] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere2019-08-145-6/+6
| | | | | | | | | | Now that we've moved to C++14, we no longer need the llvm::make_unique implementation from STLExtras.h. This patch is a mechanical replacement of (hopefully) all the llvm::make_unique instances across the monorepo. Differential revision: https://reviews.llvm.org/D66259 llvm-svn: 368944
* Simplify with llvm::is_contained. NFCFangrui Song2019-07-131-5/+2
| | | | llvm-svn: 365993
* [clang-tidy] Fix invalid read on destructionNikolai Kosjar2019-06-111-19/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ...in case the clang tidy plugin is linked into the clang binary. Valgrind's memcheck reports: 8949== Invalid read ==8866== Invalid read of size 4 8866== at 0x164D248B: fetch_sub (atomic_base.h:524) 8866== by 0x164D248B: llvm::ThreadSafeRefCountedBase<clang::ast_matchers::internal::DynMatcherInterface>::Release() const (IntrusiveRefCntPtr.h:98) 8866== by 0x164CE16C: llvm::IntrusiveRefCntPtrInfo<clang::ast_matchers::internal::DynMatcherInterface>::release(clang::ast_matchers::internal::DynMatcherInterface*) (IntrusiveRefCntPtr.h:127) 8866== by 0x164C8D5C: llvm::IntrusiveRefCntPtr<clang::ast_matchers::internal::DynMatcherInterface>::release() (IntrusiveRefCntPtr.h:190) 8866== by 0x164C3B87: llvm::IntrusiveRefCntPtr<clang::ast_matchers::internal::DynMatcherInterface>::~IntrusiveRefCntPtr() (IntrusiveRefCntPtr.h:157) 8866== by 0x164BB4F1: clang::ast_matchers::internal::DynTypedMatcher::~DynTypedMatcher() (ASTMatchersInternal.h:341) 8866== by 0x164BB529: clang::ast_matchers::internal::Matcher<clang::QualType>::~Matcher() (ASTMatchersInternal.h:496) 8866== by 0xD7AE614: __cxa_finalize (cxa_finalize.c:83) 8866== by 0x164B3082: ??? (in /d2/llvm/8/qtc/builds/DebugShared/lib/libclangTidyModernizeModule.so.8) 8866== by 0x4010B72: _dl_fini (dl-fini.c:138) 8866== by 0xD7AE040: __run_exit_handlers (exit.c:108) 8866== by 0xD7AE139: exit (exit.c:139) 8866== by 0xD78CB9D: (below main) (libc-start.c:344) 8866== Address 0x19dd9bc8 is 8 bytes inside a block of size 16 free'd 8866== at 0x4C3123B: operator delete(void*) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) 8866== by 0x1469BB99: clang::ast_matchers::internal::(anonymous namespace)::TrueMatcherImpl::~TrueMatcherImpl() (ASTMatchersInternal.cpp:126) 8866== by 0x1469BBC5: llvm::object_deleter<clang::ast_matchers::internal::(anonymous namespace)::TrueMatcherImpl>::call(void*) (ManagedStatic.h:30) 8866== by 0x9ABFF26: llvm::ManagedStaticBase::destroy() const (ManagedStatic.cpp:72) 8866== by 0x9ABFF94: llvm::llvm_shutdown() (ManagedStatic.cpp:84) 8866== by 0x9A65232: llvm::InitLLVM::~InitLLVM() (InitLLVM.cpp:52) 8866== by 0x14B0C8: main (driver.cpp:323) 8866== Block was alloc'd at 8866== at 0x4C3017F: operator new(unsigned long) (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) 8866== by 0x1469BB36: llvm::object_creator<clang::ast_matchers::internal::(anonymous namespace)::TrueMatcherImpl>::call() (ManagedStatic.h:24) 8866== by 0x9ABFD99: llvm::ManagedStaticBase::RegisterManagedStatic(void* (*)(), void (*)(void*)) const (ManagedStatic.cpp:42) 8866== by 0x1469B5DF: llvm::ManagedStatic<clang::ast_matchers::internal::(anonymous namespace)::TrueMatcherImpl, llvm::object_creator<clang::ast_matchers::internal::(anonymous namespace)::TrueMatcherImpl>, llvm::object_deleter<clang::ast_matchers::internal::(anonymous namespace)::TrueMatcherImpl> >::operator*() (ManagedStatic.h:67) 8866== by 0x14698F9D: clang::ast_matchers::internal::DynTypedMatcher::trueMatcher(clang::ast_type_traits::ASTNodeKind) (ASTMatchersInternal.cpp:195) 8866== by 0x164C9D3B: _ZNK5clang12ast_matchers8internal11TrueMatchercvNS1_7MatcherIT_EEINS_8QualTypeEEEv (ASTMatchersInternal.h:1247) 8866== by 0x16501458: __static_initialization_and_destruction_0(int, int) (LoopConvertCheck.cpp:48) 8866== by 0x16501976: _GLOBAL__sub_I_LoopConvertCheck.cpp (LoopConvertCheck.cpp:920) 8866== by 0x4010732: call_init (dl-init.c:72) 8866== by 0x4010732: _dl_init (dl-init.c:119) 8866== by 0x40010C9: ??? (in /lib/x86_64-linux-gnu/ld-2.27.so) Differential Revision: https://reviews.llvm.org/D63129 llvm-svn: 363068
* [clang-tidy] Fix make-unique check to work in C++17 mode.Haojian Wu2019-06-031-3/+12
| | | | | | | | | | | | | | | | | | | | Summary: Previously, we intended to omit the check fix to the case when constructor has any braced-init-list argument. But the HasListInitializedArgument was not correct to handle all cases (Foo(Bar{1, 2}) will return false in C++14 mode). This patch fixes it, corrects the tests, and makes the check to run at C++17 mode. Reviewers: gribozavr Subscribers: xazax.hun, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62736 llvm-svn: 362361
* [Lex] Allow to consume tokens while preprocessingIlya Biryukov2019-05-171-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: By adding a hook to consume all tokens produced by the preprocessor. The intention of this change is to make it possible to consume the expanded tokens without re-runnig the preprocessor with minimal changes to the preprocessor and minimal performance penalty when preprocessing without recording the tokens. The added hook is very low-level and reconstructing the expanded token stream requires more work in the client code, the actual algorithm to collect the tokens using this hook can be found in the follow-up change. Reviewers: rsmith Reviewed By: rsmith Subscribers: eraman, nemanjai, kbarton, jsji, riccibruno, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D59885 llvm-svn: 361007
* [clang-tidy] Recommit r360785 "modernize-loop-convert: impl const cast iter" ↵Don Hinton2019-05-151-5/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | with correct attribution Summary: modernize-loop-convert was not detecting implicit casts to const_iterator as convertible to range-based loops: std::vector<int> vec{1,2,3,4} for(std::vector<int>::const_iterator i = vec.begin(); i != vec.end(); ++i) { } Thanks to Don Hinton for advice. As well, this change adds a note for this check's applicability to code targeting OpenMP prior version 5 as this check will continue breaking compilation with `-fopenmp`. Thanks to Roman Lebedev for pointing this out. Fixes PR#35082 Patch by Torbjörn Klatt! Reviewed By: hintonda Tags: #clang-tools-extra, #clang Differential Revision: https://reviews.llvm.org/D61827 llvm-svn: 360788
* Revert [clang-tidy] modernize-loop-convert: impl const cast iterDon Hinton2019-05-151-0/+5
| | | | | | This reverts r360785 (git commit 42d28be802fe5beab18bc1a27f89894c0a290d44) llvm-svn: 360787
* [clang-tidy] modernize-loop-convert: impl const cast iterDon Hinton2019-05-151-5/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: modernize-loop-convert was not detecting implicit casts to const_iterator as convertible to range-based loops: std::vector<int> vec{1,2,3,4} for(std::vector<int>::const_iterator i = vec.begin(); i != vec.end(); ++i) { } Thanks to Don Hinton for advice. As well, this change adds a note for this check's applicability to code targeting OpenMP prior to version 5 as this check will continue breaking compilation with `-fopenmp`. Thanks to Roman Lebedev for pointing this out. Fixes PR#35082 Reviewed By: hintonda Tags: #clang-tools-extra, #clang Differential Revision: https://reviews.llvm.org/D61827 llvm-svn: 360785
* Removing an unused member variable; NFC.Aaron Ballman2019-05-101-4/+2
| | | | llvm-svn: 360451
* Recommit r360345 with fixes (was reverted in r360348).Aaron Ballman2019-05-104-0/+544
| | | | | | | | Add the modernize-use-trailing-return check to rewrite function signatures to use trailing return types. Patch by Bernhard Manfred Gruber. llvm-svn: 360438
* Revert r360345 and r360346, as they are not passing the testbots.Aaron Ballman2019-05-094-543/+0
| | | | | | http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/48063/steps/test/logs/stdio llvm-svn: 360348
* Add the modernize-use-trailing-return check to rewrite function signatures ↵Aaron Ballman2019-05-094-0/+543
| | | | | | | | to use trailing return types. Patch by Bernhard Manfred Gruber. llvm-svn: 360345
* [clang-tidy] Do not show incorrect fix in modernize-make-uniqueIlya Biryukov2019-05-081-2/+3
| | | | | | | | | | | | | | | | | | Summary: The case when initialize_list hides behind an implicit case was not handled before. Reviewers: aaron.ballman Reviewed By: aaron.ballman Subscribers: xazax.hun, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D61642 llvm-svn: 360231
* Fix up after r360006.Richard Smith2019-05-061-1/+1
| | | | llvm-svn: 360007
* Re-apply r357823 "[Lexer] NFC: Fix an off-by-one bug in getAsCharRange()."Artem Dergachev2019-04-231-0/+1
| | | | | | | | | It now comes with a follow-up fix for the clients of this API in clangd and clang-tidy. Differential Revision: https://reviews.llvm.org/D59977 llvm-svn: 359035
* [clang-tidy] Fix PR28406Alexander Kornienko2019-03-291-7/+10
| | | | | | | | Fix the crash resulting from a careless use of getLocWithOffset. At the beginning of a macro expansion it produces an invalid SourceLocation that causes an assertion failure later on. llvm-svn: 357312
* [clang-tidy] Switch checks to #include "ClangTidyCheck.h"Alexander Kornienko2019-03-2528-28/+28
| | | | llvm-svn: 356892
* [clang-tidy] Move all checks to the new registerPPCallbacks APIAlexander Kornienko2019-03-2210-27/+37
| | | | llvm-svn: 356796
* [clang-tidy] add OverrideMacro to modernize-use-override checkPaul Hoad2019-02-282-20/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The usefulness of **modernize-use-override** can be reduced if you have to live in an environment where you support multiple compilers, some of which sadly are not yet fully C++11 compliant some codebases have to use override as a macro OVERRIDE e.g. ``` // GCC 4.7 supports explicit virtual overrides when C++11 support is enabled. ``` This allows code to be compiled with C++11 compliant compilers and get warnings and errors that clang, MSVC,gcc can give, while still allowing other legacy pre C++11 compilers to compile the code. This can be an important step towards modernizing C++ code whilst living in a legacy codebase. When it comes to clang tidy, the use of the **modernize-use-override** is one of the most useful checks, but the messages reported are inaccurate for that codebase if the standard approach is to use the macros OVERRIDE and/or FINAL. When combined with fix-its that introduce the C++11 override keyword, they become fatal, resulting in the modernize-use-override check being turned off to prevent the introduction of such errors. This revision, allows the possibility for the replacement **override **to be a macro instead, Allowing the clang-tidy check to be run on both pre and post C++11 code, and allowing fix-its to be applied. Reviewers: alexfh, JonasToth, hokein, Eugene.Zelenko, aaron.ballman Reviewed By: alexfh, JonasToth Subscribers: lewmpk, malcolm.parsons, jdoerfert, xazax.hun, cfe-commits, llvm-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D57087 llvm-svn: 355132
* [clang-tidy] added cppcoreguidelines-explicit-virtual-functionsJonas Toth2019-02-282-2/+18
| | | | | | | | | | | | Addresses the bugzilla bug #30397. (https://bugs.llvm.org/show_bug.cgi?id=30397) modernize-use-override suggests that destructors require the override specifier and the CPP core guidelines do not recommend this. Patch by lewmpk. Differential Revision: https://reviews.llvm.org/D58731 llvm-svn: 355093
* [clang-tidy] Don't use assignment for value-initialized enumsMalcolm Parsons2019-02-081-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The modernize-use-default-member-init check crashes when trying to create an assignment value for a value-initialized enum because it isn't a BuiltinType. An enum cannot be initialized by assigning 0 to it unless a cast is added. It could be initialized with an enumerator with the value 0, but there might not be one. Avoid these issues by ignoring the UseAssignment setting for value-initialized enums. Fixes PR35050. Reviewers: aaron.ballman, alexfh, JonasToth Reviewed By: JonasToth Subscribers: xazax.hun, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D57852 llvm-svn: 353554
* [clang-tidy] Fixed a std::bind() transformationJonas Toth2019-02-071-1/+1
| | | | | | | | There was an extra semicolon that was somehow working in some contexts. Patch by oleg.smolsky. llvm-svn: 353389
* [clang-tidy] modernize-avoid-c-arrays: avoid main function (PR40604)Roman Lebedev2019-02-061-1/+8
| | | | | | | | | | | | | | | | | | | | | Summary: The check should ignore the main function, the program entry point. It is not possible to use `std::array<>` for the `argv`. The alternative is to use `char** argv`. Fixes [[ https://bugs.llvm.org/show_bug.cgi?id=40604 | PR40604 ]] Reviewers: JonasToth, aaron.ballman Reviewed By: aaron.ballman Subscribers: xazax.hun, hans, cfe-commits Tags: #clang-tools-extra, #clang Differential Revision: https://reviews.llvm.org/D57787 llvm-svn: 353327
* [clang-tidy] Handle unions with existing default-member-initMalcolm Parsons2019-02-041-1/+1
| | | | | | | | | | | | | | | | | | | | Summary: clang-tidy's modernize-use-default-member-init was crashing for unions with an existing default member initializer. Fixes PR40492 Reviewers: aaron.ballman, alexfh, JonasToth Reviewed By: JonasToth Subscribers: JonasToth, riccibruno, xazax.hun, cfe-commits Tags: #clang, #clang-tools-extra Differential Revision: https://reviews.llvm.org/D57665 llvm-svn: 353092
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-1963-252/+189
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* [clang-tidy] Fix case of local variables in modernize-use-nodiscard checkerJonas Toth2019-01-101-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Correct the case of the local variables.. Rational: I want to be able to run clang-tidy on new clang-tidy checker code prior to creating a review (to demonstrate we should dog food our own tools during development, not my suggestion but @Eugene.Zelenko) To this end I am running the following in a script, prior to make a change. ``` tidy: @for source in $$(git status -suno | grep ".cpp$$" | cut -c4-) ;\ do \ clang-tidy -quiet $$source -- $(TIDY_FLAGS);\ done ``` I then want to go through the checkers and see which checkers most closely match the review style of the reviewers ``` --- Checks: ' -clang-diagnostic-*, readability-identifier-naming, llvm-header-guard ' WarningsAsErrors: '' HeaderFilterRegex: '' AnalyzeTemporaryDtors: false FormatStyle: LLVM CheckOptions: - key: readability-identifier-naming.IgnoreFailedSplit value: '0' - key: readability-identifier-naming.VariableCase value: 'CamelCase' - key: readability-identifier-naming.LocalVariableCase value: 'CamelCase' ... ``` Unfortunately in doing so, I have identified that my previous review {D55433} it violates what looks like to be the convention of local variables being in CamelCase. Sending this small review in the hope it can be corrected. Patch by MyDeveloperDay. Reviewers: JonasToth, Eugene.Zelenko Reviewed By: JonasToth Subscribers: xazax.hun, Eugene.Zelenko Differential Revision: https://reviews.llvm.org/D56536 llvm-svn: 350814
* [clang-tidy] Adding a new modernize use nodiscard checkerJonas Toth2019-01-094-0/+199
| | | | | | | | | | | | | | | | | | Summary: Adds a checker to clang-tidy to warn when a non void const member function, taking only parameters passed by value or const reference could be marked as '[[nodiscard]]' Patch by MyDeveloperDay. Reviewers: alexfh, stephenkelly, curdeius, aaron.ballman, hokein, JonasToth Reviewed By: curdeius, JonasToth Subscribers: Eugene.Zelenko, lefticus, lebedev.ri, mgorny, xazax.hun, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D55433 llvm-svn: 350760
* [clang-tidy] No warning for auto new expression in smart checkHaojian Wu2018-11-261-0/+3
| | | | | | | | | | | | Summary: The fix for `auto` new expression is illegal. Reviewers: aaron.ballman Subscribers: xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D54832 llvm-svn: 347551
* [clang-tidy] Don't generate incorrect fixes for class with deleted copy ↵Haojian Wu2018-11-261-0/+13
| | | | | | | | | | | | | | | | | constructor in smart_ptr check. Summary: The fix for aggregate initialization (`std::make_unique<Foo>(Foo {1, 2})` needs to see Foo copy constructor, otherwise we will have a compiler error. So we only emit the check warning. Reviewers: JonasToth, aaron.ballman Subscribers: xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D54745 llvm-svn: 347537
OpenPOWER on IntegriCloud