Skip to content

Commit

Permalink
[clang-tidy] Cleaning namespaces to be more consistant across checkers.
Browse files Browse the repository at this point in the history
Summary:
The goal of the patch is to bring checkers in their appropriate namespace.
This path doesn't change any behavior.

Reviewers: alexfh

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D19811

llvm-svn: 268264
  • Loading branch information
bergeret committed May 2, 2016
1 parent 93529ed commit 456177b
Showing 57 changed files with 137 additions and 52 deletions.
8 changes: 4 additions & 4 deletions clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@ class CERTModule : public ClangTidyModule {
CheckFactories.registerCheck<google::build::UnnamedNamespaceInHeaderCheck>(
"cert-dcl59-cpp");
// OOP
CheckFactories.registerCheck<MoveConstructorInitCheck>(
CheckFactories.registerCheck<misc::MoveConstructorInitCheck>(
"cert-oop11-cpp");
// ERR
CheckFactories.registerCheck<SetLongJmpCheck>(
@@ -49,12 +49,12 @@ class CERTModule : public ClangTidyModule {
"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>(
@@ -63,7 +63,7 @@ class CERTModule : public ClangTidyModule {
CheckFactories.registerCheck<FloatLoopCounter>(
"cert-flp30-c");
// FIO
CheckFactories.registerCheck<NonCopyableObjectsCheck>(
CheckFactories.registerCheck<misc::NonCopyableObjectsCheck>(
"cert-fio38-c");
// ERR
CheckFactories.registerCheck<StrToNumCheck>(
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ using namespace clang::ast_matchers;

namespace clang {
namespace tidy {
namespace cppcoreguidelines {

AST_MATCHER_P(CXXForRangeStmt, hasRangeBeginEndStmt,
ast_matchers::internal::Matcher<DeclStmt>, InnerMatcher) {
@@ -74,5 +75,6 @@ void ProBoundsArrayToPointerDecayCheck::check(
"an explicit cast instead");
}

} // namespace cppcoreguidelines
} // namespace tidy
} // namespace clang
Original file line number Diff line number Diff line change
@@ -14,7 +14,8 @@

namespace clang {
namespace tidy {

namespace cppcoreguidelines {

/// This check flags all array to pointer decays
///
/// For the user-facing documentation see:
@@ -27,6 +28,7 @@ class ProBoundsArrayToPointerDecayCheck : public ClangTidyCheck {
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
};

} // namespace cppcoreguidelines
} // namespace tidy
} // namespace clang

Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@ using namespace clang::ast_matchers;

namespace clang {
namespace tidy {
namespace cppcoreguidelines {

ProBoundsConstantArrayIndexCheck::ProBoundsConstantArrayIndexCheck(
StringRef Name, ClangTidyContext *Context)
@@ -128,5 +129,6 @@ void ProBoundsConstantArrayIndexCheck::check(
}
}

} // namespace cppcoreguidelines
} // namespace tidy
} // namespace clang
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@

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
@@ -34,6 +35,7 @@ class ProBoundsConstantArrayIndexCheck : public ClangTidyCheck {
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
};

} // namespace cppcoreguidelines
} // namespace tidy
} // namespace clang

Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ using namespace clang::ast_matchers;

namespace clang {
namespace tidy {
namespace cppcoreguidelines {

void ProBoundsPointerArithmeticCheck::registerMatchers(MatchFinder *Finder) {
if (!getLangOpts().CPlusPlus)
@@ -53,5 +54,6 @@ ProBoundsPointerArithmeticCheck::check(const MatchFinder::MatchResult &Result) {
diag(MatchedExpr->getExprLoc(), "do not use pointer arithmetic");
}

} // namespace cppcoreguidelines
} // namespace tidy
} // namespace clang
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@

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.
@@ -28,6 +29,7 @@ class ProBoundsPointerArithmeticCheck : public ClangTidyCheck {
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
};

} // namespace cppcoreguidelines
} // namespace tidy
} // namespace clang

Original file line number Diff line number Diff line change
@@ -15,7 +15,8 @@ using namespace clang::ast_matchers;

namespace clang {
namespace tidy {

namespace cppcoreguidelines {

void ProTypeConstCastCheck::registerMatchers(MatchFinder *Finder) {
if (!getLangOpts().CPlusPlus)
return;
@@ -28,5 +29,6 @@ void ProTypeConstCastCheck::check(const MatchFinder::MatchResult &Result) {
diag(MatchedCast->getOperatorLoc(), "do not use const_cast");
}

} // namespace cppcoreguidelines
} // namespace tidy
} // namespace clang
Original file line number Diff line number Diff line change
@@ -14,7 +14,8 @@

namespace clang {
namespace tidy {

namespace cppcoreguidelines {

/// This check flags all instances of const_cast
///
/// For the user-facing documentation see:
@@ -27,6 +28,7 @@ class ProTypeConstCastCheck : public ClangTidyCheck {
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
};

} // namespace cppcoreguidelines
} // namespace tidy
} // namespace clang

Original file line number Diff line number Diff line change
@@ -16,6 +16,7 @@ using namespace clang::ast_matchers;

namespace clang {
namespace tidy {
namespace cppcoreguidelines {

static bool needsConstCast(QualType SourceType, QualType DestType) {
SourceType = SourceType.getNonReferenceType();
@@ -103,5 +104,6 @@ void ProTypeCstyleCastCheck::check(const MatchFinder::MatchResult &Result) {
}
}

} // namespace cppcoreguidelines
} // namespace tidy
} // namespace clang
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@

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.
@@ -28,6 +29,7 @@ class ProTypeCstyleCastCheck : public ClangTidyCheck {
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
};

} // namespace cppcoreguidelines
} // namespace tidy
} // namespace clang

Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ using namespace clang::ast_matchers;

