llvm-project/clang-tools-extra/clang-tidy
Etienne Bergeron 9cfd8cea6b [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
2016-04-15 18:12:06 +00:00
..
cert Add a new check, cert-env33-c, that diagnoses uses of system(), popen(), and _popen() to execute a command processor. This check corresponds to the CERT secure coding rule: https://www.securecoding.cert.org/confluence/pages/viewpage.action?pageId=2130132 2016-02-22 16:01:06 +00:00
cppcoreguidelines Complete support for C++ Core Guidelines Type.6: Always initialize a member variable. 2016-04-13 11:35:47 +00:00
google [clang-tidy] Remove unnecessary getName() on Decls and Types feeding into a DiagnosticBuilder 2016-04-07 14:55:25 +00:00
llvm Remove autoconf support 2016-01-26 21:31:36 +00:00
misc [clang-tidy] Add new checker for suspicious sizeof expressions 2016-04-15 16:36:00 +00:00
modernize Add support for type aliases to modernize-redundant-void-arg.cpp 2016-04-14 19:28:13 +00:00
performance [clang-tidy] fix a crash with -fdelayed-template-parsing in UnnecessaryValueParamCheck. 2016-04-07 14:58:13 +00:00
plugin [clang-tidy] Add "clang-tidy as a clang plugin" skeleton. 2016-03-03 08:58:12 +00:00
readability [clang-tidy] Add more detection rules for redundant c_str calls. 2016-04-15 18:12:06 +00:00
tool [clang-tidy] Reformatted docs + minor updates 2016-02-08 00:19:29 +00:00
utils Complete support for C++ Core Guidelines Type.6: Always initialize a member variable. 2016-04-13 11:35:47 +00:00
CMakeLists.txt [clang-tidy] Add "clang-tidy as a clang plugin" skeleton. 2016-03-03 08:58:12 +00:00
ClangTidy.cpp [clang-tidy] filter plugins and plugin arguments of the command-line 2016-04-06 14:07:51 +00:00
ClangTidy.h [docs] Clean up doxygen comments a bit. 2016-03-06 04:05:59 +00:00
ClangTidyDiagnosticConsumer.cpp [clang-tidy] Fix a crash issue when clang-tidy runs with compilation database. 2016-02-26 09:19:33 +00:00
ClangTidyDiagnosticConsumer.h [clang-tidy] Add "clang-tidy as a clang plugin" skeleton. 2016-03-03 08:58:12 +00:00
ClangTidyModule.cpp [clang-tidy] Default options in modules. 2014-10-16 11:27:57 +00:00
ClangTidyModule.h Revert "Apply modernize-use-default to clang-tools-extra." 2015-10-20 21:45:52 +00:00
ClangTidyModuleRegistry.h [clang-tidy] Fixed header guards using clang-tidy llvm-header-guard check. NFC. 2015-03-09 16:52:33 +00:00
ClangTidyOptions.cpp Teach clang-tidy how to upgrade warnings into errors. 2016-01-13 17:36:41 +00:00
ClangTidyOptions.h Teach clang-tidy how to upgrade warnings into errors. 2016-01-13 17:36:41 +00:00
add_new_check.py [clang-tidy] add_new_check.py should fail if check name starts with the module name 2016-04-13 08:46:32 +00:00
rename_check.py [clang-tidy] Python script for easy check rename 2015-10-11 07:58:34 +00:00