[clang-tools-extra] 63dfe70 - [clang-tidy][NFC] move AST_MATCHER to anonymous namespace in InfiniteLoopCheck (#118820)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Dec 5 14:46:07 PST 2024
Author: Congcong Cai
Date: 2024-12-06T06:46:03+08:00
New Revision: 63dfe70b224b562f4e5a4e8367353127684584df
URL: https://github.com/llvm/llvm-project/commit/63dfe70b224b562f4e5a4e8367353127684584df
DIFF: https://github.com/llvm/llvm-project/commit/63dfe70b224b562f4e5a4e8367353127684584df.diff
LOG: [clang-tidy][NFC] move AST_MATCHER to anonymous namespace in InfiniteLoopCheck (#118820)
Added:
Modified:
clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp
index 2b2d80ea9346bd..b7f0c08b2a7d4b 100644
--- a/clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp
@@ -13,13 +13,15 @@
#include "clang/Analysis/Analyses/ExprMutationAnalyzer.h"
#include "clang/Analysis/CallGraph.h"
#include "llvm/ADT/SCCIterator.h"
-#include "llvm/ADT/SmallVector.h"
using namespace clang::ast_matchers;
+using clang::ast_matchers::internal::Matcher;
using clang::tidy::utils::hasPtrOrReferenceInFunc;
namespace clang {
-namespace ast_matchers {
+namespace tidy::bugprone {
+
+namespace {
/// matches a Decl if it has a "no return" attribute of any kind
AST_MATCHER(Decl, declHasNoReturnAttr) {
return Node.hasAttr<NoReturnAttr>() || Node.hasAttr<CXX11NoReturnAttr>() ||
@@ -30,23 +32,21 @@ AST_MATCHER(Decl, declHasNoReturnAttr) {
AST_MATCHER(FunctionType, typeHasNoReturnAttr) {
return Node.getNoReturnAttr();
}
-} // namespace ast_matchers
-namespace tidy::bugprone {
+} // namespace
-static internal::Matcher<Stmt>
-loopEndingStmt(internal::Matcher<Stmt> Internal) {
- internal::Matcher<QualType> isNoReturnFunType =
+static Matcher<Stmt> loopEndingStmt(Matcher<Stmt> Internal) {
+ Matcher<QualType> IsNoReturnFunType =
ignoringParens(functionType(typeHasNoReturnAttr()));
- internal::Matcher<Decl> isNoReturnDecl =
- anyOf(declHasNoReturnAttr(), functionDecl(hasType(isNoReturnFunType)),
- varDecl(hasType(blockPointerType(pointee(isNoReturnFunType)))));
+ Matcher<Decl> IsNoReturnDecl =
+ anyOf(declHasNoReturnAttr(), functionDecl(hasType(IsNoReturnFunType)),
+ varDecl(hasType(blockPointerType(pointee(IsNoReturnFunType)))));
return stmt(anyOf(
mapAnyOf(breakStmt, returnStmt, gotoStmt, cxxThrowExpr).with(Internal),
callExpr(Internal,
callee(mapAnyOf(functionDecl, /* block callee */ varDecl)
- .with(isNoReturnDecl))),
- objcMessageExpr(Internal, callee(isNoReturnDecl))));
+ .with(IsNoReturnDecl))),
+ objcMessageExpr(Internal, callee(IsNoReturnDecl))));
}
/// Return whether `Var` was changed in `LoopStmt`.
More information about the cfe-commits
mailing list