[clang-tools-extra] [clang-tidy] Improve `container-data-pointer` check to use `c_str()` (PR #71304)
Julian Schmidt via cfe-commits
cfe-commits at lists.llvm.org
Sat Jun 15 09:25:17 PDT 2024
================
@@ -111,16 +115,18 @@ void ContainerDataPointerCheck::check(const MatchFinder::MatchResult &Result) {
MemberExpr>(CE))
ReplacementText = "(" + ReplacementText + ")";
- if (CE->getType()->isPointerType())
- ReplacementText += "->data()";
- else
- ReplacementText += ".data()";
+ ReplacementText += CE->getType()->isPointerType() ? "->" : ".";
+ ReplacementText += CStrMethod ? "c_str()" : "data()";
----------------
5chmidti wrote:
Prefer to use `llvm::Twine` for this concatenation
https://github.com/llvm/llvm-project/pull/71304
More information about the cfe-commits
mailing list