[clang-tools-extra] e8158bf - [NFC] Clean up braces and anon namespace
Nathan James via cfe-commits
cfe-commits at lists.llvm.org
Sun Jul 5 03:16:51 PDT 2020
Author: Nathan James
Date: 2020-07-05T11:16:40+01:00
New Revision: e8158bf0e770e7a4cf73df91552af1e156a3ea17
URL: https://github.com/llvm/llvm-project/commit/e8158bf0e770e7a4cf73df91552af1e156a3ea17
DIFF: https://github.com/llvm/llvm-project/commit/e8158bf0e770e7a4cf73df91552af1e156a3ea17.diff
LOG: [NFC] Clean up braces and anon namespace
Added:
Modified:
clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp
Removed:
################################################################################
diff --git a/clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp b/clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp
index 98ca34eb620c..9ad6fb737ec9 100644
--- a/clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp
+++ b/clang-tools-extra/clang-tidy/readability/ElseAfterReturnCheck.cpp
@@ -19,7 +19,6 @@ namespace clang {
namespace tidy {
namespace readability {
-namespace {
static const char ReturnStr[] = "return";
static const char ContinueStr[] = "continue";
static const char BreakStr[] = "break";
@@ -28,44 +27,40 @@ static const char WarningMessage[] = "do not use 'else' after '%0'";
static const char WarnOnUnfixableStr[] = "WarnOnUnfixable";
static const char WarnOnConditionVariablesStr[] = "WarnOnConditionVariables";
-const DeclRefExpr *findUsage(const Stmt *Node, int64_t DeclIdentifier) {
+static const DeclRefExpr *findUsage(const Stmt *Node, int64_t DeclIdentifier) {
if (!Node)
return nullptr;
if (const auto *DeclRef = dyn_cast<DeclRefExpr>(Node)) {
- if (DeclRef->getDecl()->getID() == DeclIdentifier) {
+ if (DeclRef->getDecl()->getID() == DeclIdentifier)
return DeclRef;
- }
} else {
for (const Stmt *ChildNode : Node->children()) {
- if (const DeclRefExpr *Result = findUsage(ChildNode, DeclIdentifier)) {
+ if (const DeclRefExpr *Result = findUsage(ChildNode, DeclIdentifier))
return Result;
- }
}
}
return nullptr;
}
-const DeclRefExpr *
+static const DeclRefExpr *
findUsageRange(const Stmt *Node,
- const llvm::iterator_range<int64_t *> &DeclIdentifiers) {
+ const llvm::ArrayRef<int64_t> &DeclIdentifiers) {
if (!Node)
return nullptr;
if (const auto *DeclRef = dyn_cast<DeclRefExpr>(Node)) {
- if (llvm::is_contained(DeclIdentifiers, DeclRef->getDecl()->getID())) {
+ if (llvm::is_contained(DeclIdentifiers, DeclRef->getDecl()->getID()))
return DeclRef;
- }
} else {
for (const Stmt *ChildNode : Node->children()) {
if (const DeclRefExpr *Result =
- findUsageRange(ChildNode, DeclIdentifiers)) {
+ findUsageRange(ChildNode, DeclIdentifiers))
return Result;
- }
}
}
return nullptr;
}
-const DeclRefExpr *checkInitDeclUsageInElse(const IfStmt *If) {
+static const DeclRefExpr *checkInitDeclUsageInElse(const IfStmt *If) {
const auto *InitDeclStmt = dyn_cast_or_null<DeclStmt>(If->getInit());
if (!InitDeclStmt)
return nullptr;
@@ -82,25 +77,23 @@ const DeclRefExpr *checkInitDeclUsageInElse(const IfStmt *If) {
return findUsageRange(If->getElse(), DeclIdentifiers);
}
-const DeclRefExpr *checkConditionVarUsageInElse(const IfStmt *If) {
- const VarDecl *CondVar = If->getConditionVariable();
- return CondVar != nullptr ? findUsage(If->getElse(), CondVar->getID())
- : nullptr;
+static const DeclRefExpr *checkConditionVarUsageInElse(const IfStmt *If) {
+ if (const VarDecl *CondVar = If->getConditionVariable())
+ return findUsage(If->getElse(), CondVar->getID());
+ return nullptr;
}
-bool containsDeclInScope(const Stmt *Node) {
- if (isa<DeclStmt>(Node)) {
+static bool containsDeclInScope(const Stmt *Node) {
+ if (isa<DeclStmt>(Node))
return true;
- }
- if (const auto *Compound = dyn_cast<CompoundStmt>(Node)) {
+ if (const auto *Compound = dyn_cast<CompoundStmt>(Node))
return llvm::any_of(Compound->body(), [](const Stmt *SubNode) {
return isa<DeclStmt>(SubNode);
});
- }
return false;
}
-void removeElseAndBrackets(DiagnosticBuilder &Diag, ASTContext &Context,
+static void removeElseAndBrackets(DiagnosticBuilder &Diag, ASTContext &Context,
const Stmt *Else, SourceLocation ElseLoc) {
auto Remap = [&](SourceLocation Loc) {
return Context.getSourceManager().getExpansionLoc(Loc);
@@ -134,7 +127,6 @@ void removeElseAndBrackets(DiagnosticBuilder &Diag, ASTContext &Context,
SourceRange(ElseExpandedLoc, EndLoc), Repl);
}
}
-} // namespace
ElseAfterReturnCheck::ElseAfterReturnCheck(StringRef Name,
ClangTidyContext *Context)
More information about the cfe-commits
mailing list