Skip to content

Commit 5ee115e

Browse files
committed
feedback
1 parent 062aebb commit 5ee115e

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

clang-tools-extra/clang-tidy/modernize/CleanupStaticCastCheck.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,14 @@
1616

1717
using namespace clang::ast_matchers;
1818

19-
namespace {
19+
namespace clang::tidy::modernize {
20+
21+
2022
std::string getText(const clang::Expr *E, const clang::ASTContext &Context) {
2123
auto &SM = Context.getSourceManager();
2224
auto Range = clang::CharSourceRange::getTokenRange(E->getSourceRange());
2325
return clang::Lexer::getSourceText(Range, SM, Context.getLangOpts()).str();
2426
}
25-
} // namespace
26-
27-
namespace clang::tidy::modernize {
2827

2928
void CleanupStaticCastCheck::registerMatchers(MatchFinder *Finder) {
3029
// Match static_cast expressions not in templates
@@ -42,7 +41,6 @@ void CleanupStaticCastCheck::check(const MatchFinder::MatchResult &Result) {
4241
if (!Cast)
4342
return;
4443

45-
// Get the source expression and its type
4644
const Expr *SubExpr = Cast->getSubExpr()->IgnoreParenImpCasts();
4745
QualType SourceType = SubExpr->getType();
4846
QualType TargetType = Cast->getType();
@@ -61,10 +59,8 @@ void CleanupStaticCastCheck::check(const MatchFinder::MatchResult &Result) {
6159
"redundant static_cast to the same type %0") // Removed single quotes
6260
<< TargetType;
6361

64-
// Use our helper function to get the source text
6562
std::string ReplacementText = getText(SubExpr, *Result.Context);
6663

67-
// Suggest removing the cast
6864
Diag << FixItHint::CreateReplacement(
6965
Cast->getSourceRange(),
7066
ReplacementText);

0 commit comments

Comments
 (0)