[clang-tools-extra] r319183 - [clang-tidy] Move more checks from misc- to performance-

Alexander Kornienko via cfe-commits cfe-commits at lists.llvm.org
Tue Nov 28 08:41:03 PST 2017


Author: alexfh
Date: Tue Nov 28 08:41:03 2017
New Revision: 319183

URL: http://llvm.org/viewvc/llvm-project?rev=319183&view=rev
Log:
[clang-tidy] Move more checks from misc- to performance-

Summary:
rename_check.py misc-move-const-arg performance-move-const-arg
rename_check.py misc-noexcept-move-constructor performance-noexcept-move-constructor

Reviewers: hokein, xazax.hun

Reviewed By: xazax.hun

Subscribers: rnkovacs, klimek, mgorny, xazax.hun, cfe-commits

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

Added:
    clang-tools-extra/trunk/clang-tidy/performance/MoveConstArgCheck.cpp
      - copied, changed from r319174, clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp
    clang-tools-extra/trunk/clang-tidy/performance/MoveConstArgCheck.h
      - copied, changed from r319174, clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.h
    clang-tools-extra/trunk/clang-tidy/performance/NoexceptMoveConstructorCheck.cpp
      - copied, changed from r319174, clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveConstructorCheck.cpp
    clang-tools-extra/trunk/clang-tidy/performance/NoexceptMoveConstructorCheck.h
      - copied, changed from r319174, clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveConstructorCheck.h
    clang-tools-extra/trunk/docs/clang-tidy/checks/performance-move-const-arg.rst
      - copied, changed from r319174, clang-tools-extra/trunk/docs/clang-tidy/checks/misc-move-const-arg.rst
    clang-tools-extra/trunk/docs/clang-tidy/checks/performance-noexcept-move-constructor.rst
      - copied, changed from r319174, clang-tools-extra/trunk/docs/clang-tidy/checks/misc-noexcept-move-constructor.rst
    clang-tools-extra/trunk/test/clang-tidy/performance-move-const-arg-trivially-copyable.cpp
      - copied, changed from r319174, clang-tools-extra/trunk/test/clang-tidy/misc-move-const-arg-trivially-copyable.cpp
    clang-tools-extra/trunk/test/clang-tidy/performance-move-const-arg.cpp
      - copied, changed from r319174, clang-tools-extra/trunk/test/clang-tidy/misc-move-const-arg.cpp
    clang-tools-extra/trunk/test/clang-tidy/performance-noexcept-move-constructor.cpp
      - copied, changed from r319174, clang-tools-extra/trunk/test/clang-tidy/misc-noexcept-move-constructor.cpp
Removed:
    clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp
    clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.h
    clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveConstructorCheck.cpp
    clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveConstructorCheck.h
    clang-tools-extra/trunk/docs/clang-tidy/checks/misc-move-const-arg.rst
    clang-tools-extra/trunk/docs/clang-tidy/checks/misc-noexcept-move-constructor.rst
    clang-tools-extra/trunk/test/clang-tidy/misc-move-const-arg-trivially-copyable.cpp
    clang-tools-extra/trunk/test/clang-tidy/misc-move-const-arg.cpp
    clang-tools-extra/trunk/test/clang-tidy/misc-noexcept-move-constructor.cpp
Modified:
    clang-tools-extra/trunk/clang-tidy/hicpp/CMakeLists.txt
    clang-tools-extra/trunk/clang-tidy/hicpp/HICPPTidyModule.cpp
    clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
    clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
    clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp
    clang-tools-extra/trunk/clang-tidy/performance/CMakeLists.txt
    clang-tools-extra/trunk/clang-tidy/performance/PerformanceTidyModule.cpp
    clang-tools-extra/trunk/docs/ReleaseNotes.rst
    clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-move-const-arg.rst
    clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
    clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value.cpp

Modified: clang-tools-extra/trunk/clang-tidy/hicpp/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/hicpp/CMakeLists.txt?rev=319183&r1=319182&r2=319183&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/hicpp/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/hicpp/CMakeLists.txt Tue Nov 28 08:41:03 2017
@@ -17,6 +17,7 @@ add_clang_library(clangTidyHICPPModule
   clangTidyGoogleModule
   clangTidyMiscModule
   clangTidyModernizeModule
+  clangTidyPerformanceModule
   clangTidyReadabilityModule
   clangTidyUtils
   )

Modified: clang-tools-extra/trunk/clang-tidy/hicpp/HICPPTidyModule.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/hicpp/HICPPTidyModule.cpp?rev=319183&r1=319182&r2=319183&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/hicpp/HICPPTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/hicpp/HICPPTidyModule.cpp Tue Nov 28 08:41:03 2017
@@ -18,9 +18,7 @@
 #include "../cppcoreguidelines/SpecialMemberFunctionsCheck.h"
 #include "../google/DefaultArgumentsCheck.h"
 #include "../google/ExplicitConstructorCheck.h"
-#include "../misc/MoveConstantArgumentCheck.h"
 #include "../misc/NewDeleteOverloadsCheck.h"
-#include "../misc/NoexceptMoveConstructorCheck.h"
 #include "../misc/StaticAssertCheck.h"
 #include "../misc/UndelegatedConstructor.h"
 #include "../modernize/DeprecatedHeadersCheck.h"
@@ -31,6 +29,8 @@
 #include "../modernize/UseNoexceptCheck.h"
 #include "../modernize/UseNullptrCheck.h"
 #include "../modernize/UseOverrideCheck.h"
+#include "../performance/MoveConstArgCheck.h"
+#include "../performance/NoexceptMoveConstructorCheck.h"
 #include "../readability/BracesAroundStatementsCheck.h"
 #include "../readability/FunctionSizeCheck.h"
 #include "../readability/IdentifierNamingCheck.h"
@@ -63,11 +63,11 @@ public:
         "hicpp-invalid-access-moved");
     CheckFactories.registerCheck<cppcoreguidelines::ProTypeMemberInitCheck>(
         "hicpp-member-init");