namespace clang {
namespace tidy {
namespace cppcoreguidelines {

void ProTypeReinterpretCastCheck::registerMatchers(MatchFinder *Finder) {
if (!getLangOpts().CPlusPlus)
@@ -30,5 +31,6 @@ void ProTypeReinterpretCastCheck::check(
diag(MatchedCast->getOperatorLoc(), "do not use reinterpret_cast");
}

} // namespace cppcoreguidelines
} // namespace tidy
} // namespace clang
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@

namespace clang {
namespace tidy {
namespace cppcoreguidelines {

/// Flags all occurrences of reinterpret_cast
///
@@ -27,6 +28,7 @@ class ProTypeReinterpretCastCheck : public ClangTidyCheck {
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
};

} // namespace cppcoreguidelines
} // namespace tidy
} // namespace clang

Original file line number Diff line number Diff line change
@@ -15,7 +15,8 @@ using namespace clang::ast_matchers;

namespace clang {
namespace tidy {

namespace cppcoreguidelines {

void ProTypeStaticCastDowncastCheck::registerMatchers(MatchFinder *Finder) {
if (!getLangOpts().CPlusPlus)
return;
@@ -48,5 +49,6 @@ void ProTypeStaticCastDowncastCheck::check(const MatchFinder::MatchResult &Resul
"do not use static_cast to downcast from a base to a derived class");
}

} // namespace cppcoreguidelines
} // namespace tidy
} // namespace clang
Original file line number Diff line number Diff line change
@@ -14,7 +14,8 @@

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:
@@ -27,6 +28,7 @@ class ProTypeStaticCastDowncastCheck : public ClangTidyCheck {
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
};

} // namespace cppcoreguidelines
} // namespace tidy
} // namespace clang

Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ using namespace clang::ast_matchers;

namespace clang {
namespace tidy {
namespace cppcoreguidelines {

void ProTypeUnionAccessCheck::registerMatchers(MatchFinder *Finder) {
if (!getLangOpts().CPlusPlus)
@@ -28,6 +29,7 @@ void ProTypeUnionAccessCheck::check(const MatchFinder::MatchResult &Result) {
diag(Matched->getMemberLoc(), "do not access members of unions; use (boost::)variant instead");
}

} // namespace cppcoreguidelines
} // namespace tidy
} // namespace clang

Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@

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.
@@ -28,6 +29,7 @@ class ProTypeUnionAccessCheck : public ClangTidyCheck {
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
};

} // namespace cppcoreguidelines
} // namespace tidy
} // namespace clang

Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ using namespace clang::ast_matchers;

namespace clang {
namespace tidy {
namespace cppcoreguidelines {

const internal::VariadicDynCastAllOfMatcher<Stmt, VAArgExpr> vAArgExpr;

@@ -72,5 +73,6 @@ void ProTypeVarargCheck::check(const MatchFinder::MatchResult &Result) {
}
}

} // namespace cppcoreguidelines
} // namespace tidy
} // namespace clang
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@

namespace clang {
namespace tidy {
namespace cppcoreguidelines {

/// This check flags all calls to c-style variadic functions and all use
/// of va_arg.
@@ -28,6 +29,7 @@ class ProTypeVarargCheck : public ClangTidyCheck {
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
};

} // namespace cppcoreguidelines
} // namespace tidy
} // namespace clang

6 changes: 4 additions & 2 deletions clang-tools-extra/clang-tidy/misc/AssertSideEffectCheck.cpp
Original file line number Diff line number Diff line change
@@ -21,6 +21,9 @@
using namespace clang::ast_matchers;

namespace clang {
namespace tidy {
namespace misc {

namespace {

AST_MATCHER_P(Expr, hasSideEffect, bool, CheckFunctionCalls) {
@@ -66,8 +69,6 @@ AST_MATCHER_P(Expr, hasSideEffect, bool, CheckFunctionCalls) {

} // namespace

namespace tidy {

AssertSideEffectCheck::AssertSideEffectCheck(StringRef Name,
ClangTidyContext *Context)
: ClangTidyCheck(Name, Context),
@@ -121,5 +122,6 @@ void AssertSideEffectCheck::check(const MatchFinder::MatchResult &Result) {
diag(Loc, "found %0() with side effect") << AssertMacroName;
}

} // namespace misc
} // namespace tidy
} // namespace clang
2 changes: 2 additions & 0 deletions clang-tools-extra/clang-tidy/misc/AssertSideEffectCheck.h
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@

namespace clang {
namespace tidy {
namespace misc {

/// Finds `assert()` with side effect.
///
@@ -44,6 +45,7 @@ class AssertSideEffectCheck : public ClangTidyCheck {
SmallVector<StringRef, 5> AssertMacros;
};

} // namespace misc
} // namespace tidy
} // namespace clang

Original file line number Diff line number Diff line change
@@ -12,6 +12,9 @@
using namespace clang::ast_matchers;

namespace clang {
namespace tidy {
namespace misc {

namespace {

AST_MATCHER(CastExpr, isPointerToBoolean) {
@@ -20,9 +23,6 @@ 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.
Loading

0 comments on commit 456177b

Please sign in to comment.