[PATCH] D25639: Add ctor for string literal to StringRef, and make explicit the conversion from const char *

Manuel Klimek via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 16 23:43:59 PDT 2016


klimek added a comment.

In https://reviews.llvm.org/D25639#571344, @zturner wrote:

> The only thing I'm not crazy about here is that the clang tidy check seems to blindly replace all calls to `s.c_str()` with `llvm::StringRef(s.c_str())`.  Is there any way to make it attempt to replace it with just `s` first, and only if that fails do you then try `llvm::StringRef(s.c_str())`?


Shouldn't it be relatively straight forward to discover whether the expression is convertible to StringRef without the .c_str() call from an AST matcher?


https://reviews.llvm.org/D25639





More information about the llvm-commits mailing list