llvm-project/clang-tools-extra/clang-tidy/utils
Alexander Kornienko 271e181c78 [clang-tidy] Add ExprMutationAnalyzer, that analyzes whether an expression is mutated within a statement.
Summary:
(Originally started as a clang-tidy check but there's already D45444 so shifted to just adding ExprMutationAnalyzer)

`ExprMutationAnalyzer` is a generally useful helper that can be used in different clang-tidy checks for checking whether a given expression is (potentially) mutated within a statement (typically the enclosing compound statement.)

This is a more general and more powerful/accurate version of isOnlyUsedAsConst, which is used in ForRangeCopyCheck, UnnecessaryCopyInitialization.

It should also be possible to construct checks like D45444 (suggest adding const to variable declaration) or https://bugs.llvm.org/show_bug.cgi?id=21981 (suggest adding const to member function) using this helper function.

This function is tested by itself and is intended to stay generally useful instead of tied to any particular check.

Reviewers: hokein, alexfh, aaron.ballman, ilya-biryukov, george.karpenkov

Reviewed By: aaron.ballman

Subscribers: lebedev.ri, shuaiwang, rnkovacs, hokein, alexfh, aaron.ballman, a.sidorin, Eugene.Zelenko, xazax.hun, JonasToth, klimek, mgorny, cfe-commits

Tags: #clang-tools-extra

Patch by Shuai Wang.

Differential Revision: https://reviews.llvm.org/D45679

llvm-svn: 335736
2018-06-27 14:30:55 +00:00
..
ASTUtils.cpp [clang-tidy] Kill marco. No functionality change. 2018-02-02 13:39:07 +00:00
ASTUtils.h [clang-tidy] Add a new Android check "android-cloexec-socket" 2017-07-12 17:43:36 +00:00
CMakeLists.txt [clang-tidy] Add ExprMutationAnalyzer, that analyzes whether an expression is mutated within a statement. 2018-06-27 14:30:55 +00:00
DeclRefExprUtils.cpp [clang-tidy] Do not trigger move fix for non-copy assignment operators in performance-unnecessary-value-param check 2017-01-19 15:51:10 +00:00
DeclRefExprUtils.h [clang-tidy] Handle constructors in performance-unnecessary-value-param 2017-01-03 12:10:44 +00:00
ExprMutationAnalyzer.cpp [clang-tidy] Add ExprMutationAnalyzer, that analyzes whether an expression is mutated within a statement. 2018-06-27 14:30:55 +00:00
ExprMutationAnalyzer.h [clang-tidy] Add ExprMutationAnalyzer, that analyzes whether an expression is mutated within a statement. 2018-06-27 14:30:55 +00:00
ExprSequence.cpp [clang-tidy] refactor ExprSequence out of use-after-move check 2016-12-24 12:45:07 +00:00
ExprSequence.h [clang-tidy] refactor ExprSequence out of use-after-move check 2016-12-24 12:45:07 +00:00
FixItHintUtils.cpp [clang-tidy] getPreviousNonCommentToken -> getPreviousToken 2017-02-06 15:46:33 +00:00
FixItHintUtils.h [clang-tidy] Fix doxygen errors. NFC. 2016-06-17 11:43:33 +00:00
HeaderFileExtensionsUtils.cpp [clang-tidy] Some tweaks on header guard checks. 2016-08-26 11:15:38 +00:00
HeaderFileExtensionsUtils.h [clang-tidy] Unify the way IncludeStyle and HeaderFileExtesions options are used 2017-07-20 12:02:03 +00:00
HeaderGuard.cpp Spelling mistakes in comments. NFCI. 2017-03-30 13:10:33 +00:00
HeaderGuard.h [clang-tidy] Unify the way IncludeStyle and HeaderFileExtesions options are used 2017-07-20 12:02:03 +00:00
IncludeInserter.cpp Reland "[tools] Updating PPCallbacks::InclusionDirective calls" 2018-05-10 19:13:14 +00:00
IncludeInserter.h [clang-tidy] Fix doxygen errors. NFC. 2016-06-17 11:43:33 +00:00
IncludeSorter.cpp Correctly classify main file includes if there is a prefix added 2017-01-12 15:31:50 +00:00
IncludeSorter.h [clang-tidy] More doc fixes. NFC. 2016-06-17 12:01:15 +00:00
LexerUtils.cpp [clang-tidy] getPreviousNonCommentToken -> getPreviousToken 2017-02-06 15:46:33 +00:00
LexerUtils.h [clang-tidy] getPreviousNonCommentToken -> getPreviousToken 2017-02-06 15:46:33 +00:00
Matchers.h [clang-tidy] Implement type-based check for `gsl::owner` 2017-09-12 20:00:42 +00:00
NamespaceAliaser.cpp [clang-tools-extra] Format sources with clang-format. NFC. 2016-11-08 07:50:19 +00:00
NamespaceAliaser.h Recommit "[ClangTidy] Add UsingInserter and NamespaceAliaser" 2016-10-17 08:33:59 +00:00
OptionsUtils.cpp [clang-tidy] Lift parsing of sequence of names functions to utils. 2016-05-10 15:31:15 +00:00
OptionsUtils.h [clang-tidy] More doc fixes. NFC. 2016-06-17 12:01:15 +00:00
TypeTraits.cpp [clang-tidy] ObjC ARC objects should not trigger performance-unnecessary-value-param 2018-02-02 15:34:33 +00:00
TypeTraits.h [clang-tidy] UnnecessaryValueParamCheck - suggest std::move() if non-const value parameter can be moved. 2016-07-01 20:12:15 +00:00
UsingInserter.cpp [clang-tools-extra] Format sources with clang-format. NFC. 2016-11-08 07:50:19 +00:00
UsingInserter.h Recommit "[ClangTidy] Add UsingInserter and NamespaceAliaser" 2016-10-17 08:33:59 +00:00