[PATCH] D25257: Use StringRef in Option library instead of raw pointers (NFC)

Zachary Turner via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 5 10:47:56 PDT 2016


zturner added a comment.

F2468218: stuff.patch <https://reviews.llvm.org/F2468218>

Attached is a sample patch that converts some of the simpler functions to accepting `StringRef`.  This should get rid of some of the `data()` calls.  There's more functions you can do this too as well, I didn't want to go too deep though.  I think you should do this for as many functions as possible, then rebase on top of that and remove all those data calls.  We can look at the rest after.  In general though I'm against using `data()` anywhere if at all possible.



> Tools.cpp:137
>                                         SmallVectorImpl<char> &Res) {
> +  const char *Arg = ArgStr.data();
>    for (; *Arg; ++Arg) {

In this case, there's no reason for data at all.  You should change the for loop to use a range based for over `ArgStr`.

https://reviews.llvm.org/D25257





More information about the llvm-commits mailing list