-    CheckFactories.registerCheck<misc::MoveConstantArgumentCheck>(
+    CheckFactories.registerCheck<performance::MoveConstArgCheck>(
         "hicpp-move-const-arg");
     CheckFactories.registerCheck<misc::NewDeleteOverloadsCheck>(
         "hicpp-new-delete-operators");
-    CheckFactories.registerCheck<misc::NoexceptMoveConstructorCheck>(
+    CheckFactories.registerCheck<performance::NoexceptMoveConstructorCheck>(
         "hicpp-noexcept-move");
     CheckFactories
         .registerCheck<cppcoreguidelines::ProBoundsArrayToPointerDecayCheck>(

Modified: clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt?rev=319183&r1=319182&r2=319183&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt Tue Nov 28 08:41:03 2017
@@ -11,9 +11,7 @@ add_clang_library(clangTidyMiscModule
   MacroRepeatedSideEffectsCheck.cpp
   MiscTidyModule.cpp
   MisplacedWideningCastCheck.cpp
-  MoveConstantArgumentCheck.cpp
   NewDeleteOverloadsCheck.cpp
-  NoexceptMoveConstructorCheck.cpp
   NonCopyableObjects.cpp
   RedundantExpressionCheck.cpp
   SizeofContainerCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp?rev=319183&r1=319182&r2=319183&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp Tue Nov 28 08:41:03 2017
@@ -18,9 +18,7 @@
 #include "MacroRepeatedSideEffectsCheck.h"
 #include "MisplacedConstCheck.h"
 #include "MisplacedWideningCastCheck.h"
-#include "MoveConstantArgumentCheck.h"
 #include "NewDeleteOverloadsCheck.h"
-#include "NoexceptMoveConstructorCheck.h"
 #include "NonCopyableObjects.h"
 #include "RedundantExpressionCheck.h"
 #include "SizeofContainerCheck.h"
@@ -67,12 +65,8 @@ public:
         "misc-macro-repeated-side-effects");
     CheckFactories.registerCheck<MisplacedWideningCastCheck>(
         "misc-misplaced-widening-cast");
-    CheckFactories.registerCheck<MoveConstantArgumentCheck>(
-        "misc-move-const-arg");
     CheckFactories.registerCheck<NewDeleteOverloadsCheck>(
         "misc-new-delete-overloads");
-    CheckFactories.registerCheck<NoexceptMoveConstructorCheck>(
-        "misc-noexcept-move-constructor");
     CheckFactories.registerCheck<NonCopyableObjectsCheck>(
         "misc-non-copyable-objects");
     CheckFactories.registerCheck<RedundantExpressionCheck>(

Removed: clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp?rev=319182&view=auto
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp (removed)
@@ -1,122 +0,0 @@
-//===--- MoveConstantArgumentCheck.cpp - clang-tidy -----------------------===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "MoveConstantArgumentCheck.h"
-
-#include "clang/Lex/Lexer.h"
-
-using namespace clang::ast_matchers;
-
-namespace clang {
-namespace tidy {
-namespace misc {
-
-static void ReplaceCallWithArg(const CallExpr *Call, DiagnosticBuilder &Diag,
-                               const SourceManager &SM,
-                               const LangOptions &LangOpts) {
-  const Expr *Arg = Call->getArg(0);
-
-  CharSourceRange BeforeArgumentsRange = Lexer::makeFileCharRange(
-      CharSourceRange::getCharRange(Call->getLocStart(), Arg->getLocStart()),
-      SM, LangOpts);
-  CharSourceRange AfterArgumentsRange = Lexer::makeFileCharRange(
-      CharSourceRange::getCharRange(Call->getLocEnd(),
-                                    Call->getLocEnd().getLocWithOffset(1)),
-      SM, LangOpts);
-
-  if (BeforeArgumentsRange.isValid() && AfterArgumentsRange.isValid()) {
-    Diag << FixItHint::CreateRemoval(BeforeArgumentsRange)
-         << FixItHint::CreateRemoval(AfterArgumentsRange);
-  }
-}
-
-void MoveConstantArgumentCheck::storeOptions(
-    ClangTidyOptions::OptionMap &Opts) {
-  Options.store(Opts, "CheckTriviallyCopyableMove", CheckTriviallyCopyableMove);
-}
-
-void MoveConstantArgumentCheck::registerMatchers(MatchFinder *Finder) {
-  if (!getLangOpts().CPlusPlus)
-    return;
-
-  auto MoveCallMatcher =
-      callExpr(callee(functionDecl(hasName("::std::move"))), argumentCountIs(1),
-               unless(isInTemplateInstantiation()))
-          .bind("call-move");
-
-  Finder->addMatcher(MoveCallMatcher, this);
-
-  auto ConstParamMatcher = forEachArgumentWithParam(
-      MoveCallMatcher, parmVarDecl(hasType(references(isConstQualified()))));
-
-  Finder->addMatcher(callExpr(ConstParamMatcher).bind("receiving-expr"), this);
-  Finder->addMatcher(cxxConstructExpr(ConstParamMatcher).bind("receiving-expr"),
-                     this);
-}
-
-void MoveConstantArgumentCheck::check(const MatchFinder::MatchResult &Result) {
-  const auto *CallMove = Result.Nodes.getNodeAs<CallExpr>("call-move");
-  const auto *ReceivingExpr = Result.Nodes.getNodeAs<Expr>("receiving-expr");
-  const Expr *Arg = CallMove->getArg(0);
-  SourceManager &SM = Result.Context->getSourceManager();
-
-  CharSourceRange MoveRange =
-      CharSourceRange::getCharRange(CallMove->getSourceRange());
-  CharSourceRange FileMoveRange =
-      Lexer::makeFileCharRange(MoveRange, SM, getLangOpts());
-  if (!FileMoveRange.isValid())
-    return;
-
-  bool IsConstArg = Arg->getType().isConstQualified();
-  bool IsTriviallyCopyable =
-      Arg->getType().isTriviallyCopyableType(*Result.Context);
-
-  if (IsConstArg || IsTriviallyCopyable) {
-    if (const CXXRecordDecl *R = Arg->getType()->getAsCXXRecordDecl()) {
-      // According to [expr.prim.lambda]p3, "whether the closure type is
-      // trivially copyable" property can be changed by the implementation of
-      // the language, so we shouldn't rely on it when issuing diagnostics.
-      if (R->isLambda())
-        return;
-      // Don't warn when the type is not copyable.
-      for (const auto *Ctor : R->ctors()) {
-        if (Ctor->isCopyConstructor() && Ctor->isDeleted())
-          return;
-      }
-    }
-
-    if (!IsConstArg && IsTriviallyCopyable && !CheckTriviallyCopyableMove)
-      return;
-
-    bool IsVariable = isa<DeclRefExpr>(Arg);
-    const auto *Var =
-        IsVariable ? dyn_cast<DeclRefExpr>(Arg)->getDecl() : nullptr;
-    auto Diag = diag(FileMoveRange.getBegin(),
-                     "std::move of the %select{|const }0"
-                     "%select{expression|variable %4}1 "
-                     "%select{|of the trivially-copyable type %5 }2"
-                     "has no effect; remove std::move()"
-                     "%select{| or make the variable non-const}3")
-                << IsConstArg << IsVariable << IsTriviallyCopyable
-                << (IsConstArg && IsVariable && !IsTriviallyCopyable) << Var
-                << Arg->getType();
-
-    ReplaceCallWithArg(CallMove, Diag, SM, getLangOpts());
-  } else if (ReceivingExpr) {
-    auto Diag = diag(FileMoveRange.getBegin(),
-                     "passing result of std::move() as a const reference "
-                     "argument; no move will actually happen");
-
-    ReplaceCallWithArg(CallMove, Diag, SM, getLangOpts());
-  }
-}
-
-} // namespace misc
-} // namespace tidy
-} // namespace clang

Removed: clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.h?rev=319182&view=auto
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.h (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.h (removed)
@@ -1,43 +0,0 @@
-//===--- MoveConstantArgumentCheck.h - clang-tidy -------------------------===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MOVECONSTANTARGUMENTCHECK_H
-#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MOVECONSTANTARGUMENTCHECK_H
-
-#include "../ClangTidy.h"
-
-namespace clang {
-namespace tidy {
-namespace misc {
-
-/// Find casts of calculation results to bigger type. Typically from int to
-///
-/// There is one option:
-///
-///   - `CheckTriviallyCopyableMove`: Whether to check for trivially-copyable
-//      types as their objects are not moved but copied. Enabled by default.
-class MoveConstantArgumentCheck : public ClangTidyCheck {
-public:
-  MoveConstantArgumentCheck(StringRef Name, ClangTidyContext *Context)
-      : ClangTidyCheck(Name, Context),
-        CheckTriviallyCopyableMove(
-            Options.get("CheckTriviallyCopyableMove", true)) {}
-  void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
-  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
-  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
-
-private:
-  const bool CheckTriviallyCopyableMove;
-};
-
-} // namespace misc
-} // namespace tidy
-} // namespace clang
-
-#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MOVECONSTANTARGUMENTCHECK_H

Removed: clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveConstructorCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveConstructorCheck.cpp?rev=319182&view=auto
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveConstructorCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveConstructorCheck.cpp (removed)
@@ -1,77 +0,0 @@
-//===--- NoexceptMoveConstructorCheck.cpp - clang-tidy---------------------===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#include "NoexceptMoveConstructorCheck.h"
-#include "clang/AST/ASTContext.h"
-#include "clang/ASTMatchers/ASTMatchFinder.h"
-
-using namespace clang::ast_matchers;
-
-namespace clang {
-namespace tidy {
-namespace misc {
-
-void NoexceptMoveConstructorCheck::registerMatchers(MatchFinder *Finder) {
-  // Only register the matchers for C++11; the functionality currently does not
-  // provide any benefit to other languages, despite being benign.
-  if (!getLangOpts().CPlusPlus11)
-    return;
-
-  Finder->addMatcher(
-      cxxMethodDecl(anyOf(cxxConstructorDecl(), hasOverloadedOperatorName("=")),
-                    unless(isImplicit()), unless(isDeleted()))
-          .bind("decl"),
-      this);
-}
-
-void NoexceptMoveConstructorCheck::check(
-    const MatchFinder::MatchResult &Result) {
-  if (const auto *Decl = Result.Nodes.getNodeAs<CXXMethodDecl>("decl")) {
-    StringRef MethodType = "assignment operator";
-    if (const auto *Ctor = dyn_cast<CXXConstructorDecl>(Decl)) {
-      if (!Ctor->isMoveConstructor())
-        return;
-      MethodType = "constructor";
-    } else if (!Decl->isMoveAssignmentOperator()) {
-      return;
-    }
-
-    const auto *ProtoType = Decl->getType()->getAs<FunctionProtoType>();
-
-    if (isUnresolvedExceptionSpec(ProtoType->getExceptionSpecType()))
-      return;
-
-    switch (ProtoType->getNoexceptSpec(*Result.Context)) {
-      case FunctionProtoType::NR_NoNoexcept:
-        diag(Decl->getLocation(), "move %0s should be marked noexcept")
-            << MethodType;
-        // FIXME: Add a fixit.
-        break;
-      case FunctionProtoType::NR_Throw:
-        // Don't complain about nothrow(false), but complain on nothrow(expr)
-        // where expr evaluates to false.
-        if (const Expr *E = ProtoType->getNoexceptExpr()) {
-          if (isa<CXXBoolLiteralExpr>(E))
-            break;
-          diag(E->getExprLoc(),
-               "noexcept specifier on the move %0 evaluates to 'false'")
-              << MethodType;
-        }
-        break;
-      case FunctionProtoType::NR_Nothrow:
-      case FunctionProtoType::NR_Dependent:
-      case FunctionProtoType::NR_BadNoexcept:
-        break;
-    }
-  }
-}
-
-} // namespace misc
-} // namespace tidy
-} // namespace clang

Removed: clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveConstructorCheck.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveConstructorCheck.h?rev=319182&view=auto
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveConstructorCheck.h (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveConstructorCheck.h (removed)
@@ -1,38 +0,0 @@
-//===--- NoexceptMoveConstructorCheck.h - clang-tidy-------------*- C++ -*-===//
-//
-//                     The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_NOEXCEPTMOVECONSTRUCTORCHECK_H
-#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_NOEXCEPTMOVECONSTRUCTORCHECK_H
-
-#include "../ClangTidy.h"
-
-namespace clang {
-namespace tidy {
-namespace misc {
-
-/// The check flags user-defined move constructors and assignment operators not
-/// marked with `noexcept` or marked with `noexcept(expr)` where `expr`
-/// evaluates to `false` (but is not a `false` literal itself).
-///
-/// Move constructors of all the types used with STL containers, for example,
-/// need to be declared `noexcept`. Otherwise STL will choose copy constructors
-/// instead. The same is valid for move assignment operations.
-class NoexceptMoveConstructorCheck : public ClangTidyCheck {
-public:
-  NoexceptMoveConstructorCheck(StringRef Name, ClangTidyContext *Context)
-      : ClangTidyCheck(Name, Context) {}
-  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
-  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
-};
-
-} // namespace misc
-} // namespace tidy
-} // namespace clang
-
-#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_NOEXCEPTMOVECONSTRUCTORCHECK_H

Modified: clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp?rev=319183&r1=319182&r2=319183&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/PassByValueCheck.cpp Tue Nov 28 08:41:03 2017
@@ -187,7 +187,7 @@ void PassByValueCheck::check(const Match
     return;
 
   // If the parameter is trivial to copy, don't move it. Moving a trivivally
-  // copyable type will cause a problem with misc-move-const-arg
+  // copyable type will cause a problem with performance-move-const-arg
   if (ParamDecl->getType().getNonReferenceType().isTriviallyCopyableType(
           *Result.Context))
     return;

Modified: clang-tools-extra/trunk/clang-tidy/performance/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/performance/CMakeLists.txt?rev=319183&r1=319182&r2=319183&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/performance/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/performance/CMakeLists.txt Tue Nov 28 08:41:03 2017
@@ -7,7 +7,9 @@ add_clang_library(clangTidyPerformanceMo
   InefficientAlgorithmCheck.cpp
   InefficientStringConcatenationCheck.cpp
   InefficientVectorOperationCheck.cpp
+  MoveConstArgCheck.cpp
   MoveConstructorInitCheck.cpp
+  NoexceptMoveConstructorCheck.cpp
   PerformanceTidyModule.cpp
   TypePromotionInMathFnCheck.cpp
   UnnecessaryCopyInitialization.cpp

Copied: clang-tools-extra/trunk/clang-tidy/performance/MoveConstArgCheck.cpp (from r319174, clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp)
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/performance/MoveConstArgCheck.cpp?p2=clang-tools-extra/trunk/clang-tidy/performance/MoveConstArgCheck.cpp&p1=clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp&r1=319174&r2=319183&rev=319183&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/performance/MoveConstArgCheck.cpp Tue Nov 28 08:41:03 2017
@@ -1,4 +1,4 @@
-//===--- MoveConstantArgumentCheck.cpp - clang-tidy -----------------------===//
+//===--- MoveConstArgCheck.cpp - clang-tidy -----------------------===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -7,7 +7,7 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "MoveConstantArgumentCheck.h"
+#include "MoveConstArgCheck.h"
 
 #include "clang/Lex/Lexer.h"
 
@@ -15,7 +15,7 @@ using namespace clang::ast_matchers;
 
 namespace clang {
 namespace tidy {
-namespace misc {
+namespace performance {
 
 static void ReplaceCallWithArg(const CallExpr *Call, DiagnosticBuilder &Diag,
                                const SourceManager &SM,
@@ -36,12 +36,11 @@ static void ReplaceCallWithArg(const Cal
   }
 }
 
-void MoveConstantArgumentCheck::storeOptions(
-    ClangTidyOptions::OptionMap &Opts) {
+void MoveConstArgCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
   Options.store(Opts, "CheckTriviallyCopyableMove", CheckTriviallyCopyableMove);
 }
 
-void MoveConstantArgumentCheck::registerMatchers(MatchFinder *Finder) {
+void MoveConstArgCheck::registerMatchers(MatchFinder *Finder) {
   if (!getLangOpts().CPlusPlus)
     return;
 
@@ -60,7 +59,7 @@ void MoveConstantArgumentCheck::register
                      this);
 }
 
-void MoveConstantArgumentCheck::check(const MatchFinder::MatchResult &Result) {
+void MoveConstArgCheck::check(const MatchFinder::MatchResult &Result) {
   const auto *CallMove = Result.Nodes.getNodeAs<CallExpr>("call-move");
   const auto *ReceivingExpr = Result.Nodes.getNodeAs<Expr>("receiving-expr");
   const Expr *Arg = CallMove->getArg(0);
@@ -117,6 +116,6 @@ void MoveConstantArgumentCheck::check(co
   }
 }
 
-} // namespace misc
+} // namespace performance
 } // namespace tidy
 } // namespace clang

Copied: clang-tools-extra/trunk/clang-tidy/performance/MoveConstArgCheck.h (from r319174, clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.h)
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/performance/MoveConstArgCheck.h?p2=clang-tools-extra/trunk/clang-tidy/performance/MoveConstArgCheck.h&p1=clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.h&r1=319174&r2=319183&rev=319183&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/MoveConstantArgumentCheck.h (original)
+++ clang-tools-extra/trunk/clang-tidy/performance/MoveConstArgCheck.h Tue Nov 28 08:41:03 2017
@@ -1,4 +1,4 @@
-//===--- MoveConstantArgumentCheck.h - clang-tidy -------------------------===//
+//===--- MoveConstArgCheck.h - clang-tidy -------------------------===//
 //
 //                     The LLVM Compiler Infrastructure
 //
@@ -14,7 +14,7 @@
 
 namespace clang {
 namespace tidy {
-namespace misc {
+namespace performance {
 
 /// Find casts of calculation results to bigger type. Typically from int to
 ///
@@ -22,9 +22,9 @@ namespace misc {
 ///
 ///   - `CheckTriviallyCopyableMove`: Whether to check for trivially-copyable
 //      types as their objects are not moved but copied. Enabled by default.
-class MoveConstantArgumentCheck : public ClangTidyCheck {
+class MoveConstArgCheck : public ClangTidyCheck {
 public:
-  MoveConstantArgumentCheck(StringRef Name, ClangTidyContext *Context)
+  MoveConstArgCheck(StringRef Name, ClangTidyContext *Context)
       : ClangTidyCheck(Name, Context),
         CheckTriviallyCopyableMove(
             Options.get("CheckTriviallyCopyableMove", true)) {}
@@ -36,7 +36,7 @@ private:
   const bool CheckTriviallyCopyableMove;
 };
 
-} // namespace misc
+} // namespace performance
 } // namespace tidy
 } // namespace clang
 

Copied: clang-tools-extra/trunk/clang-tidy/performance/NoexceptMoveConstructorCheck.cpp (from r319174, clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveConstructorCheck.cpp)
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/performance/NoexceptMoveConstructorCheck.cpp?p2=clang-tools-extra/trunk/clang-tidy/performance/NoexceptMoveConstructorCheck.cpp&p1=clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveConstructorCheck.cpp&r1=319174&r2=319183&rev=319183&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveConstructorCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/performance/NoexceptMoveConstructorCheck.cpp Tue Nov 28 08:41:03 2017
@@ -15,7 +15,7 @@ using namespace clang::ast_matchers;
 
 namespace clang {
 namespace tidy {
-namespace misc {
+namespace performance {
 
 void NoexceptMoveConstructorCheck::registerMatchers(MatchFinder *Finder) {
   // Only register the matchers for C++11; the functionality currently does not
@@ -48,30 +48,30 @@ void NoexceptMoveConstructorCheck::check
       return;
 
     switch (ProtoType->getNoexceptSpec(*Result.Context)) {
-      case FunctionProtoType::NR_NoNoexcept:
-        diag(Decl->getLocation(), "move %0s should be marked noexcept")
+    case FunctionProtoType::NR_NoNoexcept:
+      diag(Decl->getLocation(), "move %0s should be marked noexcept")
+          << MethodType;
+      // FIXME: Add a fixit.
+      break;
+    case FunctionProtoType::NR_Throw:
+      // Don't complain about nothrow(false), but complain on nothrow(expr)
+      // where expr evaluates to false.
+      if (const Expr *E = ProtoType->getNoexceptExpr()) {
+        if (isa<CXXBoolLiteralExpr>(E))
+          break;
+        diag(E->getExprLoc(),
+             "noexcept specifier on the move %0 evaluates to 'false'")
             << MethodType;
-        // FIXME: Add a fixit.
-        break;
-      case FunctionProtoType::NR_Throw:
-        // Don't complain about nothrow(false), but complain on nothrow(expr)
-        // where expr evaluates to false.
-        if (const Expr *E = ProtoType->getNoexceptExpr()) {
-          if (isa<CXXBoolLiteralExpr>(E))
-            break;
-          diag(E->getExprLoc(),
-               "noexcept specifier on the move %0 evaluates to 'false'")
-              << MethodType;
-        }
-        break;
-      case FunctionProtoType::NR_Nothrow:
-      case FunctionProtoType::NR_Dependent:
-      case FunctionProtoType::NR_BadNoexcept:
-        break;
+      }
+      break;
+    case FunctionProtoType::NR_Nothrow:
+    case FunctionProtoType::NR_Dependent:
+    case FunctionProtoType::NR_BadNoexcept:
+      break;
     }
   }
 }
 
-} // namespace misc
+} // namespace performance
 } // namespace tidy
 } // namespace clang

Copied: clang-tools-extra/trunk/clang-tidy/performance/NoexceptMoveConstructorCheck.h (from r319174, clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveConstructorCheck.h)
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/performance/NoexceptMoveConstructorCheck.h?p2=clang-tools-extra/trunk/clang-tidy/performance/NoexceptMoveConstructorCheck.h&p1=clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveConstructorCheck.h&r1=319174&r2=319183&rev=319183&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/NoexceptMoveConstructorCheck.h (original)
+++ clang-tools-extra/trunk/clang-tidy/performance/NoexceptMoveConstructorCheck.h Tue Nov 28 08:41:03 2017
@@ -7,14 +7,14 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_NOEXCEPTMOVECONSTRUCTORCHECK_H
-#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_NOEXCEPTMOVECONSTRUCTORCHECK_H
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_NOEXCEPTMOVECONSTRUCTORCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_NOEXCEPTMOVECONSTRUCTORCHECK_H
 
 #include "../ClangTidy.h"
 
 namespace clang {
 namespace tidy {
-namespace misc {
+namespace performance {
 
 /// The check flags user-defined move constructors and assignment operators not
 /// marked with `noexcept` or marked with `noexcept(expr)` where `expr`
@@ -31,8 +31,8 @@ public:
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
 };
 
-} // namespace misc
+} // namespace performance
 } // namespace tidy
 } // namespace clang
 
-#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_NOEXCEPTMOVECONSTRUCTORCHECK_H
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_NOEXCEPTMOVECONSTRUCTORCHECK_H

Modified: clang-tools-extra/trunk/clang-tidy/performance/PerformanceTidyModule.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/performance/PerformanceTidyModule.cpp?rev=319183&r1=319182&r2=319183&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/performance/PerformanceTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/performance/PerformanceTidyModule.cpp Tue Nov 28 08:41:03 2017
@@ -16,7 +16,9 @@
 #include "InefficientAlgorithmCheck.h"
 #include "InefficientStringConcatenationCheck.h"
 #include "InefficientVectorOperationCheck.h"
+#include "MoveConstArgCheck.h"
 #include "MoveConstructorInitCheck.h"
+#include "NoexceptMoveConstructorCheck.h"
 #include "TypePromotionInMathFnCheck.h"
 #include "UnnecessaryCopyInitialization.h"
 #include "UnnecessaryValueParamCheck.h"
@@ -40,8 +42,12 @@ public:
         "performance-inefficient-string-concatenation");
     CheckFactories.registerCheck<InefficientVectorOperationCheck>(
         "performance-inefficient-vector-operation");
+    CheckFactories.registerCheck<MoveConstArgCheck>(
+        "performance-move-const-arg");
     CheckFactories.registerCheck<MoveConstructorInitCheck>(
         "performance-move-constructor-init");
+    CheckFactories.registerCheck<NoexceptMoveConstructorCheck>(
+        "performance-noexcept-move-constructor");
     CheckFactories.registerCheck<TypePromotionInMathFnCheck>(
         "performance-type-promotion-in-math-fn");
     CheckFactories.registerCheck<UnnecessaryCopyInitialization>(

Modified: clang-tools-extra/trunk/docs/ReleaseNotes.rst
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/ReleaseNotes.rst?rev=319183&r1=319182&r2=319183&view=diff
==============================================================================
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst (original)
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst Tue Nov 28 08:41:03 2017
@@ -62,6 +62,12 @@ Improvements to clang-tidy
 
   Add new check to detect the use of OSSpinlock.
 
+- The 'misc-move-const-arg' check was renamed to `performance-move-const-arg
+  <http://clang.llvm.org/extra/clang-tidy/checks/performance-move-const-arg.html>`_
+
+- The 'misc-noexcept-move-constructor' check was renamed to `performance-noexcept-move-constructor
+  <http://clang.llvm.org/extra/clang-tidy/checks/performance-noexcept-move-constructor.html>`_
+
 - The 'misc-move-constructor-init' check was renamed to `performance-move-constructor-init
   <http://clang.llvm.org/extra/clang-tidy/checks/performance-move-constructor-init.html>`_
 

Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-move-const-arg.rst
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-move-const-arg.rst?rev=319183&r1=319182&r2=319183&view=diff
==============================================================================
--- clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-move-const-arg.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/hicpp-move-const-arg.rst Tue Nov 28 08:41:03 2017
@@ -1,10 +1,10 @@
 .. title:: clang-tidy - hicpp-move-const-arg
 .. meta::
-   :http-equiv=refresh: 5;URL=misc-move-const-arg.html
+   :http-equiv=refresh: 5;URL=performance-move-const-arg.html
 
 hicpp-move-const-arg
 ====================
 
 The `hicpp-move-const-arg` check is an alias, please see
-`misc-move-const-arg <misc-move-const-arg.html>`_ for more information.
+`performance-move-const-arg <performance-move-const-arg.html>`_ for more information.
 It enforces the `rule 17.3.1 <http://www.codingstandard.com/rule/17-3-1-do-not-use-stdmove-on-objects-declared-with-const-or-const-type/>`_.

Modified: clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst?rev=319183&r1=319182&r2=319183&view=diff
==============================================================================
--- clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst Tue Nov 28 08:41:03 2017
@@ -93,7 +93,7 @@ Clang-Tidy Checks
    hicpp-function-size (redirects to readability-function-size) <hicpp-function-size>
    hicpp-invalid-access-moved (redirects to bugprone-use-after-move) <hicpp-invalid-access-moved>
    hicpp-member-init (redirects to cppcoreguidelines-pro-type-member-init) <hicpp-member-init>
-   hicpp-move-const-arg (redirects to misc-move-const-arg) <hicpp-move-const-arg>
+   hicpp-move-const-arg (redirects to performance-move-const-arg) <hicpp-move-const-arg>
    hicpp-named-parameter (redirects to readability-named-parameter) <hicpp-named-parameter>
    hicpp-new-delete-operators (redirects to misc-new-delete-overloads) <hicpp-new-delete-operators>
    hicpp-no-array-decay (redirects to cppcoreguidelines-pro-bounds-array-to-pointer-decay) <hicpp-no-array-decay>
@@ -124,9 +124,7 @@ Clang-Tidy Checks
    misc-macro-repeated-side-effects
    misc-misplaced-const
    misc-misplaced-widening-cast
-   misc-move-const-arg
    misc-new-delete-overloads
-   misc-noexcept-move-constructor
    misc-non-copyable-objects
    misc-redundant-expression
    misc-sizeof-container
@@ -183,7 +181,9 @@ Clang-Tidy Checks
    performance-inefficient-algorithm
    performance-inefficient-string-concatenation
    performance-inefficient-vector-operation
+   performance-move-const-arg
    performance-move-constructor-init
+   performance-noexcept-move-constructor
    performance-type-promotion-in-math-fn
    performance-unnecessary-copy-initialization
    performance-unnecessary-value-param

Removed: clang-tools-extra/trunk/docs/clang-tidy/checks/misc-move-const-arg.rst
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/misc-move-const-arg.rst?rev=319182&view=auto
==============================================================================
--- clang-tools-extra/trunk/docs/clang-tidy/checks/misc-move-const-arg.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/misc-move-const-arg.rst (removed)
@@ -1,37 +0,0 @@
-.. title:: clang-tidy - misc-move-const-arg
-
-misc-move-const-arg
-===================
-
-The check warns
-
-- if ``std::move()`` is called with a constant argument,
-
-- if ``std::move()`` is called with an argument of a trivially-copyable type,
-
-- if the result of ``std::move()`` is passed as a const reference argument.
-
-In all three cases, the check will suggest a fix that removes the
-``std::move()``.
-
-Here are examples of each of the three cases:
-
-.. code-block:: c++
-
-  const string s;
-  return std::move(s);  // Warning: std::move of the const variable has no effect
-
-  int x;
-  return std::move(x);  // Warning: std::move of the variable of a trivially-copyable type has no effect
-
-  void f(const string &s);
-  string s;
-  f(std::move(s));  // Warning: passing result of std::move as a const reference argument; no move will actually happen
-
-Options
--------
-
-.. option:: CheckTriviallyCopyableMove
-
-   If non-zero, enables detection of trivially copyable types that do not
-   have a move constructor. Default is non-zero.

Removed: clang-tools-extra/trunk/docs/clang-tidy/checks/misc-noexcept-move-constructor.rst
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/misc-noexcept-move-constructor.rst?rev=319182&view=auto
==============================================================================
--- clang-tools-extra/trunk/docs/clang-tidy/checks/misc-noexcept-move-constructor.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/misc-noexcept-move-constructor.rst (removed)
@@ -1,13 +0,0 @@
-.. title:: clang-tidy - misc-noexcept-move-constructor
-
-misc-noexcept-move-constructor
-==============================
-
-
-The check flags user-defined move constructors and assignment operators not
-marked with ``noexcept`` or marked with ``noexcept(expr)`` where ``expr``
-evaluates to ``false`` (but is not a ``false`` literal itself).
-
-Move constructors of all the types used with STL containers, for example,
-need to be declared ``noexcept``. Otherwise STL will choose copy constructors
-instead. The same is valid for move assignment operations.

Copied: clang-tools-extra/trunk/docs/clang-tidy/checks/performance-move-const-arg.rst (from r319174, clang-tools-extra/trunk/docs/clang-tidy/checks/misc-move-const-arg.rst)
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/performance-move-const-arg.rst?p2=clang-tools-extra/trunk/docs/clang-tidy/checks/performance-move-const-arg.rst&p1=clang-tools-extra/trunk/docs/clang-tidy/checks/misc-move-const-arg.rst&r1=319174&r2=319183&rev=319183&view=diff
==============================================================================
--- clang-tools-extra/trunk/docs/clang-tidy/checks/misc-move-const-arg.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/performance-move-const-arg.rst Tue Nov 28 08:41:03 2017
@@ -1,7 +1,7 @@
-.. title:: clang-tidy - misc-move-const-arg
+.. title:: clang-tidy - performance-move-const-arg
 
-misc-move-const-arg
-===================
+performance-move-const-arg
+==========================
 
 The check warns
 

Copied: clang-tools-extra/trunk/docs/clang-tidy/checks/performance-noexcept-move-constructor.rst (from r319174, clang-tools-extra/trunk/docs/clang-tidy/checks/misc-noexcept-move-constructor.rst)
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/performance-noexcept-move-constructor.rst?p2=clang-tools-extra/trunk/docs/clang-tidy/checks/performance-noexcept-move-constructor.rst&p1=clang-tools-extra/trunk/docs/clang-tidy/checks/misc-noexcept-move-constructor.rst&r1=319174&r2=319183&rev=319183&view=diff
==============================================================================
--- clang-tools-extra/trunk/docs/clang-tidy/checks/misc-noexcept-move-constructor.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/performance-noexcept-move-constructor.rst Tue Nov 28 08:41:03 2017
@@ -1,7 +1,7 @@
-.. title:: clang-tidy - misc-noexcept-move-constructor
+.. title:: clang-tidy - performance-noexcept-move-constructor
 
-misc-noexcept-move-constructor
-==============================
+performance-noexcept-move-constructor
+=====================================
 
 
 The check flags user-defined move constructors and assignment operators not

Removed: clang-tools-extra/trunk/test/clang-tidy/misc-move-const-arg-trivially-copyable.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-move-const-arg-trivially-copyable.cpp?rev=319182&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-move-const-arg-trivially-copyable.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-move-const-arg-trivially-copyable.cpp (removed)
@@ -1,98 +0,0 @@
-// RUN: %check_clang_tidy %s misc-move-const-arg %t \
-// RUN: -config='{CheckOptions: \
-// RUN:  [{key: misc-move-const-arg.CheckTriviallyCopyableMove, value: 0}]}' \
-// RUN: -- -std=c++14
-
-namespace std {
-
-template <typename> struct remove_reference;
-template <typename _Tp> struct remove_reference { typedef _Tp type; };
-template <typename _Tp> struct remove_reference<_Tp &> { typedef _Tp type; };
-template <typename _Tp> struct remove_reference<_Tp &&> { typedef _Tp type; };
-
-template <typename _Tp>
-constexpr typename std::remove_reference<_Tp>::type &&move(_Tp &&__t) {
-  return static_cast<typename std::remove_reference<_Tp>::type &&>(__t);
-}
-
-template <typename _Tp>
-constexpr _Tp &&
-forward(typename remove_reference<_Tp>::type &__t) noexcept {
-  return static_cast<_Tp &&>(__t);
-}
-
-} // namespace std
-
-class NoMoveSemantics {
- public:
-  NoMoveSemantics();
-  NoMoveSemantics(const NoMoveSemantics &);
-
-  NoMoveSemantics &operator=(const NoMoveSemantics &);
-};
-
-void callByConstRef(const NoMoveSemantics &);
-void callByConstRef(int i, const NoMoveSemantics &);
-
-void moveToConstReferencePositives() {
-  NoMoveSemantics obj;
-
-  // Basic case. It is here just to have a single "detected and fixed" case.
-  callByConstRef(std::move(obj));
-  // CHECK-MESSAGES: :[[@LINE-1]]:18:  warning: passing result of std::move() as a const reference argument; no move will actually happen [misc-move-const-arg]
-  // CHECK-FIXES: callByConstRef(obj);
-}
-
-struct TriviallyCopyable {
-  int i;
-};
-
-void f(TriviallyCopyable) {}
-
-void g() {
-  TriviallyCopyable obj;
-  f(std::move(obj));
-}
-
-class MoveSemantics {
- public:
-  MoveSemantics();
-  MoveSemantics(MoveSemantics &&);
-
-  MoveSemantics &operator=(MoveSemantics &&);
-};
-
-void fmovable(MoveSemantics);
-
-void lambda1() {
-  auto f = [](MoveSemantics m) {
-    fmovable(std::move(m));
-  };
-  f(MoveSemantics());
-}
-
-template<class T> struct function {};
-
-template<typename Result, typename... Args>
-class function<Result(Args...)> {
-public:
-  function() = default;
-  void operator()(Args... args) const {
-    fmovable(std::forward<Args>(args)...);
-  }
-};
-
-void functionInvocation() {
-  function<void(MoveSemantics)> callback;
-  MoveSemantics m;
-  callback(std::move(m));
-}
-
-void lambda2() {
-  function<void(MoveSemantics)> callback;
-
-  auto f = [callback = std::move(callback)](MoveSemantics m) mutable {
-    callback(std::move(m));
-  };
-  f(MoveSemantics());
-}

Removed: clang-tools-extra/trunk/test/clang-tidy/misc-move-const-arg.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-move-const-arg.cpp?rev=319182&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-move-const-arg.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-move-const-arg.cpp (removed)
@@ -1,234 +0,0 @@
-// RUN: %check_clang_tidy %s misc-move-const-arg %t
-
-namespace std {
-template <typename> struct remove_reference;
-
-template <typename _Tp> struct remove_reference { typedef _Tp type; };
-
-template <typename _Tp> struct remove_reference<_Tp &> { typedef _Tp type; };
-
-template <typename _Tp> struct remove_reference<_Tp &&> { typedef _Tp type; };
-
-template <typename _Tp>
-constexpr typename std::remove_reference<_Tp>::type &&move(_Tp &&__t) {
-  return static_cast<typename std::remove_reference<_Tp>::type &&>(__t);
-}
-
-template <typename _Tp>
-constexpr _Tp &&
-forward(typename remove_reference<_Tp>::type &__t) noexcept {
-  return static_cast<_Tp &&>(__t);
-}
-
-} // namespace std
-
-class A {
-public:
-  A() {}
-  A(const A &rhs) {}
-  A(A &&rhs) {}
-};
-
-struct TriviallyCopyable {
-  int i;
-};
-
-void f(TriviallyCopyable) {}
-
-void g() {
-  TriviallyCopyable obj;
-  f(std::move(obj));
-  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: std::move of the variable 'obj' of the trivially-copyable type 'TriviallyCopyable' has no effect; remove std::move() [misc-move-const-arg]
-  // CHECK-FIXES: f(obj);
-}
-
-int f1() {
-  return std::move(42);
-  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: std::move of the expression of the trivially-copyable type 'int' has no effect; remove std::move() [misc-move-const-arg]
-  // CHECK-FIXES: return 42;
-}
-
-int f2(int x2) {
-  return std::move(x2);
-  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: std::move of the variable 'x2' of the trivially-copyable type 'int'
-  // CHECK-FIXES: return x2;
-}
-
-int *f3(int *x3) {
-  return std::move(x3);
-  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: std::move of the variable 'x3' of the trivially-copyable type 'int *'
-  // CHECK-FIXES: return x3;
-}
-
-A f4(A x4) { return std::move(x4); }
-
-A f5(const A x5) {
-  return std::move(x5);
-  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: std::move of the const variable 'x5' has no effect; remove std::move() or make the variable non-const [misc-move-const-arg]
-  // CHECK-FIXES: return x5;
-}
-
-template <typename T> T f6(const T x6) { return std::move(x6); }
-
-void f7() { int a = f6(10); }
-
-#define M1(x) x
-void f8() {
-  const A a;
-  M1(A b = std::move(a);)
-  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: std::move of the const variable 'a' has no effect; remove std::move() or make the variable non-const
-  // CHECK-FIXES: M1(A b = a;)
-}
-
-#define M2(x) std::move(x)
-int f9() { return M2(1); }
-
-template <typename T> T f10(const int x10) {
-  return std::move(x10);
-  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: std::move of the const variable 'x10' of the trivially-copyable type 'const int' has no effect; remove std::move() [misc-move-const-arg]
-  // CHECK-FIXES: return x10;
-}
-void f11() {
-  f10<int>(1);
-  f10<double>(1);
-}
-
-class NoMoveSemantics {
- public:
-  NoMoveSemantics();
-  NoMoveSemantics(const NoMoveSemantics &);
-
-  NoMoveSemantics &operator=(const NoMoveSemantics &);
-};
-
-void callByConstRef(const NoMoveSemantics &);
-void callByConstRef(int i, const NoMoveSemantics &);
-
-void moveToConstReferencePositives() {
-  NoMoveSemantics obj;
-
-  // Basic case.
-  callByConstRef(std::move(obj));
-  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: passing result of std::move() as
-  // CHECK-FIXES: callByConstRef(obj);
-
-  // Also works for second argument.
-  callByConstRef(1, std::move(obj));
-  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: passing result of std::move() as
-  // CHECK-FIXES: callByConstRef(1, obj);
-
-  // Works if std::move() applied to a temporary.
-  callByConstRef(std::move(NoMoveSemantics()));
-  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: passing result of std::move() as
-  // CHECK-FIXES: callByConstRef(NoMoveSemantics());
-
-  // Works if calling a copy constructor.
-  NoMoveSemantics other(std::move(obj));
-  // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: passing result of std::move() as
-  // CHECK-FIXES: NoMoveSemantics other(obj);
-
-  // Works if calling assignment operator.
-  other = std::move(obj);
-  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: passing result of std::move() as
-  // CHECK-FIXES: other = obj;
-}
-
-class MoveSemantics {
- public:
-  MoveSemantics();
-  MoveSemantics(MoveSemantics &&);
-
-  MoveSemantics &operator=(MoveSemantics &&);
-};
-
-void callByValue(MoveSemantics);
-
-void callByRValueRef(MoveSemantics &&);
-
-template <class T>
-void templateFunction(T obj) {
-  T other = std::move(obj);
-}
-
-#define M3(T, obj)            \
-  do {                        \
-    T other = std::move(obj); \
-  } while (true)
-
-#define CALL(func) (func)()
-
-void moveToConstReferenceNegatives() {
-  // No warning when actual move takes place.
-  MoveSemantics move_semantics;
-  callByValue(std::move(move_semantics));
-  callByRValueRef(std::move(move_semantics));
-  MoveSemantics other(std::move(move_semantics));
-  other = std::move(move_semantics);
-
-  // No warning if std::move() not used.
-  NoMoveSemantics no_move_semantics;
-  callByConstRef(no_move_semantics);
-
-  // No warning if instantiating a template.
-  templateFunction(no_move_semantics);
-
-  // No warning inside of macro expansions.
-  M3(NoMoveSemantics, no_move_semantics);
-
-  // No warning inside of macro expansion, even if the macro expansion is inside
-  // a lambda that is, in turn, an argument to a macro.
-  CALL([no_move_semantics] { M3(NoMoveSemantics, no_move_semantics); });
-
-  auto lambda = [] {};
-  auto lambda2 = std::move(lambda);
-}
-
-class MoveOnly {
-public:
-  MoveOnly(const MoveOnly &other) = delete;
-  MoveOnly &operator=(const MoveOnly &other) = delete;
-  MoveOnly(MoveOnly &&other) = default;
-  MoveOnly &operator=(MoveOnly &&other) = default;
-};
-template <class T>
-void Q(T);
-void moveOnlyNegatives(MoveOnly val) {
-  Q(std::move(val));
-}
-
-void fmovable(MoveSemantics);
-
-void lambda1() {
-  auto f = [](MoveSemantics m) {
-    fmovable(std::move(m));
-  };
-  f(MoveSemantics());
-}
-
-template<class T> struct function {};
-
-template<typename Result, typename... Args>
-class function<Result(Args...)> {
-public:
-  function() = default;
-  void operator()(Args... args) const {
-    fmovable(std::forward<Args>(args)...);
-  }
-};
-
-void functionInvocation() {
-  function<void(MoveSemantics)> callback;
-  MoveSemantics m;
-  callback(std::move(m));
-}
-
-void lambda2() {
-  function<void(MoveSemantics)> callback;
-
-  auto f = [callback = std::move(callback)](MoveSemantics m) mutable {
-    // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: std::move of the variable 'callback' of the trivially-copyable type 'function<void (MoveSemantics)>' has no effect; remove std::move()
-    // CHECK-FIXES: auto f = [callback = callback](MoveSemantics m) mutable {
-    callback(std::move(m));
-  };
-  f(MoveSemantics());
-}

Removed: clang-tools-extra/trunk/test/clang-tidy/misc-noexcept-move-constructor.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-noexcept-move-constructor.cpp?rev=319182&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-noexcept-move-constructor.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-noexcept-move-constructor.cpp (removed)
@@ -1,54 +0,0 @@
-// RUN: %check_clang_tidy %s misc-noexcept-move-constructor %t
-
-class A {
-  A(A &&);
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: move constructors should be marked noexcept [misc-noexcept-move-constructor]
-  A &operator=(A &&);
-  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: move assignment operators should
-};
-
-struct B {
-  static constexpr bool kFalse = false;
-  B(B &&) noexcept(kFalse);
-  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: noexcept specifier on the move constructor evaluates to 'false' [misc-noexcept-move-constructor]
-};
-
-class OK {};
-
-void f() {
-  OK a;
-  a = OK();
-}
-
-class OK1 {
- public:
-  OK1();
-  OK1(const OK1 &);
-  OK1(OK1&&) noexcept;
-  OK1 &operator=(OK1 &&) noexcept;
-  void f();
-  void g() noexcept;
-};
-
-class OK2 {
-  static constexpr bool kTrue = true;
-
-public:
-  OK2(OK2 &&) noexcept(true) {}
-  OK2 &operator=(OK2 &&) noexcept(kTrue) { return *this; }
-};
-
-struct OK3 {
-  OK3(OK3 &&) noexcept(false) {}
-  OK3 &operator=(OK3 &&) = delete;
-};
-
-struct OK4 {
-  OK4(OK4 &&) noexcept = default;
-  OK4 &operator=(OK4 &&) noexcept = default;
-};
-
-struct OK5 {
-  OK5(OK5 &&) noexcept(true) = default;
-  OK5 &operator=(OK5 &&) noexcept(true) = default;
-};

Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value.cpp?rev=319183&r1=319182&r2=319183&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-pass-by-value.cpp Tue Nov 28 08:41:03 2017
@@ -202,7 +202,7 @@ struct S {
 template <typename T, int N> struct array { T A[N]; };
 
 // Test that types that are trivially copyable will not use std::move. This will
-// cause problems with misc-move-const-arg, as it will revert it.
+// cause problems with performance-move-const-arg, as it will revert it.
 struct T {
   T(array<int, 10> a) : a_(a) {}
   // CHECK-FIXES: T(array<int, 10> a) : a_(a) {}

Copied: clang-tools-extra/trunk/test/clang-tidy/performance-move-const-arg-trivially-copyable.cpp (from r319174, clang-tools-extra/trunk/test/clang-tidy/misc-move-const-arg-trivially-copyable.cpp)
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/performance-move-const-arg-trivially-copyable.cpp?p2=clang-tools-extra/trunk/test/clang-tidy/performance-move-const-arg-trivially-copyable.cpp&p1=clang-tools-extra/trunk/test/clang-tidy/misc-move-const-arg-trivially-copyable.cpp&r1=319174&r2=319183&rev=319183&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-move-const-arg-trivially-copyable.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/performance-move-const-arg-trivially-copyable.cpp Tue Nov 28 08:41:03 2017
@@ -1,6 +1,6 @@
-// RUN: %check_clang_tidy %s misc-move-const-arg %t \
+// RUN: %check_clang_tidy %s performance-move-const-arg %t \
 // RUN: -config='{CheckOptions: \
-// RUN:  [{key: misc-move-const-arg.CheckTriviallyCopyableMove, value: 0}]}' \
+// RUN:  [{key: performance-move-const-arg.CheckTriviallyCopyableMove, value: 0}]}' \
 // RUN: -- -std=c++14
 
 namespace std {
@@ -39,7 +39,7 @@ void moveToConstReferencePositives() {
 
   // Basic case. It is here just to have a single "detected and fixed" case.
   callByConstRef(std::move(obj));
-  // CHECK-MESSAGES: :[[@LINE-1]]:18:  warning: passing result of std::move() as a const reference argument; no move will actually happen [misc-move-const-arg]
+  // CHECK-MESSAGES: :[[@LINE-1]]:18:  warning: passing result of std::move() as a const reference argument; no move will actually happen [performance-move-const-arg]
   // CHECK-FIXES: callByConstRef(obj);
 }
 

Copied: clang-tools-extra/trunk/test/clang-tidy/performance-move-const-arg.cpp (from r319174, clang-tools-extra/trunk/test/clang-tidy/misc-move-const-arg.cpp)
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/performance-move-const-arg.cpp?p2=clang-tools-extra/trunk/test/clang-tidy/performance-move-const-arg.cpp&p1=clang-tools-extra/trunk/test/clang-tidy/misc-move-const-arg.cpp&r1=319174&r2=319183&rev=319183&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-move-const-arg.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/performance-move-const-arg.cpp Tue Nov 28 08:41:03 2017
@@ -1,13 +1,23 @@
-// RUN: %check_clang_tidy %s misc-move-const-arg %t
+// RUN: %check_clang_tidy %s performance-move-const-arg %t
 
 namespace std {
-template <typename> struct remove_reference;
+template <typename>
+struct remove_reference;
 
-template <typename _Tp> struct remove_reference { typedef _Tp type; };
+template <typename _Tp>
+struct remove_reference {
+  typedef _Tp type;
+};
 
-template <typename _Tp> struct remove_reference<_Tp &> { typedef _Tp type; };
+template <typename _Tp>
+struct remove_reference<_Tp &> {
+  typedef _Tp type;
+};
 
-template <typename _Tp> struct remove_reference<_Tp &&> { typedef _Tp type; };
+template <typename _Tp>
+struct remove_reference<_Tp &&> {
+  typedef _Tp type;
+};
 
 template <typename _Tp>
 constexpr typename std::remove_reference<_Tp>::type &&move(_Tp &&__t) {
@@ -38,13 +48,13 @@ void f(TriviallyCopyable) {}
 void g() {
   TriviallyCopyable obj;
   f(std::move(obj));
-  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: std::move of the variable 'obj' of the trivially-copyable type 'TriviallyCopyable' has no effect; remove std::move() [misc-move-const-arg]
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: std::move of the variable 'obj' of the trivially-copyable type 'TriviallyCopyable' has no effect; remove std::move() [performance-move-const-arg]
   // CHECK-FIXES: f(obj);
 }
 
 int f1() {
   return std::move(42);
-  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: std::move of the expression of the trivially-copyable type 'int' has no effect; remove std::move() [misc-move-const-arg]
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: std::move of the expression of the trivially-copyable type 'int' has no effect; remove std::move() [performance-move-const-arg]
   // CHECK-FIXES: return 42;
 }
 
@@ -64,11 +74,14 @@ A f4(A x4) { return std::move(x4); }
 
 A f5(const A x5) {
   return std::move(x5);
-  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: std::move of the const variable 'x5' has no effect; remove std::move() or make the variable non-const [misc-move-const-arg]
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: std::move of the const variable 'x5' has no effect; remove std::move() or make the variable non-const [performance-move-const-arg]
   // CHECK-FIXES: return x5;
 }
 
-template <typename T> T f6(const T x6) { return std::move(x6); }
+template <typename T>
+T f6(const T x6) {
+  return std::move(x6);
+}
 
 void f7() { int a = f6(10); }
 
@@ -83,9 +96,10 @@ void f8() {
 #define M2(x) std::move(x)
 int f9() { return M2(1); }
 
-template <typename T> T f10(const int x10) {
+template <typename T>
+T f10(const int x10) {
   return std::move(x10);
-  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: std::move of the const variable 'x10' of the trivially-copyable type 'const int' has no effect; remove std::move() [misc-move-const-arg]
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: std::move of the const variable 'x10' of the trivially-copyable type 'const int' has no effect; remove std::move() [performance-move-const-arg]
   // CHECK-FIXES: return x10;
 }
 void f11() {
@@ -94,7 +108,7 @@ void f11() {
 }
 
 class NoMoveSemantics {
- public:
+public:
   NoMoveSemantics();
   NoMoveSemantics(const NoMoveSemantics &);
 
@@ -134,7 +148,7 @@ void moveToConstReferencePositives() {
 }
 
 class MoveSemantics {
- public:
+public:
   MoveSemantics();
   MoveSemantics(MoveSemantics &&);
 

Copied: clang-tools-extra/trunk/test/clang-tidy/performance-noexcept-move-constructor.cpp (from r319174, clang-tools-extra/trunk/test/clang-tidy/misc-noexcept-move-constructor.cpp)
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/performance-noexcept-move-constructor.cpp?p2=clang-tools-extra/trunk/test/clang-tidy/performance-noexcept-move-constructor.cpp&p1=clang-tools-extra/trunk/test/clang-tidy/misc-noexcept-move-constructor.cpp&r1=319174&r2=319183&rev=319183&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-noexcept-move-constructor.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/performance-noexcept-move-constructor.cpp Tue Nov 28 08:41:03 2017
@@ -1,8 +1,8 @@
-// RUN: %check_clang_tidy %s misc-noexcept-move-constructor %t
+// RUN: %check_clang_tidy %s performance-noexcept-move-constructor %t
 
 class A {
   A(A &&);
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: move constructors should be marked noexcept [misc-noexcept-move-constructor]
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: move constructors should be marked noexcept [performance-noexcept-move-constructor]
   A &operator=(A &&);
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: move assignment operators should
 };
@@ -10,7 +10,7 @@ class A {
 struct B {
   static constexpr bool kFalse = false;
   B(B &&) noexcept(kFalse);
-  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: noexcept specifier on the move constructor evaluates to 'false' [misc-noexcept-move-constructor]
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: noexcept specifier on the move constructor evaluates to 'false' [performance-noexcept-move-constructor]
 };
 
 class OK {};
@@ -21,10 +21,10 @@ void f() {
 }
 
 class OK1 {
- public:
+public:
   OK1();
   OK1(const OK1 &);
-  OK1(OK1&&) noexcept;
+  OK1(OK1 &&) noexcept;
   OK1 &operator=(OK1 &&) noexcept;
   void f();
   void g() noexcept;




More information about the cfe-commits mailing list