forked from OSchip/llvm-project
[clang-tidy] Refactor: Move misc clang-tidy checks to namespace clang::tidy::misc
clang-tidy checks are organized into modules. This refactoring moves the misc module checks into the namespace clang::tidy::misc http://reviews.llvm.org/D7996 Patch by Richard Thomson! llvm-svn: 230950
This commit is contained in:
parent
39ccabe500
commit
2b312420aa
|
@ -17,6 +17,7 @@ using namespace clang::ast_matchers;
|
|||
|
||||
namespace clang {
|
||||
namespace tidy {
|
||||
namespace misc {
|
||||
|
||||
ArgumentCommentCheck::ArgumentCommentCheck(StringRef Name,
|
||||
ClangTidyContext *Context)
|
||||
|
@ -181,5 +182,6 @@ void ArgumentCommentCheck::check(const MatchFinder::MatchResult &Result) {
|
|||
}
|
||||
}
|
||||
|
||||
} // namespace misc
|
||||
} // namespace tidy
|
||||
} // namespace clang
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
namespace clang {
|
||||
namespace tidy {
|
||||
namespace misc {
|
||||
|
||||
/// \brief Checks that argument comments match parameter names.
|
||||
class ArgumentCommentCheck : public ClangTidyCheck {
|
||||
|
@ -36,6 +37,7 @@ private:
|
|||
llvm::ArrayRef<const Expr *> Args);
|
||||
};
|
||||
|
||||
} // namespace misc
|
||||
} // namespace tidy
|
||||
} // namespace clang
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ using namespace clang::ast_matchers;
|
|||
|
||||
namespace clang {
|
||||
namespace tidy {
|
||||
namespace misc {
|
||||
|
||||
void AssignOperatorSignatureCheck::registerMatchers(
|
||||
ast_matchers::MatchFinder *Finder) {
|
||||
|
@ -63,5 +64,6 @@ void AssignOperatorSignatureCheck::check(
|
|||
}
|
||||
}
|
||||
|
||||
} // namespace misc
|
||||
} // namespace tidy
|
||||
} // namespace clang
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
namespace clang {
|
||||
namespace tidy {
|
||||
namespace misc {
|
||||
|
||||
/// \brief Finds declarations of assign operators with the wrong return and/or
|
||||
/// argument types.
|
||||
|
@ -29,6 +30,7 @@ public:
|
|||
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
|
||||
};
|
||||
|
||||
} // namespace misc
|
||||
} // namespace tidy
|
||||
} // namespace clang
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ AST_MATCHER(QualType, isBoolean) { return Node->isBooleanType(); }
|
|||
} // namespace ast_matchers
|
||||
|
||||
namespace tidy {
|
||||
namespace misc {
|
||||
|
||||
void BoolPointerImplicitConversion::registerMatchers(MatchFinder *Finder) {
|
||||
// Look for ifs that have an implicit bool* to bool conversion in the
|
||||
|
@ -71,5 +72,6 @@ BoolPointerImplicitConversion::check(const MatchFinder::MatchResult &Result) {
|
|||
<< FixItHint::CreateInsertion(Var->getLocStart(), "*");
|
||||
}
|
||||
|
||||
} // namespace misc
|
||||
} // namespace tidy
|
||||
} // namespace clang
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
namespace clang {
|
||||
namespace tidy {
|
||||
namespace misc {
|
||||
|
||||
/// \brief Checks for conditions based on implicit conversion from a bool
|
||||
/// pointer to bool e.g.
|
||||
|
@ -29,6 +30,7 @@ public:
|
|||
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
|
||||
};
|
||||
|
||||
} // namespace misc
|
||||
} // namespace tidy
|
||||
} // namespace clang
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ using namespace clang::ast_matchers;
|
|||
|
||||
namespace clang {
|
||||
namespace tidy {
|
||||
namespace misc {
|
||||
|
||||
void InaccurateEraseCheck::registerMatchers(MatchFinder *Finder) {
|
||||
const auto CheckForEndCall = hasArgument(
|
||||
|
@ -60,5 +61,6 @@ void InaccurateEraseCheck::check(const MatchFinder::MatchResult &Result) {
|
|||
<< Hint;
|
||||
}
|
||||
|
||||
} // namespace misc
|
||||
} // namespace tidy
|
||||
} // namespace clang
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
namespace clang {
|
||||
namespace tidy {
|
||||
namespace misc {
|
||||
|
||||
/// \brief Checks for inaccurate use of \c erase() method.
|
||||
///
|
||||
|
@ -30,6 +31,7 @@ public:
|
|||
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
|
||||
};
|
||||
|
||||
} // namespace misc
|
||||
} // namespace tidy
|
||||
} // namespace clang
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ using namespace clang::ast_matchers;
|
|||
|
||||
namespace clang {
|
||||
namespace tidy {
|
||||
namespace misc {
|
||||
|
||||
static bool areTypesCompatible(QualType Left, QualType Right) {
|
||||
if (const auto *LeftRefType = Left->getAs<ReferenceType>())
|
||||
|
@ -123,5 +124,6 @@ void InefficientAlgorithmCheck::check(const MatchFinder::MatchResult &Result) {
|
|||
<< Hint;
|
||||
}
|
||||
|
||||
} // namespace misc
|
||||
} // namespace tidy
|
||||
} // namespace clang
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
namespace clang {
|
||||
namespace tidy {
|
||||
namespace misc {
|
||||
|
||||
/// \brief Warns on inefficient use of STL algorithms on associative containers.
|
||||
///
|
||||
|
@ -28,6 +29,7 @@ public:
|
|||
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
|
||||
};
|
||||
|
||||
} // namespace misc
|
||||
} // namespace tidy
|
||||
} // namespace clang
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
namespace clang {
|
||||
namespace tidy {
|
||||
namespace misc {
|
||||
|
||||
class MiscModule : public ClangTidyModule {
|
||||
public:
|
||||
|
@ -53,8 +54,10 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
} // namespace misc
|
||||
|
||||
// Register the MiscTidyModule using this statically initialized variable.
|
||||
static ClangTidyModuleRegistry::Add<MiscModule>
|
||||
static ClangTidyModuleRegistry::Add<misc::MiscModule>
|
||||
X("misc-module", "Adds miscellaneous lint checks.");
|
||||
|
||||
// This anchor is used to force the linker to link in the generated object file
|
||||
|
|
|
@ -16,6 +16,7 @@ using namespace clang::ast_matchers;
|
|||
|
||||
namespace clang {
|
||||
namespace tidy {
|
||||
namespace misc {
|
||||
|
||||
void SwappedArgumentsCheck::registerMatchers(MatchFinder *Finder) {
|
||||
Finder->addMatcher(callExpr().bind("call"), this);
|
||||
|
@ -121,5 +122,6 @@ void SwappedArgumentsCheck::check(const MatchFinder::MatchResult &Result) {
|
|||
}
|
||||
}
|
||||
|
||||
} // namespace misc
|
||||
} // namespace tidy
|
||||
} // namespace clang
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
namespace clang {
|
||||
namespace tidy {
|
||||
namespace misc {
|
||||
|
||||
/// \brief Finds potentially swapped arguments by looking at implicit
|
||||
/// conversions.
|
||||
|
@ -25,8 +26,8 @@ public:
|
|||
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
|
||||
};
|
||||
|
||||
} // namespace misc
|
||||
} // namespace tidy
|
||||
} // namespace clang
|
||||
|
||||
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_SWAPPED_ARGUMENTS_CHECK_H
|
||||
|
||||
|
|
|
@ -46,6 +46,7 @@ AST_MATCHER_P(CXXRecordDecl, baseOfBoundNode, std::string, ID) {
|
|||
} // namespace ast_matchers
|
||||
|
||||
namespace tidy {
|
||||
namespace misc {
|
||||
|
||||
void UndelegatedConstructorCheck::registerMatchers(MatchFinder *Finder) {
|
||||
// We look for calls to constructors of the same type in constructors. To do
|
||||
|
@ -70,5 +71,6 @@ void UndelegatedConstructorCheck::check(const MatchFinder::MatchResult &Result)
|
|||
"A temporary object is created here instead");
|
||||
}
|
||||
|
||||
} // namespace misc
|
||||
} // namespace tidy
|
||||
} // namespace clang
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
namespace clang {
|
||||
namespace tidy {
|
||||
namespace misc {
|
||||
|
||||
/// \brief Finds creation of temporary objects in constructors that look like a
|
||||
/// function call to another constructor of the same class. The user most likely
|
||||
|
@ -26,6 +27,7 @@ public:
|
|||
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
|
||||
};
|
||||
|
||||
} // namespace misc
|
||||
} // namespace tidy
|
||||
} // namespace clang
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ using namespace clang::ast_matchers;
|
|||
|
||||
namespace clang {
|
||||
namespace tidy {
|
||||
namespace misc {
|
||||
|
||||
void UniqueptrResetRelease::registerMatchers(MatchFinder *Finder) {
|
||||
Finder->addMatcher(
|
||||
|
@ -62,5 +63,6 @@ void UniqueptrResetRelease::check(const MatchFinder::MatchResult &Result) {
|
|||
CharSourceRange::getTokenRange(ResetCall->getSourceRange()), NewText);
|
||||
}
|
||||
|
||||
} // namespace misc
|
||||
} // namespace tidy
|
||||
} // namespace clang
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
namespace clang {
|
||||
namespace tidy {
|
||||
namespace misc {
|
||||
|
||||
/// \brief Find and replace unique_ptr::reset(release()) with std::move
|
||||
///
|
||||
|
@ -32,6 +33,7 @@ public:
|
|||
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
|
||||
};
|
||||
|
||||
} // namespace misc
|
||||
} // namespace tidy
|
||||
} // namespace clang
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ AST_MATCHER(CXXRecordDecl, hasUserDeclaredDestructor) {
|
|||
} // namespace ast_matchers
|
||||
|
||||
namespace tidy {
|
||||
namespace misc {
|
||||
|
||||
void UnusedRAIICheck::registerMatchers(MatchFinder *Finder) {
|
||||
// Look for temporaries that are constructed in-place and immediately
|
||||
|
@ -79,5 +80,6 @@ void UnusedRAIICheck::check(const MatchFinder::MatchResult &Result) {
|
|||
Replacement);
|
||||
}
|
||||
|
||||
} // namespace misc
|
||||
} // namespace tidy
|
||||
} // namespace clang
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
namespace clang {
|
||||
namespace tidy {
|
||||
namespace misc {
|
||||
|
||||
/// \brief Finds temporaries that look like RAII objects.
|
||||
///
|
||||
|
@ -43,6 +44,7 @@ public:
|
|||
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
|
||||
};
|
||||
|
||||
} // namespace misc
|
||||
} // namespace tidy
|
||||
} // namespace clang
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ using namespace clang::ast_matchers;
|
|||
|
||||
namespace clang {
|
||||
namespace tidy {
|
||||
namespace misc {
|
||||
|
||||
void UseOverride::registerMatchers(MatchFinder *Finder) {
|
||||
Finder->addMatcher(methodDecl(isOverride()).bind("method"), this);
|
||||
|
@ -175,5 +176,6 @@ void UseOverride::check(const MatchFinder::MatchResult &Result) {
|
|||
}
|
||||
}
|
||||
|
||||
} // namespace misc
|
||||
} // namespace tidy
|
||||
} // namespace clang
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
namespace clang {
|
||||
namespace tidy {
|
||||
namespace misc {
|
||||
|
||||
/// \brief Use C++11's 'override' and remove 'virtual' where applicable.
|
||||
class UseOverride : public ClangTidyCheck {
|
||||
|
@ -24,8 +25,8 @@ public:
|
|||
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
|
||||
};
|
||||
|
||||
} // namespace misc
|
||||
} // namespace tidy
|
||||
} // namespace clang
|
||||
|
||||
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_USE_OVERRIDE_H
|
||||
|
||||
|
|
|
@ -6,6 +6,8 @@ namespace clang {
|
|||
namespace tidy {
|
||||
namespace test {
|
||||
|
||||
using misc::ArgumentCommentCheck;
|
||||
|
||||
TEST(ArgumentCommentCheckTest, CorrectComments) {
|
||||
EXPECT_NO_CHANGES(ArgumentCommentCheck,
|
||||
"void f(int x, int y); void g() { f(/*x=*/0, /*y=*/0); }");
|
||||
|
|
Loading…
Reference in New Issue