mikecrowe added inline comments.

================
Comment at: 
clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp:188
+                              callee(functionDecl(hasName("::std::format")))),
+                        hasAnyArgument(materializeTemporaryExpr(
+                            has(StringCStrCallExpr))))),
----------------
njames93 wrote:
> The limitation about only transforming the first argument can be alleviated 
> by using the `forEachArgumentWithParam` matcher
Thanks for the hint. I did try to overcome this limitation but failed to find 
`forEachArgumentWithParam`.

I think that I've managed to make `forEachArgumentWithParam` work, but only if 
I lose the `materializeTemporaryExpr`. I hope that's not essential. I've ended 
up with:

```C++
  Finder->addMatcher(                                                           
                                                                                
                                           
    traverse(TK_AsIs,                                                           
                                                                                
                                           
             callExpr(callee(functionDecl(hasAnyName("::std::print", 
"::std::format"))),                                                             
                                                      
                      forEachArgumentWithParam(StringCStrCallExpr, 
parmVarDecl()))),                                                               
                                                        
    this);                                                                      
                                                                                
                                           
```
I suspect that there's something better than the `parmVarDecl()` second 
parameter to `forEachArgumentWithParam` though.


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

https://reviews.llvm.org/D143342

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to