[PATCH] D113863: [clang-tidy] Make `readability-container-data-pointer` more robust
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 8 07:28:42 PST 2021
aaron.ballman added a comment.
Mostly just nits from me. At a high level, I think this is good, but if someone else wanted to double-check the changes to the matcher statements themselves, that'd be good.
================
Comment at: clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.cpp:95
+
+ const auto SourceRange = CE->getSourceRange();
----------------
Drop top-level const and spell out the type explicitly.
================
Comment at: clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.cpp:97-100
std::string ReplacementText;
- ReplacementText = std::string(Lexer::getSourceText(
- CharSourceRange::getTokenRange(DRE->getSourceRange()),
- *Result.SourceManager, getLangOpts()));
- if (DRE->getType()->isPointerType())
+ ReplacementText = std::string(
+ Lexer::getSourceText(CharSourceRange::getTokenRange(SourceRange),
+ *Result.SourceManager, getLangOpts()));
----------------
Might as well use the constructor rather than assignment operator here.
================
Comment at: clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.cpp:102-103
+
+ if (!isa<DeclRefExpr>(CE) && !isa<ArraySubscriptExpr>(CE) &&
+ !isa<CXXOperatorCallExpr>(CE) && !isa<CallExpr>(CE))
+ ReplacementText = "(" + ReplacementText + ")";
----------------
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D113863/new/
https://reviews.llvm.org/D113863
More information about the cfe-commits
mailing list