Find instances where a string_view is constructed from a temporary string and replace the string_view with a string.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
Any way to/would it be worth broadening this with an annotation or some
such (or just a lost for now) of types that maintain references to their
ctor params? (Eg: llvm arrayref, etc)
As David noted, there are other similar classes like llvm::StringRef, llvm::ArraryRef, gsl::span, StringPiece (in various Google projects, e.g. https://github.com/google/re2/blob/master/re2/stringpiece.h) and numerous other in different code bases. I think, we should make the check sufficiently configurable to be able to support other similar classes.
clang-tidy/misc/MiscTidyModule.cpp | ||
---|---|---|
36 | Please include the full context in the diff (see http://llvm.org/docs/Phabricator.html). | |
89 | Please use CamelCase for class names: StringViewOfTemporaryCheck. | |
90 | Please only use dashes as delimiters in the check name: misc-string-view-of-temporary. |
Please include the full context in the diff (see http://llvm.org/docs/Phabricator.html).