aboutsummaryrefslogtreecommitdiff
path: root/clang-tidy/modernize
AgeCommit message (Collapse)Author
2019-10-17clang-tidy - silence static analyzer getAs<> null dereference warnings. NFCI.Simon Pilgrim
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. git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@375102 91177308-0d34-0410-b5e6-96231b3b80d8
2019-08-22Remove \brief commands from doxygen comments.Dmitri Gribenko
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 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@369643 91177308-0d34-0410-b5e6-96231b3b80d8
2019-08-14[clang-tools-extra] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere
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 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@368944 91177308-0d34-0410-b5e6-96231b3b80d8
2019-07-13Simplify with llvm::is_contained. NFCFangrui Song
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@365993 91177308-0d34-0410-b5e6-96231b3b80d8
2019-06-11[clang-tidy] Fix invalid read on destructionNikolai Kosjar
...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 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@363068 91177308-0d34-0410-b5e6-96231b3b80d8
2019-06-03[clang-tidy] Fix make-unique check to work in C++17 mode.Haojian Wu
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 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@362361 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-17[Lex] Allow to consume tokens while preprocessingIlya Biryukov
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 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@361007 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-15[clang-tidy] Recommit r360785 "modernize-loop-convert: impl const cast iter" ↵Don Hinton
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 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@360788 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-15Revert [clang-tidy] modernize-loop-convert: impl const cast iterDon Hinton
This reverts r360785 (git commit 42d28be802fe5beab18bc1a27f89894c0a290d44) git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@360787 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-15[clang-tidy] modernize-loop-convert: impl const cast iterDon Hinton
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 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@360785 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-10Removing an unused member variable; NFC.Aaron Ballman
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@360451 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-10Recommit r360345 with fixes (was reverted in r360348).Aaron Ballman
Add the modernize-use-trailing-return check to rewrite function signatures to use trailing return types. Patch by Bernhard Manfred Gruber. git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@360438 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-09Revert r360345 and r360346, as they are not passing the testbots.Aaron Ballman
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/48063/steps/test/logs/stdio git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@360348 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-09Add the modernize-use-trailing-return check to rewrite function signatures ↵Aaron Ballman
to use trailing return types. Patch by Bernhard Manfred Gruber. git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@360345 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-08[clang-tidy] Do not show incorrect fix in modernize-make-uniqueIlya Biryukov
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 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@360231 91177308-0d34-0410-b5e6-96231b3b80d8
2019-05-06Fix up after r360006.Richard Smith
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@360007 91177308-0d34-0410-b5e6-96231b3b80d8
2019-04-23Re-apply r357823 "[Lexer] NFC: Fix an off-by-one bug in getAsCharRange()."Artem Dergachev
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 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@359035 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-29[clang-tidy] Fix PR28406Alexander Kornienko
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. git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@357312 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-25[clang-tidy] Switch checks to #include "ClangTidyCheck.h"Alexander Kornienko
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@356892 91177308-0d34-0410-b5e6-96231b3b80d8
2019-03-22[clang-tidy] Move all checks to the new registerPPCallbacks APIAlexander Kornienko
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@356796 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-28[clang-tidy] add OverrideMacro to modernize-use-override checkPaul Hoad
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 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@355132 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-28[clang-tidy] added cppcoreguidelines-explicit-virtual-functionsJonas Toth
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 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@355093 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-08[clang-tidy] Don't use assignment for value-initialized enumsMalcolm Parsons
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 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@353554 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-07[clang-tidy] Fixed a std::bind() transformationJonas Toth
There was an extra semicolon that was somehow working in some contexts. Patch by oleg.smolsky. git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@353389 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-06[clang-tidy] modernize-avoid-c-arrays: avoid main function (PR40604)Roman Lebedev
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 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@353327 91177308-0d34-0410-b5e6-96231b3b80d8
2019-02-04[clang-tidy] Handle unions with existing default-member-initMalcolm Parsons
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 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@353092 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-19Update the file headers across all of the LLVM projects in the monorepoChandler Carruth
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. git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@351636 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-10[clang-tidy] Fix case of local variables in modernize-use-nodiscard checkerJonas Toth
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 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@350814 91177308-0d34-0410-b5e6-96231b3b80d8
2019-01-09[clang-tidy] Adding a new modernize use nodiscard checkerJonas Toth
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 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@350760 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-26[clang-tidy] No warning for auto new expression in smart checkHaojian Wu
Summary: The fix for `auto` new expression is illegal. Reviewers: aaron.ballman Subscribers: xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D54832 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@347551 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-26[clang-tidy] Don't generate incorrect fixes for class with deleted copy ↵Haojian Wu
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 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@347537 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-25A bit of AST matcher cleanup, NFC.Alexander Kornienko
Removed the uses of the allOf() matcher inside node matchers that are implicit allOf(). Replaced uses of allOf() with the explicit node matcher where it makes matchers more readable. Replace anyOf(hasName(), hasName(), ...) with the more efficient and readable hasAnyName(). git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@347520 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-22[clang-tidy] Ignore template instantiations in modernize-use-usingAlexander Kornienko
The test I'm adding passes without the change due to the deduplication logic in ClangTidyDiagnosticConsumer::take(). However this bug manifests in our internal integration with clang-tidy. I've verified the fix by locally changing LessClangTidyError to consider replacements. git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@347470 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-20[clang-tidy] Don't generate incorrect fixes for class constructed from ↵Haojian Wu
list-initialized arguments Summary: Currently the smart_ptr check (modernize-make-unique) generates the fixes that cannot compile for cases like below -- because brace list can not be deduced in `make_unique`. ``` struct Bar { int a, b; }; struct Foo { Foo(Bar); }; auto foo = std::unique_ptr<Foo>(new Foo({1, 2})); ``` Reviewers: aaron.ballman Subscribers: xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D54704 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@347315 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-15[clang-tidy] Update checks to play nicely with limited traversal scope added ↵Sam McCall
in r346847 Summary: (See D54204 for original review) Reviewers: hokein Subscribers: xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D54579 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@346961 91177308-0d34-0410-b5e6-96231b3b80d8
2018-11-14[clang-tidy] Avoid C arrays checkRoman Lebedev
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 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@346835 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-18[clang-tidy] Ignore a case where the fix of make_unique check introduces ↵Haojian Wu
side effect. Summary: Previously, ptr.reset(new char[5]) will be replaced with `p = make_unique<char[]>(5)`, the fix has side effect -- doing default initialization, it may cause performace regression (we are bitten by this rececntly) The check should be conservative for these cases. Reviewers: alexfh Subscribers: xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D53377 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@344733 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-15[Fixed Point Arithmetic] Fix for clang-tools-extra warningLeonard Chan
Fix for warnings generated on unhandled enum value `STK_FixedPoint`. Differential Revision: https://reviews.llvm.org/D53299 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@344549 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-15added fixLeonard Chan
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@344548 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-13[clang-tidy] add IgnoreMacros option to modernize-use-equals-deleteMiklos Vajna
And also enable it by default to be consistent with e.g. modernize-use-using. This improves consistency inside the check itself as well: both checks are now disabled in macros by default. This helps e.g. when running this check on client code where the macro is provided by the system, so there is no easy way to modify it. Reviewed By: alexfh Differential Revision: https://reviews.llvm.org/D53217 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@344440 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-09[clang-tidy] Fix handling of parens around new expressions in ↵Alexander Kornienko
make_<smartptr> checks. Summary: Extra parentheses around a new expression result in incorrect code after applying fixes. Reviewers: hokein Reviewed By: hokein Subscribers: xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D52989 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@344058 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-09[clang-tidy] NFC fix warnings from missing bracesJonas Toth
The std::array create multiple StringRef but did not wrap them in braces. Some compilers warned for that. Adding the braces is not possible and result in a compilation error. This commit changes the array to vector which works without warning. git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@344046 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-06Revert rL343916: Fix -Wmissing-braces warning. NFCI.Simon Pilgrim
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@343917 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-06Fix -Wmissing-braces warning. NFCI.Simon Pilgrim
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@343916 91177308-0d34-0410-b5e6-96231b3b80d8
2018-10-05[clang-tidy] Replace deprecated std::ios_base aliasesJonas Toth
This check warns the uses of the deprecated member types of std::ios_base and replaces those that have a non-deprecated equivalent. Patch by andobence! Reviewd by: alexfh Revision ID: https://reviews.llvm.org/D51332 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@343848 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-25[clang-tidy] Add modernize-concat-nested-namespaces checkJonas Toth
Summary: Finds instances of namespaces concatenated using explicit syntax, such as `namespace a { namespace b { [...] }}` and offers fix to glue it to `namespace a::b { [...] }`. Properly handles `inline` and unnamed namespaces. ~~Also, detects empty blocks in nested namespaces and offers to remove them.~~ Test with common use cases included. I ran the check against entire llvm repository. Except for expected `nested namespace definitions only available with -std=c++17 or -std=gnu++17` warnings I noticed no issues when the check was performed. Example: ``` namespace a { namespace b { void test(); }} ``` can become ``` namespace a::b { void test(); } ``` Patch by wgml! Reviewers: alexfh, aaron.ballman, hokein Reviewed By: aaron.ballman Subscribers: JonasToth, Eugene.Zelenko, lebedev.ri, mgorny, xazax.hun, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D52136 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@343000 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-20[Clang-tidy] Alphabetical sort of files/checks. Add space after clang-tidy ↵Eugene Zelenko
in source code headers. git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@342601 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-17[Clang-Tidy: modernize] Fix for modernize-redundant-void-arg: complains ↵Idriss Riouak
about variable cast to void Summary: Hello, i would like to suggest a fix for one of the checks in clang-tidy.The bug was reported in https://bugs.llvm.org/show_bug.cgi?id=32575 where you can find more information. For example: ``` template <typename T0> struct S { template <typename T> void g() const { int a; (void)a; } }; void f() { S<int>().g<int>(); } ``` this piece of code should not trigger any warning by the check modernize-redundant-void-arg but when we execute the following command ``` clang_tidy -checks=-*,modernize-redundant-void-arg test.cpp -- -std=c++11 ``` we obtain the following warning: /Users/eco419/Desktop/clang-tidy.project/void-redundand_2/test.cpp:6:6: warning: redundant void argument list in function declaration [modernize-redundant-void-arg] (void)a; ^~~~ Reviewers: aaron.ballman, hokein, alexfh, JonasToth Reviewed By: aaron.ballman, JonasToth Subscribers: JonasToth, lebedev.ri, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D52135 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@342388 91177308-0d34-0410-b5e6-96231b3b80d8
2018-09-14[modernize-use-transparent-functors] TypeLocs can be implicitly created, ↵Benjamin Kramer
don't crash when encountering those. git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@342252 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-10[clang-tidy: modernize] modernize-redundant-void-arg crashes when a function ↵Alexander Kornienko
body is in a macro Fixes https://bugs.llvm.org/show_bug.cgi?id=28406 Patch by IdrissRio. Differential revision: https://reviews.llvm.org/D49800 git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@339433 91177308-0d34-0410-b5e6-96231b3b80d8