Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[clang-tidy] RenamerClangTidy now renames dependent member expr when …
…the member can be resolved Summary: Sometimes in templated code Member references are reported as `DependentScopeMemberExpr` because that's what the standard dictates, however in many trivial cases it is easy to resolve the reference to its actual Member. Take this code: ``` template<typename T> class A{ int value; A& operator=(const A& Other){ value = Other.value; this->value = Other.value; return *this; } }; ``` When ran with `clang-tidy file.cpp -checks=readability-identifier-naming --config="{CheckOptions: [{key: readability-identifier-naming.MemberPrefix, value: m_}]}" -fix` Current behaviour: ``` template<typename T> class A{ int m_value; A& operator=(const A& Other){ m_value = Other.value; this->value = Other.value; return *this; } }; ``` As `this->value` and `Other.value` are Dependent they are ignored when creating the fix-its, however this can easily be resolved. Proposed behaviour: ``` template<typename T> class A{ int m_value; A& operator=(const A& Other){ m_value = Other.m_value; this->m_value = Other.m_value; return *this; } }; ``` Reviewers: aaron.ballman, JonasToth, alexfh, hokein, gribozavr2 Reviewed By: aaron.ballman Subscribers: merge_guards_bot, xazax.hun, cfe-commits Tags: #clang, #clang-tools-extra Differential Revision: https://reviews.llvm.org/D73052
- Loading branch information
Showing
7 changed files
with
283 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.