mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-08 09:03:18 +00:00
[tidy] Move private ast matchers into anonymous namespaces to avoid ODR conflicts.
No functionality change intended. llvm-svn: 325467
This commit is contained in:
parent
adf6e88c74
commit
f8c99297d3
@ -15,10 +15,12 @@ namespace clang {
|
||||
namespace tidy {
|
||||
namespace boost {
|
||||
|
||||
namespace {
|
||||
AST_MATCHER(Type, isStrictlyInteger) {
|
||||
return Node.isIntegerType() && !Node.isAnyCharacterType() &&
|
||||
!Node.isBooleanType();
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void UseToStringCheck::registerMatchers(MatchFinder *Finder) {
|
||||
if (!getLangOpts().CPlusPlus)
|
||||
|
@ -18,9 +18,11 @@ namespace clang {
|
||||
namespace tidy {
|
||||
namespace bugprone {
|
||||
|
||||
namespace {
|
||||
AST_MATCHER_P(IntegerLiteral, isBiggerThan, unsigned, N) {
|
||||
return Node.getValue().getZExtValue() > N;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
StringConstructorCheck::StringConstructorCheck(StringRef Name,
|
||||
ClangTidyContext *Context)
|
||||
|
@ -19,11 +19,13 @@ namespace clang {
|
||||
namespace tidy {
|
||||
namespace bugprone {
|
||||
|
||||
namespace {
|
||||
AST_MATCHER(CXXMethodDecl, isStatic) { return Node.isStatic(); }
|
||||
|
||||
AST_MATCHER(CXXMethodDecl, isOverloadedOperator) {
|
||||
return Node.isOverloadedOperator();
|
||||
}
|
||||
} // namespace
|
||||
|
||||
/// Finds out if the given method overrides some method.
|
||||
static bool isOverrideMethod(const CXXMethodDecl *MD) {
|
||||
|
@ -17,9 +17,11 @@ namespace clang {
|
||||
namespace tidy {
|
||||
namespace cppcoreguidelines {
|
||||
|
||||
namespace {
|
||||
AST_MATCHER(GotoStmt, isForwardJumping) {
|
||||
return Node.getLocStart() < Node.getLabel()->getLocStart();
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void AvoidGotoCheck::registerMatchers(MatchFinder *Finder) {
|
||||
if (!getLangOpts().CPlusPlus)
|
||||
|
@ -17,6 +17,7 @@ namespace clang {
|
||||
namespace tidy {
|
||||
namespace cppcoreguidelines {
|
||||
|
||||
namespace {
|
||||
AST_MATCHER_P(CXXForRangeStmt, hasRangeBeginEndStmt,
|
||||
ast_matchers::internal::Matcher<DeclStmt>, InnerMatcher) {
|
||||
for (const DeclStmt *Stmt : {Node.getBeginStmt(), Node.getEndStmt()})
|
||||
@ -46,6 +47,7 @@ AST_MATCHER_P(Expr, hasParentIgnoringImpCasts,
|
||||
|
||||
return InnerMatcher.matches(*E, Finder, Builder);
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void ProBoundsArrayToPointerDecayCheck::registerMatchers(MatchFinder *Finder) {
|
||||
if (!getLangOpts().CPlusPlus)
|
||||
|
@ -17,12 +17,14 @@ using namespace clang::ast_matchers;
|
||||
namespace clang {
|
||||
namespace tidy {
|
||||
namespace fuchsia {
|
||||
|
||||
|
||||
namespace {
|
||||
AST_MATCHER(CXXRecordDecl, hasBases) {
|
||||
if (Node.hasDefinition())
|
||||
return Node.getNumBases() > 0;
|
||||
return false;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
// Adds a node (by name) to the interface map, if it was not present in the map
|
||||
// previously.
|
||||
|
@ -15,6 +15,7 @@ namespace clang {
|
||||
namespace tidy {
|
||||
namespace fuchsia {
|
||||
|
||||
namespace {
|
||||
AST_MATCHER(FunctionDecl, isFuchsiaOverloadedOperator) {
|
||||
if (const auto *CXXMethodNode = dyn_cast<CXXMethodDecl>(&Node)) {
|
||||
if (CXXMethodNode->isCopyAssignmentOperator() ||
|
||||
@ -23,6 +24,7 @@ AST_MATCHER(FunctionDecl, isFuchsiaOverloadedOperator) {
|
||||
}
|
||||
return Node.isOverloadedOperator();
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void OverloadedOperatorCheck::registerMatchers(MatchFinder *Finder) {
|
||||
Finder->addMatcher(functionDecl(isFuchsiaOverloadedOperator()).bind("decl"),
|
||||
|
@ -14,7 +14,8 @@ using namespace clang::ast_matchers;
|
||||
namespace clang {
|
||||
namespace tidy {
|
||||
namespace fuchsia {
|
||||
|
||||
|
||||
namespace {
|
||||
AST_MATCHER(Expr, isConstantInitializer) {
|
||||
return Node.isConstantInitializer(Finder->getASTContext(), false);
|
||||
}
|
||||
@ -22,7 +23,8 @@ AST_MATCHER(Expr, isConstantInitializer) {
|
||||
AST_MATCHER(VarDecl, isGlobalStatic) {
|
||||
return Node.getStorageDuration() == SD_Static && !Node.isLocalVarDecl();
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
void StaticallyConstructedObjectsCheck::registerMatchers(MatchFinder *Finder) {
|
||||
// Constructing global, non-trivial objects with static storage is
|
||||
// disallowed, unless the object is statically initialized with a constexpr
|
||||
|
@ -15,18 +15,16 @@
|
||||
using namespace clang::ast_matchers;
|
||||
|
||||
namespace clang {
|
||||
namespace ast_matchers {
|
||||
|
||||
const internal::VariadicDynCastAllOfMatcher<Type, DecltypeType> decltypeType;
|
||||
|
||||
} // namespace ast_matchers
|
||||
|
||||
namespace tidy {
|
||||
namespace fuchsia {
|
||||
|
||||
namespace {
|
||||
const internal::VariadicDynCastAllOfMatcher<Type, DecltypeType> decltypeType;
|
||||
|
||||
AST_MATCHER(FunctionDecl, hasTrailingReturn) {
|
||||
return Node.getType()->castAs<FunctionProtoType>()->hasTrailingReturn();
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void TrailingReturnCheck::registerMatchers(MatchFinder *Finder) {
|
||||
|
||||
|
@ -17,6 +17,7 @@ namespace clang {
|
||||
namespace tidy {
|
||||
namespace fuchsia {
|
||||
|
||||
namespace {
|
||||
AST_MATCHER(CXXRecordDecl, hasDirectVirtualBaseClass) {
|
||||
if (!Node.hasDefinition()) return false;
|
||||
if (!Node.getNumVBases()) return false;
|
||||
@ -24,6 +25,7 @@ AST_MATCHER(CXXRecordDecl, hasDirectVirtualBaseClass) {
|
||||
if (Base.isVirtual()) return true;
|
||||
return false;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void VirtualInheritanceCheck::registerMatchers(MatchFinder *Finder) {
|
||||
// Defining classes using direct virtual inheritance is disallowed.
|
||||
|
@ -13,18 +13,17 @@
|
||||
|
||||
using namespace clang::ast_matchers;
|
||||
|
||||
namespace clang {
|
||||
namespace ast_matchers {
|
||||
AST_MATCHER(VarDecl, isAsm) { return Node.hasAttr<clang::AsmLabelAttr>(); }
|
||||
const internal::VariadicDynCastAllOfMatcher<Decl, FileScopeAsmDecl>
|
||||
fileScopeAsmDecl;
|
||||
}
|
||||
}
|
||||
|
||||
namespace clang {
|
||||
namespace tidy {
|
||||
namespace hicpp {
|
||||
|
||||
namespace {
|
||||
AST_MATCHER(VarDecl, isAsm) { return Node.hasAttr<clang::AsmLabelAttr>(); }
|
||||
const ast_matchers::internal::VariadicDynCastAllOfMatcher<Decl,
|
||||
FileScopeAsmDecl>
|
||||
fileScopeAsmDecl;
|
||||
} // namespace
|
||||
|
||||
void NoAssemblerCheck::registerMatchers(MatchFinder *Finder) {
|
||||
Finder->addMatcher(asmStmt().bind("asm-stmt"), this);
|
||||
Finder->addMatcher(fileScopeAsmDecl().bind("asm-file-scope"), this);
|
||||
|
@ -17,12 +17,14 @@ namespace clang {
|
||||
namespace tidy {
|
||||
namespace misc {
|
||||
|
||||
namespace {
|
||||
AST_MATCHER(StringLiteral, containsNul) {
|
||||
for (size_t i = 0; i < Node.getLength(); ++i)
|
||||
if (Node.getCodeUnit(i) == '\0')
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
void StringLiteralWithEmbeddedNulCheck::registerMatchers(MatchFinder *Finder) {
|
||||
// Match a string that contains embedded NUL character. Extra-checks are
|
||||
|
@ -23,6 +23,7 @@ namespace clang {
|
||||
namespace tidy {
|
||||
namespace modernize {
|
||||
|
||||
namespace {
|
||||
/// \brief Matches move-constructible classes.
|
||||
///
|
||||
/// Given
|
||||
@ -44,6 +45,7 @@ AST_MATCHER(CXXRecordDecl, isMoveConstructible) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
static TypeMatcher constRefType() {
|
||||
return lValueReferenceType(pointee(isConstQualified()));
|
||||
|
@ -21,6 +21,7 @@ namespace clang {
|
||||
namespace tidy {
|
||||
namespace modernize {
|
||||
|
||||
namespace {
|
||||
static const char AutoPtrTokenId[] = "AutoPrTokenId";
|
||||
static const char AutoPtrOwnershipTransferId[] = "AutoPtrOwnershipTransferId";
|
||||
|
||||
@ -69,6 +70,8 @@ AST_MATCHER(Decl, isFromStdNamespace) {
|
||||
return (Info && Info->isStr("std"));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
ReplaceAutoPtrCheck::ReplaceAutoPtrCheck(StringRef Name,
|
||||
ClangTidyContext *Context)
|
||||
: ClangTidyCheck(Name, Context),
|
||||
|
Loading…
Reference in New Issue
Block a user