[PATCH] D149280: [clang-tidy] Add modernize-printf-to-std-print check

Mike Crowe via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sat Jun 24 08:22:38 PDT 2023


mikecrowe marked 4 inline comments as done.
mikecrowe added inline comments.


================
Comment at: clang-tools-extra/clang-tidy/utils/FormatStringConverter.cpp:384-397
+        const auto StringDecl = type(hasUnqualifiedDesugaredType(recordType(
+            hasDeclaration(cxxRecordDecl(hasName("::std::basic_string"))))));
+        const auto StringExpr = expr(anyOf(
+            hasType(StringDecl), hasType(qualType(pointsTo(StringDecl)))));
+
+        const auto StringCStrCallExpr =
+            cxxMemberCallExpr(on(StringExpr.bind("arg")),
----------------
PiotrZSL wrote:
> mikecrowe wrote:
> > PiotrZSL wrote:
> > > constant construction of those marchers may be costly.. can be cache them somehow in this object ?
> > Good idea. Do you have any pointers to code that does this? I couldn't find any.
> > 
> > The types involved all seem to be in the `internal::` namespace and presumably subject to change. Ideally, I'd put:
> > ```
> > std::optional<SomeSortOfMatcherType> StringCStrCallExprMatcher;
> > ```
> > in the class and then populate it here the first time lazily. Unfortunately I have no idea what type to use for `SomeSortOfMatcherType`.
> `clang::ast_matchers::StatementMatcher<CXXMemberCallExpr>`, this is defined as `using clang::ast_matchers::StatementMatcher = typedef internal::Matcher<Stmt>`.
> I would create it in class constructor as private member.
Thanks for the pointer. It turns out that I need just `clang::ast_matchers::StatementMatcher`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D149280/new/

https://reviews.llvm.org/D149280



More information about the cfe-commits mailing list