[clang-tools-extra] r246437 - [clang-tidy] Move misc-use-override and readability-shrink-to-fit to "modernize/"

Alexander Kornienko via cfe-commits cfe-commits at lists.llvm.org
Mon Aug 31 06:17:44 PDT 2015


Author: alexfh
Date: Mon Aug 31 08:17:43 2015
New Revision: 246437

URL: http://llvm.org/viewvc/llvm-project?rev=246437&view=rev
Log:
[clang-tidy] Move misc-use-override and readability-shrink-to-fit to "modernize/"

These checks are focusing on migrating the code from C++98/03 to C++11, so they
belong to the modernize module.

Added:
    clang-tools-extra/trunk/clang-tidy/modernize/ShrinkToFitCheck.cpp
      - copied, changed from r246432, clang-tools-extra/trunk/clang-tidy/readability/ShrinkToFitCheck.cpp
    clang-tools-extra/trunk/clang-tidy/modernize/ShrinkToFitCheck.h
      - copied, changed from r246432, clang-tools-extra/trunk/clang-tidy/readability/ShrinkToFitCheck.h
    clang-tools-extra/trunk/clang-tidy/modernize/UseOverrideCheck.cpp
      - copied, changed from r246432, clang-tools-extra/trunk/clang-tidy/misc/UseOverrideCheck.cpp
    clang-tools-extra/trunk/clang-tidy/modernize/UseOverrideCheck.h
      - copied, changed from r246432, clang-tools-extra/trunk/clang-tidy/misc/UseOverrideCheck.h
    clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-shrink-to-fit.rst
      - copied unchanged from r246432, clang-tools-extra/trunk/docs/clang-tidy/checks/readability-shrink-to-fit.rst
    clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-override.rst
      - copied, changed from r246432, clang-tools-extra/trunk/docs/clang-tidy/checks/misc-use-override.rst
    clang-tools-extra/trunk/test/clang-tidy/modernize-shrink-to-fit.cpp
      - copied, changed from r246432, clang-tools-extra/trunk/test/clang-tidy/readability-shrink-to-fit.cpp
    clang-tools-extra/trunk/test/clang-tidy/modernize-use-override-cxx98.cpp
      - copied, changed from r246432, clang-tools-extra/trunk/test/clang-tidy/misc-use-override-cxx98.cpp
    clang-tools-extra/trunk/test/clang-tidy/modernize-use-override.cpp
      - copied, changed from r246432, clang-tools-extra/trunk/test/clang-tidy/misc-use-override.cpp
Removed:
    clang-tools-extra/trunk/clang-tidy/misc/UseOverrideCheck.cpp
    clang-tools-extra/trunk/clang-tidy/misc/UseOverrideCheck.h
    clang-tools-extra/trunk/clang-tidy/readability/ShrinkToFitCheck.cpp
    clang-tools-extra/trunk/clang-tidy/readability/ShrinkToFitCheck.h
    clang-tools-extra/trunk/docs/clang-tidy/checks/misc-use-override.rst
    clang-tools-extra/trunk/docs/clang-tidy/checks/readability-shrink-to-fit.rst
    clang-tools-extra/trunk/test/clang-tidy/misc-use-override-cxx98.cpp
    clang-tools-extra/trunk/test/clang-tidy/misc-use-override.cpp
    clang-tools-extra/trunk/test/clang-tidy/readability-shrink-to-fit.cpp
