diff options
author | Etienne Bergeron <etienneb@google.com> | 2016-04-15 18:12:06 +0000 |
---|---|---|
committer | Etienne Bergeron <etienneb@google.com> | 2016-04-15 18:12:06 +0000 |
commit | 9cfd8cea6b8172e32a76a59125f13a6662a18c86 (patch) | |
tree | 47ba7f0d01a2383d864f75e4dfbc89f3fb894e74 /llvm/tools/llvm-readobj | |
parent | 1fbe9bcab479522e7704716f0f57c7c09d27900a (diff) | |
download | bcm5719-llvm-9cfd8cea6b8172e32a76a59125f13a6662a18c86.tar.gz bcm5719-llvm-9cfd8cea6b8172e32a76a59125f13a6662a18c86.zip |
[clang-tidy] Add more detection rules for redundant c_str calls.
Summary:
The string class contains methods which support receiving either a string literal or a string object.
For example, calls to append can receive either a char* or a string.
```
string& append (const string& str);
string& append (const char* s);
```
Which make these cases equivalent, and the .c_str() useless:
```
std::string s = "123";
str.append(s);
str.append(s.c_str());
```
In these cases, removing .c_str() doesn't provide any size or speed improvement.
It's only a readability issue.
If the string contains embedded NUL characters, the string literal and the string
object won't produce the same semantic.
Reviewers: alexfh, sbenza
Subscribers: LegalizeAdulthood, aaron.ballman, chapuni, Eugene.Zelenko, cfe-commits
Differential Revision: http://reviews.llvm.org/D18475
llvm-svn: 266463
Diffstat (limited to 'llvm/tools/llvm-readobj')
0 files changed, 0 insertions, 0 deletions