summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy/readability/RedundantStringCStrCheck.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* [clang-tidy] Remove duplicated getText implementation, NFCHaojian Wu2018-12-071-11/+7
| | | | llvm-svn: 348583
* Port getLocStart -> getBeginLocStephen Kelly2018-08-091-1/+1
| | | | | | | | | | Reviewers: javed.absar Subscribers: nemanjai, kbarton, ilya-biryukov, ioeric, jkorous, arphaman, jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D50354 llvm-svn: 339400
* Adapt clang-tidy checks to changing semantics of hasDeclaration.Manuel Klimek2017-08-021-1/+2
| | | | | | Differential Revision: https://reviews.llvm.org/D36154 llvm-svn: 309810
* Remove deprecated methods ast_matchers::BoundNodes::{getStmtAs,getDeclAs}Alexander Kornienko2016-12-131-3/+3
| | | | llvm-svn: 289542
* [clang-tools-extra] Format sources with clang-format. NFC.Mandeep Singh Grang2016-11-081-44/+31
| | | | | | | | | | | | | | | | Summary: Ran clang-format on all .c/.cpp/.h files in clang-tools-extra. Excluded the test, unittests, clang-reorder-fields, include-fixer, modularize and pptrace directories. Reviewers: klimek, alexfh Subscribers: nemanjai Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D26329 llvm-svn: 286221
* [clang-tidy] Handle data() in readability-redundant-string-cstrMalcolm Parsons2016-11-031-3/+5
| | | | | | | | | | | | | | | Summary: std::string::data() and std::string::c_str() are equivalent. Enhance the readability-redundant-string-cstr check to also handle calls to data(). Reviewers: etienneb, alexfh, aaron.ballman Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D26279 llvm-svn: 285901
* [clang-tidy] Cleaning namespaces to be more consistant across checkers.Etienne Bergeron2016-05-021-5/+4
| | | | | | | | | | | | | | Summary: The goal of the patch is to bring checkers in their appropriate namespace. This path doesn't change any behavior. Reviewers: alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D19811 llvm-svn: 268264
* [clang-tidy] Add more detection rules for redundant c_str calls.Etienne Bergeron2016-04-151-2/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* [clang-tidy] Add support for different char-types for the ↵Etienne Bergeron2016-03-241-14/+14
| | | | | | | | | | | | | | | | | | | | | readability-redundant-string-cstr checker. Summary: The current checker is able to recognize std::string but does not recognize other string variants. This patch is adding the support for any string defined with basic_string without considering the the underlying char type. The most common variant is: 'std::wstring' based on 'wchar_t'. There are also other string variants added to the standard: u16string, u32string, etc... Reviewers: alexfh Subscribers: mamai, dblaikie, cfe-commits Differential Revision: http://reviews.llvm.org/D18412 llvm-svn: 264325
* [clang-tidy] Fix redundant-string-cstr check with msvc 14 headers.Etienne Bergeron2016-03-221-19/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The string constructors are not defined using optional parameters and are not recognize by the checker. The constructor defined in the MSVC header is defined with 1 parameter. Therefore, patterns are not recognized by the checker. The current patch add support to accept constructor with only one parameter. Repro on a Visual Studio 14 installation with the following code: ``` void f1(const std::string &s) { f1(s.c_str()); } ``` In the xstring.h header, the constructors are defined this way: ``` basic_string(const _Myt& _Right) [...] basic_string(const _Myt& _Right, const _Alloc& _Al) [...] ``` The CXXConstructExpr to recognize only contains 1 parameter. ``` CXXConstructExpr 0x3f1a070 <C:\src\llvm\examples\test.cc:6:6, col:14> 'const std::string':'const class std::basic_string<char, struct std::char_traits<char>, class std::allocator<char> >' 'void (const char *) __attribute__((thiscall))' `-CXXMemberCallExpr 0x3f1a008 <col:6, col:14> 'const char *' `-MemberExpr 0x3f19fe0 <col:6, col:8> '<bound member function type>' .c_str 0x3cc22f8 `-DeclRefExpr 0x3f19fc8 <col:6> 'const std::string':'const class std::basic_string<char, struct std::char_traits<char>, class std::allocator<char> >' lvalue ParmVar 0x3f19c80 's' 'const std::string &' ``` Reviewers: aaron.ballman, alexfh Subscribers: aemerson Differential Revision: http://reviews.llvm.org/D18285 llvm-svn: 264075
* Refactors AST matching code to use the new AST matcher names. This patch ↵Aaron Ballman2015-09-171-14/+16
| | | | | | correlates to r247885 which performs the AST matcher rename in Clang. llvm-svn: 247886
* Disable clang-tidy readability checkers when not compiling in C++ mode. None ↵Aaron Ballman2015-09-021-0/+5
| | | | | | of the checkers require additional testing as the tests will not compile for other languages or modes, or the checkers would never match a valid construct. llvm-svn: 246661
* Move remove-cstr-calls from a standalone executable to a clang-tidy check ↵Alexander Kornienko2015-03-161-0/+138
readability-redundant-string-cstr http://reviews.llvm.org/D7318 Patch by Richard Thomson! llvm-svn: 232338
OpenPOWER on IntegriCloud