CheckFactories.registerCheck<google::build::UnnamedNamespaceInHeaderCheck>(
"cert-dcl59-cpp");
// OOP
- CheckFactories.registerCheck<MoveConstructorInitCheck>(
+ CheckFactories.registerCheck<misc::MoveConstructorInitCheck>(
"cert-oop11-cpp");
// ERR
CheckFactories.registerCheck<SetLongJmpCheck>(
"cert-err58-cpp");
CheckFactories.registerCheck<ThrownExceptionTypeCheck>(
"cert-err60-cpp");
- CheckFactories.registerCheck<ThrowByValueCatchByReferenceCheck>(
+ CheckFactories.registerCheck<misc::ThrowByValueCatchByReferenceCheck>(
"cert-err61-cpp");
// C checkers
// DCL
- CheckFactories.registerCheck<StaticAssertCheck>(
+ CheckFactories.registerCheck<misc::StaticAssertCheck>(
"cert-dcl03-c");
// ENV
CheckFactories.registerCheck<CommandProcessorCheck>(
CheckFactories.registerCheck<FloatLoopCounter>(
"cert-flp30-c");
// FIO
- CheckFactories.registerCheck<NonCopyableObjectsCheck>(
+ CheckFactories.registerCheck<misc::NonCopyableObjectsCheck>(
"cert-fio38-c");
// ERR
CheckFactories.registerCheck<StrToNumCheck>(
namespace clang {
namespace tidy {
+namespace cppcoreguidelines {
AST_MATCHER_P(CXXForRangeStmt, hasRangeBeginEndStmt,
ast_matchers::internal::Matcher<DeclStmt>, InnerMatcher) {
"an explicit cast instead");
}
+} // namespace cppcoreguidelines
} // namespace tidy
} // namespace clang
namespace clang {
namespace tidy {
-
+namespace cppcoreguidelines {
+
/// This check flags all array to pointer decays
///
/// For the user-facing documentation see:
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
};
+} // namespace cppcoreguidelines
} // namespace tidy
} // namespace clang
namespace clang {
namespace tidy {
+namespace cppcoreguidelines {
ProBoundsConstantArrayIndexCheck::ProBoundsConstantArrayIndexCheck(
StringRef Name, ClangTidyContext *Context)
}
}
+} // namespace cppcoreguidelines
} // namespace tidy
} // namespace clang
namespace clang {
namespace tidy {
+namespace cppcoreguidelines {
/// This checks that all array subscriptions on static arrays and std::arrays
/// have a constant index and are within bounds
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
};
+} // namespace cppcoreguidelines
} // namespace tidy
} // namespace clang
namespace clang {
namespace tidy {
+namespace cppcoreguidelines {
void ProBoundsPointerArithmeticCheck::registerMatchers(MatchFinder *Finder) {
if (!getLangOpts().CPlusPlus)
diag(MatchedExpr->getExprLoc(), "do not use pointer arithmetic");
}
+} // namespace cppcoreguidelines
} // namespace tidy
} // namespace clang
namespace clang {
namespace tidy {
+namespace cppcoreguidelines {
/// Flags all kinds of pointer arithmetic that have result of pointer type, i.e.
/// +, -, +=, -=, ++, --. In addition, the [] operator on pointers (not on arrays) is flagged.
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
};
+} // namespace cppcoreguidelines
} // namespace tidy
} // namespace clang
namespace clang {
namespace tidy {
-
+namespace cppcoreguidelines {
+
void ProTypeConstCastCheck::registerMatchers(MatchFinder *Finder) {
if (!getLangOpts().CPlusPlus)
return;
diag(MatchedCast->getOperatorLoc(), "do not use const_cast");
}
+} // namespace cppcoreguidelines
} // namespace tidy
} // namespace clang
namespace clang {
namespace tidy {
-
+namespace cppcoreguidelines {
+
/// This check flags all instances of const_cast
///
/// For the user-facing documentation see:
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
};
+} // namespace cppcoreguidelines
} // namespace tidy
} // namespace clang
namespace clang {
namespace tidy {
+namespace cppcoreguidelines {
static bool needsConstCast(QualType SourceType, QualType DestType) {
SourceType = SourceType.getNonReferenceType();
}
}
+} // namespace cppcoreguidelines
} // namespace tidy
} // namespace clang
namespace clang {
namespace tidy {
+namespace cppcoreguidelines {
/// This check flags all use of C-style casts that perform a static_cast
/// downcast, const_cast, or reinterpret_cast.
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
};
+} // namespace cppcoreguidelines
} // namespace tidy
} // namespace clang
namespace clang {
namespace tidy {
+namespace cppcoreguidelines {
void ProTypeReinterpretCastCheck::registerMatchers(MatchFinder *Finder) {
if (!getLangOpts().CPlusPlus)
diag(MatchedCast->getOperatorLoc(), "do not use reinterpret_cast");
}
+} // namespace cppcoreguidelines
} // namespace tidy
} // namespace clang
namespace clang {
namespace tidy {
+namespace cppcoreguidelines {
/// Flags all occurrences of reinterpret_cast
///
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
};
+} // namespace cppcoreguidelines
} // namespace tidy
} // namespace clang
namespace clang {
namespace tidy {
-
+namespace cppcoreguidelines {
+
void ProTypeStaticCastDowncastCheck::registerMatchers(MatchFinder *Finder) {
if (!getLangOpts().CPlusPlus)
return;
"do not use static_cast to downcast from a base to a derived class");
}
+} // namespace cppcoreguidelines
} // namespace tidy
} // namespace clang
namespace clang {
namespace tidy {
-
+namespace cppcoreguidelines {
+
/// Checks for usages of static_cast, where a base class is downcasted to a derived class.
///
/// For the user-facing documentation see:
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
};
+} // namespace cppcoreguidelines
} // namespace tidy
} // namespace clang
namespace clang {
namespace tidy {
+namespace cppcoreguidelines {
void ProTypeUnionAccessCheck::registerMatchers(MatchFinder *Finder) {
if (!getLangOpts().CPlusPlus)
diag(Matched->getMemberLoc(), "do not access members of unions; use (boost::)variant instead");
}
+} // namespace cppcoreguidelines
} // namespace tidy
} // namespace clang
namespace clang {
namespace tidy {
+namespace cppcoreguidelines {
/// This check flags all access to members of unions.
/// Access to a union as a whole (e.g. passing to a function) is not flagged.
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
};
+} // namespace cppcoreguidelines
} // namespace tidy
} // namespace clang
namespace clang {
namespace tidy {
+namespace cppcoreguidelines {
const internal::VariadicDynCastAllOfMatcher<Stmt, VAArgExpr> vAArgExpr;
}
}
+} // namespace cppcoreguidelines
} // namespace tidy
} // namespace clang
namespace clang {
namespace tidy {
+namespace cppcoreguidelines {
/// This check flags all calls to c-style variadic functions and all use
/// of va_arg.
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
};
+} // namespace cppcoreguidelines
} // namespace tidy
} // namespace clang
using namespace clang::ast_matchers;
namespace clang {
+namespace tidy {
+namespace misc {
+
namespace {
AST_MATCHER_P(Expr, hasSideEffect, bool, CheckFunctionCalls) {
} // namespace
-namespace tidy {
-
AssertSideEffectCheck::AssertSideEffectCheck(StringRef Name,
ClangTidyContext *Context)
: ClangTidyCheck(Name, Context),
diag(Loc, "found %0() with side effect") << AssertMacroName;
}
+} // namespace misc
} // namespace tidy
} // namespace clang
namespace clang {
namespace tidy {
+namespace misc {
/// Finds `assert()` with side effect.
///
SmallVector<StringRef, 5> AssertMacros;
};
+} // namespace misc
} // namespace tidy
} // namespace clang
using namespace clang::ast_matchers;
namespace clang {
+namespace tidy {
+namespace misc {
+
namespace {
AST_MATCHER(CastExpr, isPointerToBoolean) {
} // namespace
-namespace tidy {
-namespace misc {
-
void BoolPointerImplicitConversionCheck::registerMatchers(MatchFinder *Finder) {
// Look for ifs that have an implicit bool* to bool conversion in the
// condition. Filter negations.
#include "clang/ASTMatchers/ASTMatchers.h"
#include "clang/Lex/Lexer.h"
+using namespace clang::ast_matchers;
+
namespace clang {
-namespace ast_matchers {
+namespace tidy {
+namespace misc {
+
+namespace {
AST_MATCHER(FloatingLiteral, floatHalf) {
const auto &literal = Node.getValue();
if ((&Node.getSemantics()) == &llvm::APFloat::IEEEsingle)
return literal.convertToDouble() == 0.5;
return false;
}
-} // namespace ast_matchers
-} // namespace clang
+} // namespace
-using namespace clang::ast_matchers;
-namespace clang {
-namespace tidy {
-namespace misc {
void IncorrectRoundings::registerMatchers(MatchFinder *MatchFinder) {
// Match a floating literal with value 0.5.
auto FloatHalf = floatLiteral(floatHalf());
namespace clang {
namespace tidy {
+namespace misc {
namespace {
class MacroParenthesesPPCallbacks : public PPCallbacks {
&Compiler.getPreprocessor(), this));
}
+} // namespace misc
} // namespace tidy
} // namespace clang
namespace clang {
namespace tidy {
+namespace misc {
/// Finds macros that can have unexpected behaviour due to missing parentheses.
///
void registerPPCallbacks(CompilerInstance &Compiler) override;
};
+} // namespace misc
} // namespace tidy
} // namespace clang
#include "MoveConstantArgumentCheck.h"
-#include <clang/Lex/Lexer.h>
+#include "clang/Lex/Lexer.h"
+
+using namespace clang::ast_matchers;
namespace clang {
namespace tidy {
namespace misc {
-using namespace ast_matchers;
-
void MoveConstantArgumentCheck::registerMatchers(MatchFinder *Finder) {
if (!getLangOpts().CPlusPlus)
return;
namespace clang {
namespace tidy {
+namespace misc {
namespace {
Options.store(Opts, "IncludeStyle", IncludeSorter::toString(IncludeStyle));
}
+} // namespace misc
} // namespace tidy
} // namespace clang
namespace clang {
namespace tidy {
+namespace misc {
/// The check flags user-defined move constructors that have a ctor-initializer
/// initializing a member or base class through a copy constructor instead of a
const bool UseCERTSemantics;
};
+} // namespace misc
} // namespace tidy
} // namespace clang
using namespace clang::ast_matchers;
namespace clang {
+namespace tidy {
+namespace misc {
+
namespace {
+
AST_MATCHER(FunctionDecl, isPlacementOverload) {
bool New;
switch (Node.getOverloadedOperator()) {
return true;
}
-} // namespace
-namespace tidy {
-namespace misc {
-
-namespace {
OverloadedOperatorKind getCorrespondingOverload(const FunctionDecl *FD) {
switch (FD->getOverloadedOperator()) {
default: break;
return false;
}
+
} // anonymous namespace
void NewDeleteOverloadsCheck::registerMatchers(MatchFinder *Finder) {
namespace clang {
namespace tidy {
+namespace misc {
void NoexceptMoveConstructorCheck::registerMatchers(MatchFinder *Finder) {
// Only register the matchers for C++11; the functionality currently does not
}
}
+} // namespace misc
} // namespace tidy
} // namespace clang
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`
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
};
+} // namespace misc
} // namespace tidy
} // namespace clang
using namespace clang::ast_matchers;
namespace clang {
+namespace tidy {
+namespace misc {
+
namespace {
// FIXME: it would be good to make a list that is also user-configurable so that
// users can add their own elements to the list. However, it may require some
}
} // namespace
-namespace tidy {
void NonCopyableObjectsCheck::registerMatchers(MatchFinder *Finder) {
// There are two ways to get into trouble with objects like FILE *:
// dereferencing the pointer type to be a non-pointer type, and declaring
<< BD;
}
+} // namespace misc
} // namespace tidy
} // namespace clang
namespace clang {
namespace tidy {
+namespace misc {
/// The check flags dereferences and non-pointer declarations of objects that
/// are not meant to be passed by value, such as C FILE objects.
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
};
+} // namespace misc
} // namespace tidy
} // namespace clang
namespace clang {
namespace tidy {
+namespace misc {
void SizeofContainerCheck::registerMatchers(MatchFinder *Finder) {
Finder->addMatcher(
"container; did you mean .size()?");
}
+} // namespace misc
} // namespace tidy
} // namespace clang
namespace clang {
namespace tidy {
+namespace misc {
/// Find usages of sizeof on expressions of STL container types. Most likely the
/// user wanted to use `.size()` instead.
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
};
+} // namespace misc
} // namespace tidy
} // namespace clang
namespace clang {
namespace tidy {
+namespace misc {
StaticAssertCheck::StaticAssertCheck(StringRef Name, ClangTidyContext *Context)
: ClangTidyCheck(Name, Context) {}
return Token.getLocation();
}
+} // namespace misc
} // namespace tidy
} // namespace clang
namespace clang {
namespace tidy {
+namespace misc {
/// Replaces `assert()` with `static_assert()` if the condition is evaluatable
/// at compile time.
SourceLocation AssertLoc);
};
+} // namespace misc
} // namespace tidy
} // namespace clang
namespace clang {
namespace tidy {
+namespace misc {
void StringIntegerAssignmentCheck::registerMatchers(MatchFinder *Finder) {
if (!getLangOpts().CPlusPlus)
}
}
+} // namespace misc
} // namespace tidy
} // namespace clang
namespace clang {
namespace tidy {
+namespace misc {
/// Finds instances where an integer is assigned to a string.
///
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
};
+} // namespace misc
} // namespace tidy
} // namespace clang
namespace clang {
namespace tidy {
+namespace misc {
ThrowByValueCatchByReferenceCheck::ThrowByValueCatchByReferenceCheck(
StringRef Name, ClangTidyContext *Context)
}
}
+} // namespace misc
} // namespace tidy
} // namespace clang
namespace clang {
namespace tidy {
+namespace misc {
///\brief checks for locations that do not throw by value
// or catch by reference.
const bool CheckAnonymousTemporaries;
};
+} // namespace misc
} // namespace tidy
} // namespace clang
using namespace clang::ast_matchers;
namespace clang {
+namespace tidy {
+namespace misc {
namespace {
AST_MATCHER_P(Stmt, ignoringTemporaryExpr,
}
} // namespace
-namespace tidy {
-namespace misc {
-
void UndelegatedConstructorCheck::registerMatchers(MatchFinder *Finder) {
// We look for calls to constructors of the same type in constructors. To do
// this we have to look through a variety of nodes that occur in the path,
namespace clang {
namespace tidy {
+namespace misc {
void UnusedAliasDeclsCheck::registerMatchers(MatchFinder *Finder) {
// Only register the matchers for C++11; the functionality currently does not
}
}
+} // namespace misc
} // namespace tidy
} // namespace clang
namespace clang {
namespace tidy {
+namespace misc {
/// Finds unused namespace alias declarations.
class UnusedAliasDeclsCheck : public ClangTidyCheck {
llvm::DenseMap<const NamedDecl *, CharSourceRange> FoundDecls;
};
+} // namespace misc
} // namespace tidy
} // namespace clang
namespace clang {
namespace tidy {
+namespace misc {
+
namespace {
bool isOverrideMethod(const FunctionDecl *Function) {
if (const auto *MD = dyn_cast<CXXMethodDecl>(Function))
}
}
+} // namespace misc
} // namespace tidy
} // namespace clang
namespace clang {
namespace tidy {
+namespace misc {
/// Finds unused parameters and fixes them, so that `-Wunused-parameter` can be
/// turned on.
const FunctionDecl *Function, unsigned ParamIndex);
};
+} // namespace misc
} // namespace tidy
} // namespace clang
using namespace clang::ast_matchers;
namespace clang {
+namespace tidy {
+namespace misc {
+
namespace {
AST_MATCHER(CXXRecordDecl, hasNonTrivialDestructor) {
// TODO: If the dtor is there but empty we don't want to warn either.
}
} // namespace
-namespace tidy {
-namespace misc {
-
void UnusedRAIICheck::registerMatchers(MatchFinder *Finder) {
// Only register the matchers for C++; the functionality currently does not
// provide any benefit to other languages, despite being benign.
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_RAW_STRING_LITERAL_H
#include "../ClangTidy.h"
-//#include <string>
namespace clang {
namespace tidy {
using namespace clang::ast_matchers;
namespace clang {
+namespace tidy {
+namespace modernize {
namespace {
} // namespace
-namespace tidy {
-namespace modernize {
-
void RedundantVoidArgCheck::registerMatchers(MatchFinder *Finder) {
Finder->addMatcher(functionDecl(parameterCountIs(0), unless(isImplicit()),
unless(isExternC()))
#include "../utils/FixItHintUtils.h"
#include "../utils/TypeTraits.h"
+using namespace clang::ast_matchers;
+
namespace clang {
namespace tidy {
namespace performance {
-using namespace ::clang::ast_matchers;
-
ForRangeCopyCheck::ForRangeCopyCheck(StringRef Name, ClangTidyContext *Context)
: ClangTidyCheck(Name, Context),
WarnOnAllAutoCopies(Options.get("WarnOnAllAutoCopies", 0)) {}
#include "clang/ASTMatchers/ASTMatchers.h"
#include "clang/Lex/Lexer.h"
-namespace clang {
-
-using namespace ast_matchers;
+using namespace clang::ast_matchers;
+namespace clang {
namespace tidy {
namespace performance {
namespace clang {
namespace tidy {
+namespace readability {
namespace {
}
}
+} // namespace readability
} // namespace tidy
} // namespace clang
namespace clang {
namespace tidy {
+namespace readability {
/// \brief Checks for use of implicit bool casts in expressions.
///
bool AllowConditionalPointerCasts;
};
+} // namespace readability
} // namespace tidy
} // namespace clang
#include <functional>
#include <sstream>
+using namespace clang::ast_matchers;
+
namespace clang {
namespace tidy {
namespace readability {
-using namespace ast_matchers;
-
namespace {
AST_MATCHER(FunctionDecl, hasOtherDeclarations) {
#include "RedundantStringCStrCheck.h"
#include "clang/Lex/Lexer.h"
-namespace clang {
+using namespace clang::ast_matchers;
-using namespace ast_matchers;
+namespace clang {
+namespace tidy {
+namespace readability {
namespace {
} // end namespace
-namespace tidy {
-namespace readability {
-
void RedundantStringCStrCheck::registerMatchers(
ast_matchers::MatchFinder *Finder) {
// Only register the matchers for C++; the functionality currently does not
namespace clang {
namespace tidy {
+namespace readability {
void UniqueptrDeleteReleaseCheck::registerMatchers(MatchFinder *Finder) {
auto IsSusbstituted = qualType(anyOf(
" = nullptr");
}
+} // namespace readability
} // namespace tidy
} // namespace clang
namespace clang {
namespace tidy {
+namespace readability {
/// Flag statements of the form: delete <unique_ptr expr>.release()
/// and replace them with: <unique_ptr expr> = nullptr
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
};
+} // namespace readability
} // namespace tidy
} // namespace clang