[all-commits] [llvm/llvm-project] 06f3da: [clang-tidy] Fix readability-redundant-string-init...
mitchell-stellar via All-commits
all-commits at lists.llvm.org
Fri Nov 15 15:11:11 PST 2019
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: 06f3dabe4a2e85a32ade27c0769b6084c828a206
https://github.com/llvm/llvm-project/commit/06f3dabe4a2e85a32ade27c0769b6084c828a206
Author: Mitchell Balan <mitchell at stellarscience.com>
Date: 2019-11-15 (Fri, 15 Nov 2019)
Changed paths:
M clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.cpp
M clang-tools-extra/clang-tidy/modernize/UseOverrideCheck.h
M clang-tools-extra/docs/ReleaseNotes.rst
M clang-tools-extra/docs/clang-tidy/checks/modernize-use-override.rst
Log Message:
-----------
[clang-tidy] Fix readability-redundant-string-init for c++17/c++2a
Summary:
`readability-redundant-string-init` was one of several clang-tidy checks documented as failing for C++17. (The failure mode in C++17 is that it changes `std::string Name = ""`; to `std::string Name = Name;`, which actually compiles but crashes at run-time.)
Analyzing the AST with `clang -Xclang -ast-dump` showed that the outer `CXXConstructExprs` that previously held the correct SourceRange were being elided in C++17/2a, but the containing `VarDecl` expressions still had all the relevant information. So this patch changes the fix to get its source ranges from `VarDecl`.
It adds one test `std::string g = "u", h = "", i = "uuu", j = "", k;` to confirm proper warnings and fixit replacements in a single `DeclStmt` where some strings require replacement and others don't. The readability-redundant-string-init.cpp and readability-redundant-string-init-msvc.cpp tests now pass for C++11/14/17/2a.
Reviewers: gribozavr, etienneb, alexfh, hokein, aaron.ballman, gribozavr2
Patch by: poelmanc
Subscribers: NoQ, MyDeveloperDay, Eugene.Zelenko, dylanmckay, cfe-commits
Tags: #clang, #clang-tools-extra
Differential Revision: https://reviews.llvm.org/D69238
Commit: 12d7500ba2417c7f299daa83a7812962f15632ec
https://github.com/llvm/llvm-project/commit/12d7500ba2417c7f299daa83a7812962f15632ec
Author: Mitchell Balan <mitchell at stellarscience.com>
Date: 2019-11-15 (Fri, 15 Nov 2019)
Changed paths:
M clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp
M clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.h
M clang-tools-extra/docs/ReleaseNotes.rst
M clang-tools-extra/docs/clang-tidy/checks/readability-redundant-string-init.rst
M clang-tools-extra/test/clang-tidy/checkers/readability-redundant-string-init.cpp
Log Message:
-----------
[clang-tidy] Give readability-redundant-string-init a customizable list of string types to fix
Summary:
This patch adds a feature requested in https://reviews.llvm.org/D69238 to enable `readability-redundant-string-init` to take a list of strings to apply the fix to rather than hard-coding `basic_string`. It adds a `StringNames` option of semicolon-delimited names of string classes to which to apply this fix. Tests ensure this works with test class out::TestString as well as std::string and std::wstring as before. It should be applicable to llvm::StringRef, QString, etc.
Note: This commit was previously reverted due to a failing unit test. That test has been fixed in this version.
Reviewers: MyDeveloperDay, aaron.ballman, hokein, alexfh, JonasToth, gribozavr2
Patch by: poelmanc
Subscribers: gribozavr2, xazax.hun, Eugene.Zelenko, cfe-commits
Tags: #clang-tools-extra, #clang
Differential Revision: https://reviews.llvm.org/D69548
Compare: https://github.com/llvm/llvm-project/compare/905357440c98...12d7500ba241
More information about the All-commits
mailing list