mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-28 18:54:55 +00:00
[clang-tidy] Rename modernize-use-default to modernize-use-equals-default
Reviewers: angelgarcia, aaron.ballman, alexfh Subscribers: JDevlieghere, Prazek, mgorny, cfe-commits Differential Revision: https://reviews.llvm.org/D26511 llvm-svn: 288375
This commit is contained in:
parent
55082cddef
commit
bcf23661d0
@ -226,8 +226,13 @@ def update_checks_list(clang_tidy_path):
|
||||
def format_link(doc_file):
|
||||
check_name = doc_file.replace('.rst', '')
|
||||
with open(os.path.join(docs_dir, doc_file), 'r') as doc:
|
||||
content = doc.read()
|
||||
match = re.search('.*:orphan:.*', content)
|
||||
if match:
|
||||
return ''
|
||||
|
||||
match = re.search('.*:http-equiv=refresh: \d+;URL=(.*).html.*',
|
||||
doc.read())
|
||||
content)
|
||||
if match:
|
||||
return ' %(check)s (redirects to %(target)s) <%(check)s>\n' % {
|
||||
'check': check_name,
|
||||
|
@ -16,8 +16,8 @@ add_clang_library(clangTidyModernizeModule
|
||||
ShrinkToFitCheck.cpp
|
||||
UseAutoCheck.cpp
|
||||
UseBoolLiteralsCheck.cpp
|
||||
UseDefaultCheck.cpp
|
||||
UseEmplaceCheck.cpp
|
||||
UseEqualsDefaultCheck.cpp
|
||||
UseEqualsDeleteCheck.cpp
|
||||
UseNullptrCheck.cpp
|
||||
UseOverrideCheck.cpp
|
||||
|
@ -22,8 +22,8 @@
|
||||
#include "ShrinkToFitCheck.h"
|
||||
#include "UseAutoCheck.h"
|
||||
#include "UseBoolLiteralsCheck.h"
|
||||
#include "UseDefaultCheck.h"
|
||||
#include "UseEmplaceCheck.h"
|
||||
#include "UseEqualsDefaultCheck.h"
|
||||
#include "UseEqualsDeleteCheck.h"
|
||||
#include "UseNullptrCheck.h"
|
||||
#include "UseOverrideCheck.h"
|
||||
@ -56,8 +56,8 @@ public:
|
||||
CheckFactories.registerCheck<UseAutoCheck>("modernize-use-auto");
|
||||
CheckFactories.registerCheck<UseBoolLiteralsCheck>(
|
||||
"modernize-use-bool-literals");
|
||||
CheckFactories.registerCheck<UseDefaultCheck>("modernize-use-default");
|
||||
CheckFactories.registerCheck<UseEmplaceCheck>("modernize-use-emplace");
|
||||
CheckFactories.registerCheck<UseEqualsDefaultCheck>("modernize-use-equals-default");
|
||||
CheckFactories.registerCheck<UseEqualsDeleteCheck>(
|
||||
"modernize-use-equals-delete");
|
||||
CheckFactories.registerCheck<UseNullptrCheck>("modernize-use-nullptr");
|
||||
|
@ -1,4 +1,4 @@
|
||||
//===--- UseDefaultCheck.cpp - clang-tidy----------------------------------===//
|
||||
//===--- UseEqualsDefaultCheck.cpp - clang-tidy----------------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
@ -7,7 +7,7 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "UseDefaultCheck.h"
|
||||
#include "UseEqualsDefaultCheck.h"
|
||||
#include "clang/AST/ASTContext.h"
|
||||
#include "clang/ASTMatchers/ASTMatchFinder.h"
|
||||
#include "clang/Lex/Lexer.h"
|
||||
@ -197,7 +197,7 @@ static bool bodyEmpty(const ASTContext *Context, const CompoundStmt *Body) {
|
||||
return !Invalid && std::strspn(Text.data(), " \t\r\n") == Text.size();
|
||||
}
|
||||
|
||||
void UseDefaultCheck::registerMatchers(MatchFinder *Finder) {
|
||||
void UseEqualsDefaultCheck::registerMatchers(MatchFinder *Finder) {
|
||||
if (getLangOpts().CPlusPlus) {
|
||||
// Destructor.
|
||||
Finder->addMatcher(cxxDestructorDecl(isDefinition()).bind(SpecialFunction),
|
||||
@ -229,7 +229,7 @@ void UseDefaultCheck::registerMatchers(MatchFinder *Finder) {
|
||||
}
|
||||
}
|
||||
|
||||
void UseDefaultCheck::check(const MatchFinder::MatchResult &Result) {
|
||||
void UseEqualsDefaultCheck::check(const MatchFinder::MatchResult &Result) {
|
||||
std::string SpecialFunctionName;
|
||||
|
||||
// Both CXXConstructorDecl and CXXDestructorDecl inherit from CXXMethodDecl.
|
@ -1,4 +1,4 @@
|
||||
//===--- UseDefaultCheck.h - clang-tidy--------------------------*- C++ -*-===//
|
||||
//===--- UseEqualsDefaultCheck.h - clang-tidy--------------------------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
@ -7,8 +7,8 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_USE_DEFAULT_H
|
||||
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_USE_DEFAULT_H
|
||||
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_USE_EQUALS_DEFAULT_H
|
||||
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_USE_EQUALS_DEFAULT_H
|
||||
|
||||
#include "../ClangTidy.h"
|
||||
|
||||
@ -34,10 +34,10 @@ namespace modernize {
|
||||
/// \endcode
|
||||
///
|
||||
/// For the user-facing documentation see:
|
||||
/// http://clang.llvm.org/extra/clang-tidy/checks/modernize-use-default.html
|
||||
class UseDefaultCheck : public ClangTidyCheck {
|
||||
/// http://clang.llvm.org/extra/clang-tidy/checks/modernize-use-equals-default.html
|
||||
class UseEqualsDefaultCheck : public ClangTidyCheck {
|
||||
public:
|
||||
UseDefaultCheck(StringRef Name, ClangTidyContext *Context)
|
||||
UseEqualsDefaultCheck(StringRef Name, ClangTidyContext *Context)
|
||||
: ClangTidyCheck(Name, Context) {}
|
||||
void registerMatchers(ast_matchers::MatchFinder *Finder) override;
|
||||
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
|
||||
@ -47,4 +47,4 @@ public:
|
||||
} // namespace tidy
|
||||
} // namespace clang
|
||||
|
||||
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_USE_DEFAULT_H
|
||||
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_USE_EQUALS_DEFAULT_H
|
@ -91,6 +91,9 @@ Improvements to clang-tidy
|
||||
<http://clang.llvm.org/extra/clang-tidy/checks/modernize-use-auto.html>`_ check
|
||||
now warns about variable declarations that are initialized with a cast.
|
||||
|
||||
- The modernize-use-default check has been renamed to `modernize-use-equals-default
|
||||
<http://clang.llvm.org/extra/clang-tidy/checks/modernize-use-equals-default.html>`_.
|
||||
|
||||
- New `modernize-use-equals-delete
|
||||
<http://clang.llvm.org/extra/clang-tidy/checks/modernize-use-equals-delete.html>`_ check
|
||||
|
||||
|
@ -18,7 +18,7 @@ Clang-Tidy Checks
|
||||
cert-err61-cpp (redirects to misc-throw-by-value-catch-by-reference) <cert-err61-cpp>
|
||||
cert-fio38-c (redirects to misc-non-copyable-objects) <cert-fio38-c>
|
||||
cert-flp30-c
|
||||
cert-msc30-c (redirects to cert-limited-randomness) <cert-msc30-c>
|
||||
cert-msc30-c (redirects to cert-msc50-cpp) <cert-msc30-c>
|
||||
cert-msc50-cpp
|
||||
cert-oop11-cpp (redirects to misc-move-constructor-init) <cert-oop11-cpp>
|
||||
cppcoreguidelines-interfaces-global-init
|
||||
@ -109,8 +109,8 @@ Clang-Tidy Checks
|
||||
modernize-shrink-to-fit
|
||||
modernize-use-auto
|
||||
modernize-use-bool-literals
|
||||
modernize-use-default
|
||||
modernize-use-emplace
|
||||
modernize-use-equals-default
|
||||
modernize-use-equals-delete
|
||||
modernize-use-nullptr
|
||||
modernize-use-override
|
||||
|
@ -1,28 +1,10 @@
|
||||
:orphan:
|
||||
.. title:: clang-tidy - modernize-use-default
|
||||
.. meta::
|
||||
:http-equiv=refresh: 5;URL=modernize-use-equals-default.html
|
||||
|
||||
modernize-use-default
|
||||
=====================
|
||||
|
||||
This check replaces default bodies of special member functions with ``=
|
||||
default;``. The explicitly defaulted function declarations enable more
|
||||
opportunities in optimization, because the compiler might treat explicitly
|
||||
defaulted functions as trivial.
|
||||
|
||||
.. code-block:: c++
|
||||
|
||||
struct A {
|
||||
A() {}
|
||||
~A();
|
||||
};
|
||||
A::~A() {}
|
||||
|
||||
// becomes
|
||||
|
||||
struct A {
|
||||
A() = default;
|
||||
~A();
|
||||
};
|
||||
A::~A() = default;
|
||||
|
||||
.. note::
|
||||
Move-constructor and move-assignment operator are not supported yet.
|
||||
This check has been renamed to
|
||||
`modernize-use-equals-default <modernize-use-equals-default.html>`_.
|
||||
|
@ -0,0 +1,28 @@
|
||||
.. title:: clang-tidy - modernize-use-equals-default
|
||||
|
||||
modernize-use-equals-default
|
||||
============================
|
||||
|
||||
This check replaces default bodies of special member functions with ``=
|
||||
default;``. The explicitly defaulted function declarations enable more
|
||||
opportunities in optimization, because the compiler might treat explicitly
|
||||
defaulted functions as trivial.
|
||||
|
||||
.. code-block:: c++
|
||||
|
||||
struct A {
|
||||
A() {}
|
||||
~A();
|
||||
};
|
||||
A::~A() {}
|
||||
|
||||
// becomes
|
||||
|
||||
struct A {
|
||||
A() = default;
|
||||
~A();
|
||||
};
|
||||
A::~A() = default;
|
||||
|
||||
.. note::
|
||||
Move-constructor and move-assignment operator are not supported yet.
|
@ -1,4 +1,4 @@
|
||||
// RUN: %check_clang_tidy %s modernize-use-default %t -- -- -std=c++11 -fno-delayed-template-parsing -fexceptions
|
||||
// RUN: %check_clang_tidy %s modernize-use-equals-default %t -- -- -std=c++11 -fno-delayed-template-parsing -fexceptions
|
||||
|
||||
// Out of line definition.
|
||||
struct OL {
|
||||
@ -7,13 +7,13 @@ struct OL {
|
||||
int Field;
|
||||
};
|
||||
OL::OL(const OL &Other) : Field(Other.Field) {}
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use '= default' to define a trivial copy constructor [modernize-use-default]
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use '= default' to define a trivial copy constructor [modernize-use-equals-default]
|
||||
// CHECK-FIXES: OL::OL(const OL &Other) = default;
|
||||
OL &OL::operator=(const OL &Other) {
|
||||
Field = Other.Field;
|
||||
return *this;
|
||||
}
|
||||
// CHECK-MESSAGES: :[[@LINE-4]]:9: warning: use '= default' to define a trivial copy-assignment operator [modernize-use-default]
|
||||
// CHECK-MESSAGES: :[[@LINE-4]]:9: warning: use '= default' to define a trivial copy-assignment operator [modernize-use-equals-default]
|
||||
// CHECK-FIXES: OL &OL::operator=(const OL &Other) = default;
|
||||
|
||||
// Inline.
|
@ -1,4 +1,4 @@
|
||||
// RUN: clang-tidy %s -checks=-*,modernize-use-default -- -std=c++11 -fdelayed-template-parsing -fexceptions | count 0
|
||||
// RUN: clang-tidy %s -checks=-*,modernize-use-equals-default -- -std=c++11 -fdelayed-template-parsing -fexceptions | count 0
|
||||
// Note: this test expects no diagnostics, but FileCheck cannot handle that,
|
||||
// hence the use of | count 0.
|
||||
|
@ -1,4 +1,4 @@
|
||||
// RUN: %check_clang_tidy %s modernize-use-default %t -- -- -std=c++11 -fno-delayed-template-parsing -fexceptions
|
||||
// RUN: %check_clang_tidy %s modernize-use-equals-default %t -- -- -std=c++11 -fno-delayed-template-parsing -fexceptions
|
||||
|
||||
// Out of line definition.
|
||||
class OL {
|
||||
@ -8,10 +8,10 @@ public:
|
||||
};
|
||||
|
||||
OL::OL() {}
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use '= default' to define a trivial default constructor [modernize-use-default]
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use '= default' to define a trivial default constructor [modernize-use-equals-default]
|
||||
// CHECK-FIXES: OL::OL() = default;
|
||||
OL::~OL() {}
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use '= default' to define a trivial destructor [modernize-use-default]
|
||||
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use '= default' to define a trivial destructor [modernize-use-equals-default]
|
||||
// CHECK-FIXES: OL::~OL() = default;
|
||||
|
||||
// Inline definitions.
|
Loading…
Reference in New Issue
Block a user