Modified:
    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/CMakeLists.txt
    clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
    clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt
    clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp
    clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
    clang-tools-extra/trunk/docs/clang-tidy/index.rst
    clang-tools-extra/trunk/test/clang-tidy/clang-tidy-diff.cpp
    clang-tools-extra/trunk/test/clang-tidy/diagnostic.cpp

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=246437&r1=246436&r2=246437&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt Mon Aug 31 08:17:43 2015
@@ -19,7 +19,6 @@ add_clang_library(clangTidyMiscModule
   UnusedParametersCheck.cpp
   UnusedRAIICheck.cpp
   UniqueptrResetReleaseCheck.cpp
-  UseOverrideCheck.cpp
 
   LINK_LIBS
   clangAST

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=246437&r1=246436&r2=246437&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp Mon Aug 31 08:17:43 2015
@@ -27,7 +27,6 @@
 #include "UnusedAliasDeclsCheck.h"
 #include "UnusedParametersCheck.h"
 #include "UnusedRAIICheck.h"
-#include "UseOverrideCheck.h"
 
 namespace clang {
 namespace tidy {
@@ -68,7 +67,6 @@ public:
     CheckFactories.registerCheck<UnusedParametersCheck>(
         "misc-unused-parameters");
     CheckFactories.registerCheck<UnusedRAIICheck>("misc-unused-raii");
-    CheckFactories.registerCheck<UseOverrideCheck>("misc-use-override");
   }
 };
 

Removed: clang-tools-extra/trunk/clang-tidy/misc/UseOverrideCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/UseOverrideCheck.cpp?rev=246436&view=auto
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/UseOverrideCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/UseOverrideCheck.cpp (removed)
@@ -1,197 +0,0 @@
-//===--- UseOverrideCheck.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 "UseOverrideCheck.h"
-#include "clang/AST/ASTContext.h"
-#include "clang/ASTMatchers/ASTMatchFinder.h"
-#include "clang/Lex/Lexer.h"
-
-using namespace clang::ast_matchers;
-
-namespace clang {
-namespace tidy {
-namespace misc {
-
-void UseOverrideCheck::registerMatchers(MatchFinder *Finder) {
-  // Only register the matcher for C++11.
-  if (getLangOpts().CPlusPlus11)
-    Finder->addMatcher(methodDecl(isOverride()).bind("method"), this);
-}
-
-// Re-lex the tokens to get precise locations to insert 'override' and remove
-// 'virtual'.
-static SmallVector<Token, 16>
-ParseTokens(CharSourceRange Range, const MatchFinder::MatchResult &Result) {
-  const SourceManager &Sources = *Result.SourceManager;
-  std::pair<FileID, unsigned> LocInfo =
-      Sources.getDecomposedLoc(Range.getBegin());
-  StringRef File = Sources.getBufferData(LocInfo.first);
-  const char *TokenBegin = File.data() + LocInfo.second;
-  Lexer RawLexer(Sources.getLocForStartOfFile(LocInfo.first),
-                 Result.Context->getLangOpts(), File.begin(), TokenBegin,
-                 File.end());
-  SmallVector<Token, 16> Tokens;
-  Token Tok;
-  while (!RawLexer.LexFromRawLexer(Tok)) {
-    if (Tok.is(tok::semi) || Tok.is(tok::l_brace))
-      break;
-    if (Sources.isBeforeInTranslationUnit(Range.getEnd(), Tok.getLocation()))
-      break;
-    if (Tok.is(tok::raw_identifier)) {
-      IdentifierInfo &Info = Result.Context->Idents.get(StringRef(
-          Sources.getCharacterData(Tok.getLocation()), Tok.getLength()));
-      Tok.setIdentifierInfo(&Info);
-      Tok.setKind(Info.getTokenID());
-    }
-    Tokens.push_back(Tok);
-  }
-  return Tokens;
-}
-
-static StringRef GetText(const Token &Tok, const SourceManager &Sources) {
-  return StringRef(Sources.getCharacterData(Tok.getLocation()),
-                   Tok.getLength());
-}
-
-void UseOverrideCheck::check(const MatchFinder::MatchResult &Result) {
-  const FunctionDecl *Method = Result.Nodes.getStmtAs<FunctionDecl>("method");
-  const SourceManager &Sources = *Result.SourceManager;
-
-  assert(Method != nullptr);
-  if (Method->getInstantiatedFromMemberFunction() != nullptr)
-    Method = Method->getInstantiatedFromMemberFunction();
-
-  if (Method->isImplicit() || Method->getLocation().isMacroID() ||
-      Method->isOutOfLine())
-    return;
-
-  bool HasVirtual = Method->isVirtualAsWritten();
-  bool HasOverride = Method->getAttr<OverrideAttr>();
-  bool HasFinal = Method->getAttr<FinalAttr>();
-
-  bool OnlyVirtualSpecified = HasVirtual && !HasOverride && !HasFinal;
-  unsigned KeywordCount = HasVirtual + HasOverride + HasFinal;
-
-  if (!OnlyVirtualSpecified && KeywordCount == 1)
-    return; // Nothing to do.
-
-  std::string Message;
-
-  if (OnlyVirtualSpecified) {
-    Message =
-        "prefer using 'override' or (rarely) 'final' instead of 'virtual'";
-  } else if (KeywordCount == 0) {
-    Message = "annotate this function with 'override' or (rarely) 'final'";
-  } else {
-    StringRef Redundant =
-        HasVirtual ? (HasOverride && HasFinal ? "'virtual' and 'override' are"
-                                              : "'virtual' is")
-                   : "'override' is";
-    StringRef Correct = HasFinal ? "'final'" : "'override'";
-
-    Message =
-        (llvm::Twine(Redundant) +
-         " redundant since the function is already declared " + Correct).str();
-  }
-
-  DiagnosticBuilder Diag = diag(Method->getLocation(), Message);
-
-  CharSourceRange FileRange = Lexer::makeFileCharRange(
-      CharSourceRange::getTokenRange(Method->getSourceRange()), Sources,
-      Result.Context->getLangOpts());
-
-  if (!FileRange.isValid())
-    return;
-
-  // FIXME: Instead of re-lexing and looking for specific macros such as
-  // 'ABSTRACT', properly store the location of 'virtual' and '= 0' in each
-  // FunctionDecl.
-  SmallVector<Token, 16> Tokens = ParseTokens(FileRange, Result);
-
-  // Add 'override' on inline declarations that don't already have it.
-  if (!HasFinal && !HasOverride) {
-    SourceLocation InsertLoc;
-    StringRef ReplacementText = "override ";
-
-    for (Token T : Tokens) {
-      if (T.is(tok::kw___attribute)) {
-        InsertLoc = T.getLocation();
-        break;
-      }
-    }
-
-    if (Method->hasAttrs()) {
-      for (const clang::Attr *A : Method->getAttrs()) {
-        if (!A->isImplicit()) {
-          SourceLocation Loc =
-              Sources.getExpansionLoc(A->getRange().getBegin());
-          if (!InsertLoc.isValid() ||
-              Sources.isBeforeInTranslationUnit(Loc, InsertLoc))
-            InsertLoc = Loc;
-        }
-      }
-    }
-
-    if (InsertLoc.isInvalid() && Method->doesThisDeclarationHaveABody() &&
-        Method->getBody() && !Method->isDefaulted()) {
-      // For methods with inline definition, add the override keyword at the
-      // end of the declaration of the function, but prefer to put it on the
-      // same line as the declaration if the beginning brace for the start of
-      // the body falls on the next line.
-      Token LastNonCommentToken;
-      for (Token T : Tokens) {
-        if (!T.is(tok::comment)) {
-          LastNonCommentToken = T;
-        }
-      }
-      InsertLoc = LastNonCommentToken.getEndLoc();
-      ReplacementText = " override";
-    }
-
-    if (!InsertLoc.isValid()) {
-      // For declarations marked with "= 0" or "= [default|delete]", the end
-      // location will point until after those markings. Therefore, the override
-      // keyword shouldn't be inserted at the end, but before the '='.
-      if (Tokens.size() > 2 && (GetText(Tokens.back(), Sources) == "0" ||
-                                Tokens.back().is(tok::kw_default) ||
-                                Tokens.back().is(tok::kw_delete)) &&
-          GetText(Tokens[Tokens.size() - 2], Sources) == "=") {
-        InsertLoc = Tokens[Tokens.size() - 2].getLocation();
-      } else if (GetText(Tokens.back(), Sources) == "ABSTRACT") {
-        InsertLoc = Tokens.back().getLocation();
-      }
-    }
-
-    if (!InsertLoc.isValid()) {
-      InsertLoc = FileRange.getEnd();
-      ReplacementText = " override";
-    }
-    Diag << FixItHint::CreateInsertion(InsertLoc, ReplacementText);
-  }
-
-  if (HasFinal && HasOverride) {
-    SourceLocation OverrideLoc = Method->getAttr<OverrideAttr>()->getLocation();
-    Diag << FixItHint::CreateRemoval(
-        CharSourceRange::getTokenRange(OverrideLoc, OverrideLoc));
-  }
-
-  if (HasVirtual) {
-    for (Token Tok : Tokens) {
-      if (Tok.is(tok::kw_virtual)) {
-        Diag << FixItHint::CreateRemoval(CharSourceRange::getTokenRange(
-            Tok.getLocation(), Tok.getLocation()));
-        break;
-      }
-    }
-  }
-}
-
-} // namespace misc
-} // namespace tidy
-} // namespace clang

Removed: clang-tools-extra/trunk/clang-tidy/misc/UseOverrideCheck.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/UseOverrideCheck.h?rev=246436&view=auto
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/UseOverrideCheck.h (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/UseOverrideCheck.h (removed)
@@ -1,32 +0,0 @@
-//===--- UseOverrideCheck.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_USEOVERRIDECHECK_H
-#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_USEOVERRIDECHECK_H
-
-#include "../ClangTidy.h"
-
-namespace clang {
-namespace tidy {
-namespace misc {
-
-/// Use C++11's `override` and remove `virtual` where applicable.
-class UseOverrideCheck : public ClangTidyCheck {
-public:
-  UseOverrideCheck(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_USEOVERRIDECHECK_H

Modified: clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt?rev=246437&r1=246436&r2=246437&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt Mon Aug 31 08:17:43 2015
@@ -6,8 +6,10 @@ add_clang_library(clangTidyModernizeModu
   ModernizeTidyModule.cpp
   PassByValueCheck.cpp
   ReplaceAutoPtrCheck.cpp
+  ShrinkToFitCheck.cpp
   UseAutoCheck.cpp
   UseNullptrCheck.cpp
+  UseOverrideCheck.cpp
 
   LINK_LIBS
   clangAST

Modified: clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp?rev=246437&r1=246436&r2=246437&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp Mon Aug 31 08:17:43 2015
@@ -13,8 +13,10 @@
 #include "LoopConvertCheck.h"
 #include "PassByValueCheck.h"
 #include "ReplaceAutoPtrCheck.h"
+#include "ShrinkToFitCheck.h"
 #include "UseAutoCheck.h"
 #include "UseNullptrCheck.h"
+#include "UseOverrideCheck.h"
 
 using namespace clang::ast_matchers;
 
@@ -29,8 +31,10 @@ public:
     CheckFactories.registerCheck<PassByValueCheck>("modernize-pass-by-value");
     CheckFactories.registerCheck<ReplaceAutoPtrCheck>(
         "modernize-replace-auto-ptr");
+    CheckFactories.registerCheck<ShrinkToFitCheck>("modernize-shrink-to-fit");
     CheckFactories.registerCheck<UseAutoCheck>("modernize-use-auto");
     CheckFactories.registerCheck<UseNullptrCheck>("modernize-use-nullptr");
+    CheckFactories.registerCheck<UseOverrideCheck>("modernize-use-override");
   }
 
   ClangTidyOptions getModuleOptions() override {

Copied: clang-tools-extra/trunk/clang-tidy/modernize/ShrinkToFitCheck.cpp (from r246432, clang-tools-extra/trunk/clang-tidy/readability/ShrinkToFitCheck.cpp)
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/ShrinkToFitCheck.cpp?p2=clang-tools-extra/trunk/clang-tidy/modernize/ShrinkToFitCheck.cpp&p1=clang-tools-extra/trunk/clang-tidy/readability/ShrinkToFitCheck.cpp&r1=246432&r2=246437&rev=246437&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/readability/ShrinkToFitCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/ShrinkToFitCheck.cpp Mon Aug 31 08:17:43 2015
@@ -33,7 +33,7 @@ AST_MATCHER(NamedDecl, stlShrinkableCont
 } // namespace
 
 namespace tidy {
-namespace readability {
+namespace modernize {
 
 void ShrinkToFitCheck::registerMatchers(MatchFinder *Finder) {
   // Swap as a function need not to be considered, because rvalue can not
@@ -99,6 +99,6 @@ void ShrinkToFitCheck::check(const Match
       << Hint;
 }
 
-} // namespace readability
+} // namespace modernize
 } // namespace tidy
 } // namespace clang

Copied: clang-tools-extra/trunk/clang-tidy/modernize/ShrinkToFitCheck.h (from r246432, clang-tools-extra/trunk/clang-tidy/readability/ShrinkToFitCheck.h)
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/ShrinkToFitCheck.h?p2=clang-tools-extra/trunk/clang-tidy/modernize/ShrinkToFitCheck.h&p1=clang-tools-extra/trunk/clang-tidy/readability/ShrinkToFitCheck.h&r1=246432&r2=246437&rev=246437&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/readability/ShrinkToFitCheck.h (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/ShrinkToFitCheck.h Mon Aug 31 08:17:43 2015
@@ -7,14 +7,14 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_SHRINKTOFITCHECK_H
-#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_SHRINKTOFITCHECK_H
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_SHRINKTOFITCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_SHRINKTOFITCHECK_H
 
 #include "../ClangTidy.h"
 
 namespace clang {
 namespace tidy {
-namespace readability {
+namespace modernize {
 
 /// Replace copy and swap tricks on shrinkable containers with the
 /// `shrink_to_fit()` method call.
@@ -30,8 +30,8 @@ public:
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
 };
 
-} // namespace readability
+} // namespace modernize
 } // namespace tidy
 } // namespace clang
 
-#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_SHRINKTOFITCHECK_H
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_SHRINKTOFITCHECK_H

Copied: clang-tools-extra/trunk/clang-tidy/modernize/UseOverrideCheck.cpp (from r246432, clang-tools-extra/trunk/clang-tidy/misc/UseOverrideCheck.cpp)
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseOverrideCheck.cpp?p2=clang-tools-extra/trunk/clang-tidy/modernize/UseOverrideCheck.cpp&p1=clang-tools-extra/trunk/clang-tidy/misc/UseOverrideCheck.cpp&r1=246432&r2=246437&rev=246437&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/UseOverrideCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseOverrideCheck.cpp Mon Aug 31 08:17:43 2015
@@ -16,7 +16,7 @@ using namespace clang::ast_matchers;
 
 namespace clang {
 namespace tidy {
-namespace misc {
+namespace modernize {
 
 void UseOverrideCheck::registerMatchers(MatchFinder *Finder) {
   // Only register the matcher for C++11.
@@ -192,6 +192,6 @@ void UseOverrideCheck::check(const Match
   }
 }
 
-} // namespace misc
+} // namespace modernize
 } // namespace tidy
 } // namespace clang

Copied: clang-tools-extra/trunk/clang-tidy/modernize/UseOverrideCheck.h (from r246432, clang-tools-extra/trunk/clang-tidy/misc/UseOverrideCheck.h)
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseOverrideCheck.h?p2=clang-tools-extra/trunk/clang-tidy/modernize/UseOverrideCheck.h&p1=clang-tools-extra/trunk/clang-tidy/misc/UseOverrideCheck.h&r1=246432&r2=246437&rev=246437&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/misc/UseOverrideCheck.h (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseOverrideCheck.h Mon Aug 31 08:17:43 2015
@@ -7,14 +7,14 @@
 //
 //===----------------------------------------------------------------------===//
 
-#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_USEOVERRIDECHECK_H
-#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_USEOVERRIDECHECK_H
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_USEOVERRIDECHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_USEOVERRIDECHECK_H
 
 #include "../ClangTidy.h"
 
 namespace clang {
 namespace tidy {
-namespace misc {
+namespace modernize {
 
 /// Use C++11's `override` and remove `virtual` where applicable.
 class UseOverrideCheck : public ClangTidyCheck {
@@ -25,8 +25,8 @@ public:
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
 };
 
-} // namespace misc
+} // namespace modernize
 } // namespace tidy
 } // namespace clang
 
-#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_USEOVERRIDECHECK_H
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_USEOVERRIDECHECK_H

Modified: clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt?rev=246437&r1=246436&r2=246437&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt Mon Aug 31 08:17:43 2015
@@ -11,7 +11,6 @@ add_clang_library(clangTidyReadabilityMo
   ReadabilityTidyModule.cpp
   RedundantStringCStrCheck.cpp
   RedundantSmartptrGetCheck.cpp
-  ShrinkToFitCheck.cpp
   SimplifyBooleanExprCheck.cpp
 
   LINK_LIBS

Modified: clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp?rev=246437&r1=246436&r2=246437&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp Mon Aug 31 08:17:43 2015
@@ -18,7 +18,6 @@
 #include "NamedParameterCheck.h"
 #include "RedundantSmartptrGetCheck.h"
 #include "RedundantStringCStrCheck.h"
-#include "ShrinkToFitCheck.h"
 #include "SimplifyBooleanExprCheck.h"
 
 namespace clang {
@@ -44,8 +43,6 @@ public:
         "readability-redundant-smartptr-get");
     CheckFactories.registerCheck<RedundantStringCStrCheck>(
         "readability-redundant-string-cstr");
-    CheckFactories.registerCheck<ShrinkToFitCheck>(
-        "readability-shrink-to-fit");
     CheckFactories.registerCheck<SimplifyBooleanExprCheck>(
         "readability-simplify-boolean-expr");
   }

Removed: clang-tools-extra/trunk/clang-tidy/readability/ShrinkToFitCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/ShrinkToFitCheck.cpp?rev=246436&view=auto
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/readability/ShrinkToFitCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/readability/ShrinkToFitCheck.cpp (removed)
@@ -1,104 +0,0 @@
-//===--- ShrinkToFitCheck.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 "ShrinkToFitCheck.h"
-#include "clang/AST/ASTContext.h"
-#include "clang/ASTMatchers/ASTMatchFinder.h"
-#include "clang/Lex/Lexer.h"
-#include "llvm/ADT/StringRef.h"
-
-using namespace clang::ast_matchers;
-
-namespace clang {
-namespace {
-bool isShrinkableContainer(llvm::StringRef ClassName) {
-  static const char *Shrinkables[] = {
-    "std::basic_string",
-    "std::deque",
-    "std::vector"
-  };
-  return std::binary_search(std::begin(Shrinkables), std::end(Shrinkables),
-                            ClassName);
-}
-
-AST_MATCHER(NamedDecl, stlShrinkableContainer) {
-  return isShrinkableContainer(Node.getQualifiedNameAsString());
-}
-} // namespace
-
-namespace tidy {
-namespace readability {
-
-void ShrinkToFitCheck::registerMatchers(MatchFinder *Finder) {
-  // Swap as a function need not to be considered, because rvalue can not
-  // be bound to a non-const reference.
-  const auto ShrinkableAsMember =
-      memberExpr(member(valueDecl().bind("ContainerDecl")));
-  const auto ShrinkableAsDecl =
-      declRefExpr(hasDeclaration(valueDecl().bind("ContainerDecl")));
-  const auto CopyCtorCall = constructExpr(
-      hasArgument(0, anyOf(ShrinkableAsMember, ShrinkableAsDecl,
-                           unaryOperator(has(ShrinkableAsMember)),
-                           unaryOperator(has(ShrinkableAsDecl)))));
-  const auto SwapParam = expr(anyOf(
-      memberExpr(member(equalsBoundNode("ContainerDecl"))),
-      declRefExpr(hasDeclaration(equalsBoundNode("ContainerDecl"))),
-      unaryOperator(has(memberExpr(member(equalsBoundNode("ContainerDecl"))))),
-      unaryOperator(
-          has(declRefExpr(hasDeclaration(equalsBoundNode("ContainerDecl")))))));
-
-  Finder->addMatcher(
-      memberCallExpr(on(hasType(namedDecl(stlShrinkableContainer()))),
-                     callee(methodDecl(hasName("swap"))),
-                     has(memberExpr(hasDescendant(CopyCtorCall))),
-                     hasArgument(0, SwapParam.bind("ContainerToShrink")),
-                     unless(isInTemplateInstantiation()))
-          .bind("CopyAndSwapTrick"),
-      this);
-}
-
-void ShrinkToFitCheck::check(const MatchFinder::MatchResult &Result) {
-  const LangOptions &Opts = Result.Context->getLangOpts();
-
-  if (!Opts.CPlusPlus11)
-    return;
-
-  const auto *MemberCall =
-      Result.Nodes.getNodeAs<CXXMemberCallExpr>("CopyAndSwapTrick");
-  const auto *Container = Result.Nodes.getNodeAs<Expr>("ContainerToShrink");
-  FixItHint Hint;
-
-  if (!MemberCall->getLocStart().isMacroID()) {
-    std::string ReplacementText;
-    if (const auto *UnaryOp = llvm::dyn_cast<UnaryOperator>(Container)) {
-      ReplacementText =
-          Lexer::getSourceText(CharSourceRange::getTokenRange(
-                                   UnaryOp->getSubExpr()->getSourceRange()),
-                               *Result.SourceManager, Opts);
-      ReplacementText += "->shrink_to_fit()";
-    } else {
-      ReplacementText = Lexer::getSourceText(
-          CharSourceRange::getTokenRange(Container->getSourceRange()),
-          *Result.SourceManager, Opts);
-      ReplacementText += ".shrink_to_fit()";
-    }
-
-    Hint = FixItHint::CreateReplacement(MemberCall->getSourceRange(),
-                                        ReplacementText);
-  }
-
-  diag(MemberCall->getLocStart(), "the shrink_to_fit method should be used "
-                                  "to reduce the capacity of a shrinkable "
-                                  "container")
-      << Hint;
-}
-
-} // namespace readability
-} // namespace tidy
-} // namespace clang

Removed: clang-tools-extra/trunk/clang-tidy/readability/ShrinkToFitCheck.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/ShrinkToFitCheck.h?rev=246436&view=auto
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/readability/ShrinkToFitCheck.h (original)
+++ clang-tools-extra/trunk/clang-tidy/readability/ShrinkToFitCheck.h (removed)
@@ -1,37 +0,0 @@
-//===--- ShrinkToFitCheck.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_READABILITY_SHRINKTOFITCHECK_H
-#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_SHRINKTOFITCHECK_H
-
-#include "../ClangTidy.h"
-
-namespace clang {
-namespace tidy {
-namespace readability {
-
-/// Replace copy and swap tricks on shrinkable containers with the
-/// `shrink_to_fit()` method call.
-///
-/// The `shrink_to_fit()` method is more readable and more effective than
-/// the copy and swap trick to reduce the capacity of a shrinkable container.
-/// Note that, the `shrink_to_fit()` method is only available in C++11 and up.
-class ShrinkToFitCheck : public ClangTidyCheck {
-public:
-  ShrinkToFitCheck(StringRef Name, ClangTidyContext *Context)
-      : ClangTidyCheck(Name, Context) {}
-  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
-  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
-};
-
-} // namespace readability
-} // namespace tidy
-} // namespace clang
-
-#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_SHRINKTOFITCHECK_H

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=246437&r1=246436&r2=246437&view=diff
==============================================================================
--- clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst Mon Aug 31 08:17:43 2015
@@ -38,10 +38,11 @@ List of clang-tidy Checks
    misc-unused-alias-decls
    misc-unused-parameters
    misc-unused-raii
-   misc-use-override
    modernize-loop-convert
    modernize-pass-by-value
+   modernize-shrink-to-fit
    modernize-use-nullptr
+   modernize-use-override
    readability-braces-around-statements
    readability-container-size-empty
    readability-else-after-return
@@ -50,5 +51,4 @@ List of clang-tidy Checks
    readability-named-parameter
    readability-redundant-smartptr-get
    readability-redundant-string-cstr
-   readability-shrink-to-fit
-   readability-simplify-boolean-expr
\ No newline at end of file
+   readability-simplify-boolean-expr

Removed: clang-tools-extra/trunk/docs/clang-tidy/checks/misc-use-override.rst
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/misc-use-override.rst?rev=246436&view=auto
==============================================================================
--- clang-tools-extra/trunk/docs/clang-tidy/checks/misc-use-override.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/misc-use-override.rst (removed)
@@ -1,5 +0,0 @@
-misc-use-override
-=================
-
-
-Use C++11's ``override`` and remove ``virtual`` where applicable.

Copied: clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-override.rst (from r246432, clang-tools-extra/trunk/docs/clang-tidy/checks/misc-use-override.rst)
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-override.rst?p2=clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-override.rst&p1=clang-tools-extra/trunk/docs/clang-tidy/checks/misc-use-override.rst&r1=246432&r2=246437&rev=246437&view=diff
==============================================================================
--- clang-tools-extra/trunk/docs/clang-tidy/checks/misc-use-override.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-override.rst Mon Aug 31 08:17:43 2015
@@ -1,5 +1,5 @@
-misc-use-override
-=================
+modernize-use-override
+======================
 
 
 Use C++11's ``override`` and remove ``virtual`` where applicable.

Removed: clang-tools-extra/trunk/docs/clang-tidy/checks/readability-shrink-to-fit.rst
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/readability-shrink-to-fit.rst?rev=246436&view=auto
==============================================================================
--- clang-tools-extra/trunk/docs/clang-tidy/checks/readability-shrink-to-fit.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/readability-shrink-to-fit.rst (removed)
@@ -1,10 +0,0 @@
-readability-shrink-to-fit
-=========================
-
-
-Replace copy and swap tricks on shrinkable containers with the
-``shrink_to_fit()`` method call.
-
-The ``shrink_to_fit()`` method is more readable and more effective than
-the copy and swap trick to reduce the capacity of a shrinkable container.
-Note that, the ``shrink_to_fit()`` method is only available in C++11 and up.

Modified: clang-tools-extra/trunk/docs/clang-tidy/index.rst
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/index.rst?rev=246437&r1=246436&r2=246437&view=diff
==============================================================================
--- clang-tools-extra/trunk/docs/clang-tidy/index.rst (original)
+++ clang-tools-extra/trunk/docs/clang-tidy/index.rst Mon Aug 31 08:17:43 2015
@@ -53,8 +53,14 @@ There are currently the following groups
 * Checks related to the Google coding conventions have names starting with
   ``google-``.
 
-* Checks with names starting with ``misc-`` don't relate to any particular
-  coding style.
+* Checks named ``modernize-*`` advocate the usage of modern (currently "modern"
+  means "C++11") language constructs.
+
+* The ``readability-`` checks target readability-related issues that don't
+  relate to any particular coding style.
+
+* Checks with names starting with ``misc-`` the checks that we didn't have a
+  better category for.
 
 * Clang static analyzer checks are named starting with ``clang-analyzer-``.
 
@@ -494,8 +500,8 @@ The script provides multiple configurati
 
 * The default set of checks can be overridden using the ``-checks`` argument,
   taking the identical format as :program:`clang-tidy` does. For example
-  ``-checks=-*,misc-use-override`` will run the ``misc-use-override``
-  checker only.
+  ``-checks=-*,modernize-use-override`` will run the ``modernize-use-override``
+  check only.
 
 * To restrict the files examined you can provide one or more regex arguments
   that the file names are matched against.

Modified: clang-tools-extra/trunk/test/clang-tidy/clang-tidy-diff.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/clang-tidy-diff.cpp?rev=246437&r1=246436&r2=246437&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/clang-tidy-diff.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/clang-tidy-diff.cpp Mon Aug 31 08:17:43 2015
@@ -1,6 +1,6 @@
 // RUN: sed 's/placeholder_for_f/f/' %s > %t.cpp
-// RUN: clang-tidy -checks=-*,misc-use-override %t.cpp -- -std=c++11 | FileCheck -check-prefix=CHECK-SANITY %s
-// RUN: not diff -U0 %s %t.cpp | %python %S/../../clang-tidy/tool/clang-tidy-diff.py -checks=-*,misc-use-override -- -std=c++11 2>&1 | FileCheck %s
+// RUN: clang-tidy -checks=-*,modernize-use-override %t.cpp -- -std=c++11 | FileCheck -check-prefix=CHECK-SANITY %s
+// RUN: not diff -U0 %s %t.cpp | %python %S/../../clang-tidy/tool/clang-tidy-diff.py -checks=-*,modernize-use-override -- -std=c++11 2>&1 | FileCheck %s
 struct A {
   virtual void f() {}
   virtual void g() {}

Modified: clang-tools-extra/trunk/test/clang-tidy/diagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/diagnostic.cpp?rev=246437&r1=246436&r2=246437&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/diagnostic.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/diagnostic.cpp Mon Aug 31 08:17:43 2015
@@ -1,7 +1,7 @@
-// RUN: clang-tidy -checks='-*,misc-use-override' %s.nonexistent.cpp -- | FileCheck -check-prefix=CHECK1 %s
+// RUN: clang-tidy -checks='-*,modernize-use-override' %s.nonexistent.cpp -- | FileCheck -check-prefix=CHECK1 %s
 // RUN: clang-tidy -checks='-*,clang-diagnostic-*,google-explicit-constructor' %s -- -fan-unknown-option | FileCheck -check-prefix=CHECK2 %s
 // RUN: clang-tidy -checks='-*,google-explicit-constructor,clang-diagnostic-literal-conversion' %s -- -fan-unknown-option | FileCheck -check-prefix=CHECK3 %s
-// RUN: clang-tidy -checks='-*,misc-use-override,clang-diagnostic-macro-redefined' %s -- -DMACRO_FROM_COMMAND_LINE | FileCheck -check-prefix=CHECK4 %s
+// RUN: clang-tidy -checks='-*,modernize-use-override,clang-diagnostic-macro-redefined' %s -- -DMACRO_FROM_COMMAND_LINE | FileCheck -check-prefix=CHECK4 %s
 
 // CHECK1-NOT: warning
 // CHECK2-NOT: warning

Removed: clang-tools-extra/trunk/test/clang-tidy/misc-use-override-cxx98.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-use-override-cxx98.cpp?rev=246436&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-use-override-cxx98.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-use-override-cxx98.cpp (removed)
@@ -1,19 +0,0 @@
-// RUN: %python %S/check_clang_tidy.py %s misc-use-override %t -- -std=c++98
-
-struct Base {
-  virtual ~Base() {}
-  virtual void a();
-  virtual void b();
-};
-
-struct SimpleCases : public Base {
-public:
-  virtual ~SimpleCases();
-  // CHECK-FIXES: {{^}}  virtual ~SimpleCases();
-
-  void a();
-  // CHECK-FIXES: {{^}}  void a();
-
-  virtual void b();
-  // CHECK-FIXES: {{^}}  virtual void b();
-};

Removed: clang-tools-extra/trunk/test/clang-tidy/misc-use-override.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-use-override.cpp?rev=246436&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-use-override.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-use-override.cpp (removed)
@@ -1,274 +0,0 @@
-// RUN: %python %S/check_clang_tidy.py %s misc-use-override %t
-
-#define ABSTRACT = 0
-
-#define OVERRIDE override
-#define VIRTUAL virtual
-#define NOT_VIRTUAL
-#define NOT_OVERRIDE
-
-#define MUST_USE_RESULT __attribute__((warn_unused_result))
-#define UNUSED __attribute__((unused))
-
-struct MUST_USE_RESULT MustUseResultObject {};
-
-struct Base {
-  virtual ~Base() {}
-  virtual void a();
-  virtual void b();
-  virtual void c();
-  virtual void d();
-  virtual void d2();
-  virtual void e() = 0;
-  virtual void f() = 0;
-  virtual void g() = 0;
-
-  virtual void j() const;
-  virtual MustUseResultObject k();
-  virtual bool l() MUST_USE_RESULT UNUSED;
-  virtual bool n() MUST_USE_RESULT UNUSED;
-
-  virtual void m();
-  virtual void m2();
-  virtual void o() __attribute__((unused));
-
-  virtual void r() &;
-  virtual void rr() &&;
-
-  virtual void cv() const volatile;
-  virtual void cv2() const volatile;
-};
-
-struct SimpleCases : public Base {
-public:
-  virtual ~SimpleCases();
-  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: prefer using 'override' or (rarely) 'final' instead of 'virtual'
-  // CHECK-FIXES: {{^}}  ~SimpleCases() override;
-
-  void a();
-  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: annotate this
-  // CHECK-FIXES: {{^}}  void a() override;
-
-  void b() override;
-  // CHECK-MESSAGES-NOT: warning:
-  // CHECK-FIXES: {{^}}  void b() override;
-
-  virtual void c();
-  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
-  // CHECK-FIXES: {{^}}  void c() override;
-
-  virtual void d() override;
-  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: 'virtual' is redundant since the function is already declared 'override'
-  // CHECK-FIXES: {{^}}  void d() override;
-
-  virtual void d2() final;
-  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: 'virtual' is redundant since the function is already declared 'final'
-  // CHECK-FIXES: {{^}}  void d2() final;
-
-  virtual void e() = 0;
-  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
-  // CHECK-FIXES: {{^}}  void e() override = 0;
-
-  virtual void f()=0;
-  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
-  // CHECK-FIXES: {{^}}  void f()override =0;
-
-  virtual void g() ABSTRACT;
-  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
-  // CHECK-FIXES: {{^}}  void g() override ABSTRACT;
-
-  virtual void j() const;
-  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
-  // CHECK-FIXES: {{^}}  void j() const override;
-
-  virtual MustUseResultObject k();  // Has an implicit attribute.
-  // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: prefer using
-  // CHECK-FIXES: {{^}}  MustUseResultObject k() override;
-
-  virtual bool l() MUST_USE_RESULT UNUSED;
-  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
-  // CHECK-FIXES: {{^}}  bool l() override MUST_USE_RESULT UNUSED;
-
-  virtual bool n() UNUSED MUST_USE_RESULT;
-  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
-  // CHECK-FIXES: {{^}}  bool n() override UNUSED MUST_USE_RESULT;
-
-  void m() override final;
-  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: 'override' is redundant since the function is already declared 'final'
-  // CHECK-FIXES: {{^}}  void m() final;
-
-  virtual void m2() override final;
-  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: 'virtual' and 'override' are redundant since the function is already declared 'final'
-  // CHECK-FIXES: {{^}}  void m2() final;
-
-  virtual void o() __attribute__((unused));
-  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
-  // CHECK-FIXES: {{^}}  void o() override __attribute__((unused));
-};
-
-// CHECK-MESSAGES-NOT: warning:
-
-void SimpleCases::c() {}
-// CHECK-FIXES: {{^}}void SimpleCases::c() {}
-
-SimpleCases::~SimpleCases() {}
-// CHECK-FIXES: {{^}}SimpleCases::~SimpleCases() {}
-
-struct DefaultedDestructor : public Base {
-  DefaultedDestructor() {}
-  virtual ~DefaultedDestructor() = default;
-  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: prefer using
-  // CHECK-FIXES: {{^}}  ~DefaultedDestructor() override = default;
-};
-
-struct FinalSpecified : public Base {
-public:
-  virtual ~FinalSpecified() final;
-  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: 'virtual' is redundant since the function is already declared 'final'
-  // CHECK-FIXES: {{^}}  ~FinalSpecified() final;
-
-  void b() final;
-  // CHECK-MESSAGES-NOT: warning:
-  // CHECK-FIXES: {{^}}  void b() final;
-
-  virtual void d() final;
-  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: 'virtual' is redundant
-  // CHECK-FIXES: {{^}}  void d() final;
-
-  virtual void e() final = 0;
-  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: 'virtual' is redundant
-  // CHECK-FIXES: {{^}}  void e() final = 0;
-
-  virtual void j() const final;
-  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: 'virtual' is redundant
-  // CHECK-FIXES: {{^}}  void j() const final;
-
-  virtual bool l() final MUST_USE_RESULT UNUSED;
-  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: 'virtual' is redundant
-  // CHECK-FIXES: {{^}}  bool l() final MUST_USE_RESULT UNUSED;
-};
-
-struct InlineDefinitions : public Base {
-public:
-  virtual ~InlineDefinitions() {}
-  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: prefer using
-  // CHECK-FIXES: {{^}}  ~InlineDefinitions() override {}
-
-  void a() {}
-  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: annotate this
-  // CHECK-FIXES: {{^}}  void a() override {}
-
-  void b() override {}
-  // CHECK-MESSAGES-NOT: warning:
-  // CHECK-FIXES: {{^}}  void b() override {}
-
-  virtual void c()
-  {}
-  // CHECK-MESSAGES: :[[@LINE-2]]:16: warning: prefer using
-  // CHECK-FIXES: {{^}}  void c() override
-
-  virtual void d() override {}
-  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: 'virtual' is redundant
-  // CHECK-FIXES: {{^}}  void d() override {}
-
-  virtual void j() const
-  {}
-  // CHECK-MESSAGES: :[[@LINE-2]]:16: warning: prefer using
-  // CHECK-FIXES: {{^}}  void j() const override
-
-  virtual MustUseResultObject k() {}  // Has an implicit attribute.
-  // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: prefer using
-  // CHECK-FIXES: {{^}}  MustUseResultObject k() override {}
-
-  virtual bool l() MUST_USE_RESULT UNUSED {}
-  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
-  // CHECK-FIXES: {{^}}  bool l() override MUST_USE_RESULT UNUSED {}
-
-  virtual void r() &
-  {}
-  // CHECK-MESSAGES: :[[@LINE-2]]:16: warning: prefer using
-  // CHECK-FIXES: {{^}}  void r() & override
-
-  virtual void rr() &&
-  {}
-  // CHECK-MESSAGES: :[[@LINE-2]]:16: warning: prefer using
-  // CHECK-FIXES: {{^}}  void rr() && override
-
-  virtual void cv() const volatile
-  {}
-  // CHECK-MESSAGES: :[[@LINE-2]]:16: warning: prefer using
-  // CHECK-FIXES: {{^}}  void cv() const volatile override
-
-  virtual void cv2() const volatile // some comment
-  {}
-  // CHECK-MESSAGES: :[[@LINE-2]]:16: warning: prefer using
-  // CHECK-FIXES: {{^}}  void cv2() const volatile override // some comment
-};
-
-struct Macros : public Base {
-  // Tests for 'virtual' and 'override' being defined through macros. Basically
-  // give up for now.
-  NOT_VIRTUAL void a() NOT_OVERRIDE;
-  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: annotate this
-  // CHECK-FIXES: {{^}}  NOT_VIRTUAL void a() override NOT_OVERRIDE;
-
-  VIRTUAL void b() NOT_OVERRIDE;
-  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
-  // CHECK-FIXES: {{^}}  VIRTUAL void b() override NOT_OVERRIDE;
-
-  NOT_VIRTUAL void c() OVERRIDE;
-  // CHECK-MESSAGES-NOT: warning:
-  // CHECK-FIXES: {{^}}  NOT_VIRTUAL void c() OVERRIDE;
-
-  VIRTUAL void d() OVERRIDE;
-  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: 'virtual' is redundant
-  // CHECK-FIXES: {{^}}  VIRTUAL void d() OVERRIDE;
-
-#define FUNC(return_type, name) return_type name()
-  FUNC(void, e);
-  // CHECK-FIXES: {{^}}  FUNC(void, e);
-
-#define F virtual void f();
-  F
-  // CHECK-FIXES: {{^}}  F
-
-  VIRTUAL void g() OVERRIDE final;
-  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: 'virtual' and 'override' are redundant
-  // CHECK-FIXES: {{^}}  VIRTUAL void g() final;
-};
-
-// Tests for templates.
-template <typename T> struct TemplateBase {
-  virtual void f(T t);
-};
-
-template <typename T> struct DerivedFromTemplate : public TemplateBase<T> {
-  virtual void f(T t);
-  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: prefer using
-  // CHECK-FIXES: {{^}}  void f(T t) override;
-};
-void f() { DerivedFromTemplate<int>().f(2); }
-
-template <class C>
-struct UnusedMemberInstantiation : public C {
-  virtual ~UnusedMemberInstantiation() {}
-  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: prefer using
-  // CHECK-FIXES: {{^}}  ~UnusedMemberInstantiation() override {}
-};
-struct IntantiateWithoutUse : public UnusedMemberInstantiation<Base> {};
-
-struct Base2 {
-  virtual ~Base2() {}
-  virtual void a();
-};
-
-// The OverrideAttr isn't propagated to specializations in all cases. Make sure
-// we don't add "override" a second time.
-template <int I>
-struct MembersOfSpecializations : public Base2 {
-  void a() override;
-  // CHECK-MESSAGES-NOT: warning:
-  // CHECK-FIXES: {{^}}  void a() override;
-};
-template <> void MembersOfSpecializations<3>::a() {}
-void ff() { MembersOfSpecializations<3>().a(); };

Copied: clang-tools-extra/trunk/test/clang-tidy/modernize-shrink-to-fit.cpp (from r246432, clang-tools-extra/trunk/test/clang-tidy/readability-shrink-to-fit.cpp)
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-shrink-to-fit.cpp?p2=clang-tools-extra/trunk/test/clang-tidy/modernize-shrink-to-fit.cpp&p1=clang-tools-extra/trunk/test/clang-tidy/readability-shrink-to-fit.cpp&r1=246432&r2=246437&rev=246437&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/readability-shrink-to-fit.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-shrink-to-fit.cpp Mon Aug 31 08:17:43 2015
@@ -1,4 +1,4 @@
-// RUN: %python %S/check_clang_tidy.py %s readability-shrink-to-fit %t
+// RUN: %python %S/check_clang_tidy.py %s modernize-shrink-to-fit %t
 
 namespace std {
 template <typename T> struct vector { void swap(vector &other); };
@@ -8,7 +8,7 @@ void f() {
   std::vector<int> v;
 
   std::vector<int>(v).swap(v);
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: the shrink_to_fit method should be used to reduce the capacity of a shrinkable container [readability-shrink-to-fit] 
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: the shrink_to_fit method should be used to reduce the capacity of a shrinkable container [modernize-shrink-to-fit] 
   // CHECK-FIXES: {{^  }}v.shrink_to_fit();{{$}}
 
   std::vector<int> &vref = v;

Copied: clang-tools-extra/trunk/test/clang-tidy/modernize-use-override-cxx98.cpp (from r246432, clang-tools-extra/trunk/test/clang-tidy/misc-use-override-cxx98.cpp)
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-override-cxx98.cpp?p2=clang-tools-extra/trunk/test/clang-tidy/modernize-use-override-cxx98.cpp&p1=clang-tools-extra/trunk/test/clang-tidy/misc-use-override-cxx98.cpp&r1=246432&r2=246437&rev=246437&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-use-override-cxx98.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-override-cxx98.cpp Mon Aug 31 08:17:43 2015
@@ -1,4 +1,4 @@
-// RUN: %python %S/check_clang_tidy.py %s misc-use-override %t -- -std=c++98
+// RUN: %python %S/check_clang_tidy.py %s modernize-use-override %t -- -std=c++98
 
 struct Base {
   virtual ~Base() {}

Copied: clang-tools-extra/trunk/test/clang-tidy/modernize-use-override.cpp (from r246432, clang-tools-extra/trunk/test/clang-tidy/misc-use-override.cpp)
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-override.cpp?p2=clang-tools-extra/trunk/test/clang-tidy/modernize-use-override.cpp&p1=clang-tools-extra/trunk/test/clang-tidy/misc-use-override.cpp&r1=246432&r2=246437&rev=246437&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-use-override.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-override.cpp Mon Aug 31 08:17:43 2015
@@ -1,4 +1,4 @@
-// RUN: %python %S/check_clang_tidy.py %s misc-use-override %t
+// RUN: %python %S/check_clang_tidy.py %s modernize-use-override %t
 
 #define ABSTRACT = 0
 
@@ -42,7 +42,7 @@ struct Base {
 struct SimpleCases : public Base {
 public:
   virtual ~SimpleCases();
-  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: prefer using 'override' or (rarely) 'final' instead of 'virtual'
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: prefer using 'override' or (rarely) 'final' instead of 'virtual' [modernize-use-override]
   // CHECK-FIXES: {{^}}  ~SimpleCases() override;
 
   void a();

Removed: clang-tools-extra/trunk/test/clang-tidy/readability-shrink-to-fit.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-shrink-to-fit.cpp?rev=246436&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/readability-shrink-to-fit.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/readability-shrink-to-fit.cpp (removed)
@@ -1,74 +0,0 @@
-// RUN: %python %S/check_clang_tidy.py %s readability-shrink-to-fit %t
-
-namespace std {
-template <typename T> struct vector { void swap(vector &other); };
-}
-
-void f() {
-  std::vector<int> v;
-
-  std::vector<int>(v).swap(v);
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: the shrink_to_fit method should be used to reduce the capacity of a shrinkable container [readability-shrink-to-fit] 
-  // CHECK-FIXES: {{^  }}v.shrink_to_fit();{{$}}
-
-  std::vector<int> &vref = v;
-  std::vector<int>(vref).swap(vref);
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: the shrink_to_fit method should
-  // CHECK-FIXES: {{^  }}vref.shrink_to_fit();{{$}}
-
-  std::vector<int> *vptr = &v;
-  std::vector<int>(*vptr).swap(*vptr);
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: the shrink_to_fit method should
-  // CHECK-FIXES: {{^  }}vptr->shrink_to_fit();{{$}}
-}
-
-struct X {
-  std::vector<int> v;
-  void f() {
-    std::vector<int>(v).swap(v);
-    // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: the shrink_to_fit method should
-    // CHECK-FIXES: {{^    }}v.shrink_to_fit();{{$}}
-
-    std::vector<int> *vptr = &v;
-    std::vector<int>(*vptr).swap(*vptr);
-    // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: the shrink_to_fit method should
-    // CHECK-FIXES: {{^    }}vptr->shrink_to_fit();{{$}}
-  }
-};
-
-template <typename T> void g() {
-  std::vector<int> v;
-  std::vector<int>(v).swap(v);
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: the shrink_to_fit method should 
-  // CHECK-FIXES: {{^  }}v.shrink_to_fit();{{$}}
-
-  std::vector<T> v2;
-  std::vector<T>(v2).swap(v2);
-  // CHECK-FIXES: {{^  }}std::vector<T>(v2).swap(v2);{{$}}
-}
-
-template <typename T> void g2() {
-  std::vector<int> v;
-  std::vector<int>(v).swap(v);
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: the shrink_to_fit method should 
-  // CHECK-FIXES: {{^  }}v.shrink_to_fit();{{$}}
-
-  T v3;
-  T(v3).swap(v3);
-  // CHECK-FIXES: {{^  }}T(v3).swap(v3);{{$}}
-}
-
-#define COPY_AND_SWAP_INT_VEC(x) std::vector<int>(x).swap(x)
-// CHECK-FIXES: #define COPY_AND_SWAP_INT_VEC(x) std::vector<int>(x).swap(x)
-
-void h() {
-  g<int>();
-  g<double>();
-  g<bool>();
-  g2<std::vector<int>>();
-  std::vector<int> v;
-  COPY_AND_SWAP_INT_VEC(v);
-  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: the shrink_to_fit method should 
-  // CHECK-FIXES: {{^  }}COPY_AND_SWAP_INT_VEC(v);{{$}}
-}
-




More information about the cfe-commits mailing list