This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy]: string_view of temporary string
AbandonedPublic

Authored by jbcoe on Mar 1 2016, 9:19 AM.

Details

Summary

Find instances where a string_view is constructed from a temporary string and replace the string_view with a string.

Diff Detail

Repository
rL LLVM

Event Timeline

jbcoe updated this revision to Diff 49502.Mar 1 2016, 9:19 AM
jbcoe retitled this revision from to [clang-tidy]: string_view of temporary string.
jbcoe updated this object.
jbcoe added reviewers: aaron.ballman, alexfh.
jbcoe set the repository for this revision to rL LLVM.
jbcoe added a subscriber: cfe-commits.

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)

alexfh edited edge metadata.Mar 1 2016, 10:04 AM

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.