[PATCH] D45679: [clang-tidy] Add ExprMutationAnalyzer, that analyzes whether an expression is mutated within a statement.

2018-05-04 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang updated this revision to Diff 145313. shuaiwang added a comment. Revert "DeclRefExpr to volatile handling" part of last update. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45679 Files: clang-tidy/utils/CMakeLists.txt clang-tidy/utils/ExprMutationAnalyzer.cpp

[PATCH] D45679: [clang-tidy] Add ExprMutationAnalyzer, that analyzes whether an expression is mutated within a statement.

2018-05-04 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang marked 5 inline comments as done. shuaiwang added a comment. I've reverted the handling of DeclRefExpr to volatile after rethinking about it. The purpose of this analyzer is to find whether the given Expr is mutated within a scope, but doesn't really care about external changes. In

[PATCH] D45702: [clang-tidy] Add a new check, readability-simplify-subscript-expr, that simplifies subscript expressions.

2018-05-13 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang updated this revision to Diff 146514. shuaiwang marked 10 inline comments as done. shuaiwang added a comment. Rename to readability-simplify-subscript-expr and addressed other comments. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45702 Files:

[PATCH] D45679: [clang-tidy] Add ExprMutationAnalyzer, that analyzes whether an expression is mutated within a statement.

2018-05-13 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang updated this revision to Diff 146531. shuaiwang marked 3 inline comments as done. shuaiwang added a comment. Handle unevaluated expressions. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45679 Files: clang-tidy/utils/CMakeLists.txt

[PATCH] D45702: [clang-tidy] Add a new check, readability-simplify-subscript-expr, that simplifies subscript expressions.

2018-05-13 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang updated this revision to Diff 146532. shuaiwang marked 3 inline comments as done. shuaiwang added a comment. Addressed review comments. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45702 Files: clang-tidy/readability/CMakeLists.txt

[PATCH] D45702: [clang-tidy] Add a new check, readability-redundant-data-call, that finds and removes redundant calls to .data().

2018-05-07 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang added inline comments. Comment at: clang-tidy/readability/RedundantDataCallCheck.cpp:45 + anyOf(TypesMatcher, pointerType(pointee(TypesMatcher)), + callee(namedDecl(hasName("data" + .bind("call",

[PATCH] D45702: [clang-tidy] Add a new check, readability-simplify-subscript-expr, that simplifies subscript expressions.

2018-05-16 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang added a comment. In https://reviews.llvm.org/D45702#1101136, @aaron.ballman wrote: > In https://reviews.llvm.org/D45702#1097294, @shuaiwang wrote: > > > Addressed review comments. > > > This patch was approved; do you need someone to commit this for you? Yes please :) Repository:

[PATCH] D45679: [clang-tidy] Add ExprMutationAnalyzer, that analyzes whether an expression is mutated within a statement.

2018-06-13 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang added a comment. In https://reviews.llvm.org/D45679#1131115, @aaron.ballman wrote: > I had to revert due to failing tests. The revert was done in r334606 and this > is an example of a failing bot: >

[PATCH] D45679: [clang-tidy] Add ExprMutationAnalyzer, that analyzes whether an expression is mutated within a statement.

2018-06-13 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang updated this revision to Diff 151244. shuaiwang added a comment. Don't include in unit tests, should fix the test failures. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45679 Files: clang-tidy/utils/CMakeLists.txt clang-tidy/utils/ExprMutationAnalyzer.cpp

[PATCH] D45679: [clang-tidy] Add ExprMutationAnalyzer, that analyzes whether an expression is mutated within a statement.

2018-06-13 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang updated this revision to Diff 151245. shuaiwang added a comment. Add include for std::isspace() (thanks aaron.ballman!) Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45679 Files: clang-tidy/utils/CMakeLists.txt clang-tidy/utils/ExprMutationAnalyzer.cpp

[PATCH] D45679: [clang-tidy] Add ExprMutationAnalyzer, that analyzes whether an expression is mutated within a statement.

2018-06-03 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang added a comment. Overestimated the work of supporting typeid and _Generic, done now. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45679 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[PATCH] D45679: [clang-tidy] Add ExprMutationAnalyzer, that analyzes whether an expression is mutated within a statement.

2018-06-03 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang updated this revision to Diff 149659. shuaiwang marked 5 inline comments as done. shuaiwang added a comment. Handle sizeof on VLA. Added test case for typeof() Added TODO for handling typeid and generic selection. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45679

[PATCH] D45679: [clang-tidy] Add ExprMutationAnalyzer, that analyzes whether an expression is mutated within a statement.

2018-06-03 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang added inline comments. Comment at: clang-tidy/utils/ExprMutationAnalyzer.cpp:34-38 +const ast_matchers::internal::VariadicDynCastAllOfMatcher +cxxTypeidExpr; + +const ast_matchers::internal::VariadicDynCastAllOfMatcher +cxxNoexceptExpr;

[PATCH] D45679: [clang-tidy] Add ExprMutationAnalyzer, that analyzes whether an expression is mutated within a statement.

2018-06-03 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang updated this revision to Diff 149661. shuaiwang marked 4 inline comments as done. shuaiwang added a comment. Handle typeid and generic selection. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45679 Files: clang-tidy/utils/CMakeLists.txt

[PATCH] D45679: [clang-tidy] Add ExprMutationAnalyzer, that analyzes whether an expression is mutated within a statement.

2018-06-05 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang added a comment. Thanks a lot for the review! Could you also help commit this diff as well? Thanks! Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45679 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[PATCH] D45679: [clang-tidy] Add ExprMutationAnalyzer, that analyzes whether an expression is mutated within a statement.

2018-06-05 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang updated this revision to Diff 150026. shuaiwang marked an inline comment as done. shuaiwang added a comment. Remove stale comment Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45679 Files: clang-tidy/utils/CMakeLists.txt clang-tidy/utils/ExprMutationAnalyzer.cpp

[PATCH] D45679: [clang-tidy] Add ExprMutationAnalyzer, that analyzes whether an expression is mutated within a statement.

2018-06-25 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang added a comment. Could someone help commit this now that the build issue with header include is fixed? Thanks a lot! (meanwhile I'm requesting commit access) In https://reviews.llvm.org/D45679#1132327, @alexfh wrote: > In https://reviews.llvm.org/D45679#1132086, @JonasToth wrote: > >

[PATCH] D48854: Use ExprMutationAnalyzer in performance-for-range-copy

2018-07-02 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang created this revision. Herald added a reviewer: george.karpenkov. Herald added subscribers: cfe-commits, a.sidorin. This gives better coverage to the check as ExprMutationAnalyzer is more accurate comparing to isOnlyUsedAsConst. Majority of wins come from const usage of member field,

[PATCH] D45444: [clang-tidy] WIP: implement new check for const-correctness

2018-04-30 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang added a comment. > Why do you think that looping is required? From my understanding, we > need the first usage (DeclRefExpr) to get the analysis started. The > analysis itself will check all remaining uses. Is this necessary, > because we analysis on a `Expr` basis? Yes. the

[PATCH] D45702: [clang-tidy] Add a new check, readability-redundant-data-call, that finds and removes redundant calls to .data().

2018-05-02 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang added a comment. In https://reviews.llvm.org/D45702#1085224, @aaron.ballman wrote: > > Have you run this over any large code bases to see whether the check > > triggers in practice? > > I'm still curious about this, btw. Yes it triggers in Google's code base. Repository: rCTE

[PATCH] D45702: [clang-tidy] Add a new check, readability-redundant-data-call, that finds and removes redundant calls to .data().

2018-05-02 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang added inline comments. Comment at: clang-tidy/readability/RedundantDataCallCheck.cpp:45 + anyOf(TypesMatcher, pointerType(pointee(TypesMatcher)), + callee(namedDecl(hasName("data" + .bind("call",

[PATCH] D45444: [clang-tidy] WIP: implement new check for const-correctness

2018-04-29 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang added inline comments. Comment at: clang-tidy/cppcoreguidelines/ConstCheck.cpp:229-237 + const auto *UseExpr = selectFirst("use", Usage); + + // The declared variables was used in non-const conserving way and can not + // be declared as const. + if (UseExpr &&

[PATCH] D45679: [clang-tidy] Add a helper function isModified, that checks whether an expression is modified within a statement.

2018-04-29 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang updated this revision to Diff 144490. shuaiwang marked 11 inline comments as done. shuaiwang added a comment. Added an isMutated overload for Decl. A few more test cases. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45679 Files: clang-tidy/utils/CMakeLists.txt

[PATCH] D45702: [clang-tidy] Add a new check, readability-redundant-data-call, that finds and removes redundant calls to .data().

2018-05-03 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang added a comment. In https://reviews.llvm.org/D45702#1086250, @aaron.ballman wrote: > In https://reviews.llvm.org/D45702#1085890, @shuaiwang wrote: > > > In https://reviews.llvm.org/D45702#1085224, @aaron.ballman wrote: > > > > > > Have you run this over any large code bases to see

[PATCH] D45679: [clang-tidy] Add a helper function isModified, that checks whether an expression is modified within a statement.

2018-05-03 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang updated this revision to Diff 145121. shuaiwang marked 4 inline comments as done. shuaiwang added a comment. Addressed review comments, notably added check for DeclRefExpr to volatile variables. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45679 Files:

[PATCH] D45679: [clang-tidy] Add a helper function isModified, that checks whether an expression is modified within a statement.

2018-05-03 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang added inline comments. Comment at: clang-tidy/utils/ExprMutationAnalyzer.cpp:82-83 +const auto *E = RefNodes.getNodeAs("expr"); +if (findMutation(E)) + return E; + } aaron.ballman wrote: > Why does this not return the result of

[PATCH] D50102: [clang-tidy] Use ExprMutationAnalyzer in performance-unnecessary-value-param

2018-08-02 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang updated this revision to Diff 158856. shuaiwang marked 2 inline comments as done. shuaiwang added a comment. Update comments. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D50102 Files: clang-tidy/performance/UnnecessaryValueParamCheck.cpp

[PATCH] D50102: [clang-tidy] Use ExprMutationAnalyzer in performance-unnecessary-value-param

2018-08-02 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang added inline comments. Comment at: clang-tidy/performance/UnnecessaryValueParamCheck.cpp:108 return; + if (const auto *Ctor = dyn_cast(Function)) { +for (const auto *Init : Ctor->inits()) { hokein wrote: > Is this a new fix or a special case

[PATCH] D50102: [clang-tidy] Use ExprMutationAnalyzer in performance-unnecessary-value-param

2018-08-03 Thread Shuai Wang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes. Closed by commit rL338903: Use ExprMutationAnalyzer in performance-unnecessary-value-param (authored by shuaiwang, committed by ). Herald added a subscriber: llvm-commits. Repository: rL LLVM

[PATCH] D50102: [clang-tidy] Use ExprMutationAnalyzer in performance-unnecessary-value-param

2018-08-03 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang updated this revision to Diff 159037. shuaiwang marked 2 inline comments as done. shuaiwang added a comment. Add comments explaining CXXCtorInitializer check Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D50102 Files:

[PATCH] D45679: [clang-tidy] Add ExprMutationAnalyzer, that analyzes whether an expression is mutated within a statement.

2018-07-31 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang added a comment. In https://reviews.llvm.org/D45679#1183116, @george.karpenkov wrote: > @aaron.ballman @alexfh @shuaiwang Would it be possible to move that code into > a matcher, or into a something which could be used from Clang? We would also > like to use similar functionality,

[PATCH] D50102: Use ExprMutationAnalyzer in performance-unnecessary-value-param

2018-07-31 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang created this revision. Herald added a reviewer: george.karpenkov. Herald added subscribers: cfe-commits, a.sidorin. This yields better recall as ExprMutationAnalyzer is more accurate. One common pattern this check is now able to catch is: void foo(std::vector v) { for (const

[PATCH] D50102: [clang-tidy] Use ExprMutationAnalyzer in performance-unnecessary-value-param

2018-07-31 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang updated this revision to Diff 158408. shuaiwang added a comment. Add test case Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D50102 Files: clang-tidy/performance/UnnecessaryValueParamCheck.cpp test/clang-tidy/performance-unnecessary-value-param.cpp Index:

[PATCH] D45444: [clang-tidy] implement new check for const-correctness

2018-08-10 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang added a comment. In https://reviews.llvm.org/D45444#1191874, @JonasToth wrote: > > Could you give a concrete example of this? > > vi llvm/lib/Demangle/ItaniumDemangle.cpp +1762 > > /home/jonas/opt/llvm/lib/Demangle/ItaniumDemangle.cpp:1762:7: warning: > variable 'num' of type 'char

[PATCH] D50447: [clang-tidy] Add a whitelistClasses option in performance-for-range-copy check.

2018-08-08 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang added a comment. In https://reviews.llvm.org/D50447#1192393, @JonasToth wrote: > ... just check if the variable is dereferenced in the scope of the loop (any > declRefExpr exists). +1 And I would imagine it's very rare (as in categories not raw number of occurrences) for a loop

[PATCH] D50447: [clang-tidy] Omit cases where loop variable is not used in loop body in performance-for-range-copy.

2018-08-10 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang added a comment. In https://reviews.llvm.org/D50447#1194967, @JonasToth wrote: > Do you think it is a bad idea? If the variable is not used it is ok to > ignore it in this particular circumstance. Other warnings/check should > deal with such a situation IMHO. > > Am 10.08.2018 um

[PATCH] D45444: [clang-tidy] implement new check for const-correctness

2018-08-11 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang added a comment. In https://reviews.llvm.org/D45444#1196271, @JonasToth wrote: > Always the same with the templates ;) So uninstantiated templates should > just be ignored. > > I think it would be better to have it in the ExprMutAnalyzer, because > that part can not decide on

[PATCH] D45444: [clang-tidy] implement new check for const-correctness

2018-08-07 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang added a comment. > - there seems to be a false positive with array-to-pointer decay. > ExprMutAnalyzer does think of it, but maybe there is a bug in it. Could you give a concrete example of this? Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45444

[PATCH] D50619: [clang-tidy] Handle unresolved expressions in ExprMutationAnalyzer

2018-08-15 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang added inline comments. Comment at: unittests/clang-tidy/ExprMutationAnalyzerTest.cpp:410 + match(withEnclosingCompound(declRefTo("y")), AST->getASTContext()); + EXPECT_THAT(mutatedBy(ResultsY, AST.get()), ElementsAre("y")); +} JonasToth wrote: >

[PATCH] D50619: [clang-tidy] Handle unresolved expressions in ExprMutationAnalyzer

2018-08-15 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang updated this revision to Diff 160960. shuaiwang added a comment. Test case with non-type template Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D50619 Files: clang-tidy/utils/ExprMutationAnalyzer.cpp unittests/clang-tidy/ExprMutationAnalyzerTest.cpp Index:

[PATCH] D50619: [clang-tidy] Handle unresolved expressions in ExprMutationAnalyzer

2018-08-15 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang added inline comments. Comment at: unittests/clang-tidy/ExprMutationAnalyzerTest.cpp:309 +TEST(ExprMutationAnalyzerTest, CallUnresolved) { + auto AST = JonasToth wrote: > I think we are missing tests for non-type template paramters (`template > `).

[PATCH] D50619: [clang-tidy] Handle unresolved expressions in ExprMutationAnalyzer

2018-08-15 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang updated this revision to Diff 160952. shuaiwang marked 3 inline comments as done. shuaiwang added a comment. More test cases Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D50619 Files: clang-tidy/utils/ExprMutationAnalyzer.cpp

[PATCH] D50605: [ASTMatchers] Let hasAnyArgument also support CXXUnresolvedConstructExpr

2018-08-12 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang updated this revision to Diff 160265. shuaiwang added a comment. update ast matchers doc Repository: rC Clang https://reviews.llvm.org/D50605 Files: docs/LibASTMatchersReference.html include/clang/AST/ExprCXX.h include/clang/ASTMatchers/ASTMatchers.h

[PATCH] D50605: [ASTMatchers] Let hasAnyArgument also support CXXUnresolvedConstructExpr

2018-08-12 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang marked an inline comment as done. shuaiwang added inline comments. Comment at: include/clang/AST/ExprCXX.h:3436 using const_arg_iterator = const Expr* const *; + using arg_const_range = llvm::iterator_range; aaron.ballman wrote: > Please name

[PATCH] D50606: [ASTMatchers] Add matchers unresolvedMemberExpr, cxxDependentScopeMemberExpr

2018-08-12 Thread Shuai Wang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes. Closed by commit rL339522: [ASTMatchers] Add matchers unresolvedMemberExpr, cxxDependentScopeMemberExpr (authored by shuaiwang, committed by ). Herald added a subscriber: llvm-commits. Repository: rL LLVM

[PATCH] D50619: [clang-tidy] Handle unresolved expressions in ExprMutationAnalyzer

2018-08-14 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang updated this revision to Diff 160694. shuaiwang marked 2 inline comments as done. shuaiwang added a comment. Herald added a subscriber: Szelethus. - Fix a few cases overlooked previously - More test cases Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D50619 Files:

[PATCH] D50619: [clang-tidy] Handle unresolved expressions in ExprMutationAnalyzer

2018-08-16 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang added a comment. In https://reviews.llvm.org/D50619#1202135, @JonasToth wrote: > @shuaiwang i tried to apply this and check the clang-tidy part again, but it > does not compile (log attached). > I update clang to master, did you add a matcher or something like this? > > F6950472:

[PATCH] D50883: [clang-tidy] Handle unique owning smart pointers in ExprMutationAnalyzer

2018-08-16 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang created this revision. shuaiwang added a reviewer: hokein. Herald added subscribers: cfe-commits, Szelethus, a.sidorin, xazax.hun. Herald added a reviewer: george.karpenkov. For smart pointers like std::unique_ptr which uniquely owns the underlying object, treat the mutation of the

[PATCH] D50605: [ASTMatchers] Let hasAnyArgument also support CXXUnresolvedConstructExpr

2018-08-12 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang updated this revision to Diff 160273. shuaiwang marked 3 inline comments as done. shuaiwang added a comment. arg_const_range -> const_arg_range Repository: rC Clang https://reviews.llvm.org/D50605 Files: docs/LibASTMatchersReference.html include/clang/AST/ExprCXX.h

[PATCH] D50619: [clang-tidy] Handle unresolved expressions in ExprMutationAnalyzer

2018-08-12 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang created this revision. shuaiwang added reviewers: aaron.ballman, JonasToth. Herald added subscribers: cfe-commits, a.sidorin, xazax.hun. Herald added a reviewer: george.karpenkov. - If a function is unresolved, assume it mutates its arguments - Follow unresolved member expressions for

[PATCH] D50617: [ASTMatchers] Let hasObjectExpression also support UnresolvedMemberExpr, CXXDependentScopeMemberExpr

2018-08-12 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang created this revision. shuaiwang added a reviewer: aaron.ballman. Herald added a subscriber: cfe-commits. Repository: rC Clang https://reviews.llvm.org/D50617 Files: docs/LibASTMatchersReference.html include/clang/ASTMatchers/ASTMatchers.h

[PATCH] D50605: [ASTMatchers] Let hasAnyArgument also support CXXUnresolvedConstructExpr

2018-08-12 Thread Shuai Wang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes. Closed by commit rL339530: [ASTMatchers] Let hasAnyArgument also support CXXUnresolvedConstructExpr (authored by shuaiwang, committed by ). Herald added a subscriber: llvm-commits. Repository: rL LLVM

[PATCH] D50606: [ASTMatchers] Add matchers unresolvedMemberExpr, cxxDependentScopeMemberExpr

2018-08-12 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang updated this revision to Diff 160263. shuaiwang marked 2 inline comments as done. shuaiwang added a comment. undo unrelated changes in doc Repository: rC Clang https://reviews.llvm.org/D50606 Files: docs/LibASTMatchersReference.html include/clang/ASTMatchers/ASTMatchers.h

[PATCH] D50606: [ASTMatchers] Add matchers unresolvedMemberExpr, cxxDependentScopeMemberExpr

2018-08-12 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang created this revision. Herald added a subscriber: cfe-commits. Repository: rC Clang https://reviews.llvm.org/D50606 Files: docs/LibASTMatchersReference.html include/clang/ASTMatchers/ASTMatchers.h lib/ASTMatchers/ASTMatchersInternal.cpp lib/ASTMatchers/Dynamic/Registry.cpp

[PATCH] D50605: [ASTMatchers] Let hasAnyArgument also support CXXUnresolvedConstructExpr

2018-08-11 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang created this revision. Herald added a subscriber: cfe-commits. Repository: rC Clang https://reviews.llvm.org/D50605 Files: include/clang/AST/ExprCXX.h include/clang/ASTMatchers/ASTMatchers.h unittests/ASTMatchers/ASTMatchersTraversalTest.cpp Index:

[PATCH] D50883: [clang-tidy] Handle unique owning smart pointers in ExprMutationAnalyzer

2018-08-17 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang added a comment. In https://reviews.llvm.org/D50883#1203690, @JonasToth wrote: > I am suprised that this does not automatically follow from the general rules. > At the end, smartpointers cant do anything else then 'normal' classes. > > The `operator+/->` were not handled before? The

[PATCH] D50617: [ASTMatchers] Let hasObjectExpression also support UnresolvedMemberExpr, CXXDependentScopeMemberExpr

2018-08-23 Thread Shuai Wang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes. Closed by commit rC340547: [ASTMatchers] Let hasObjectExpression also support UnresolvedMemberExpr… (authored by shuaiwang, committed by ). Changed prior to commit: https://reviews.llvm.org/D50617?vs=161830=162218#toc

[PATCH] D50617: [ASTMatchers] Let hasObjectExpression also support UnresolvedMemberExpr, CXXDependentScopeMemberExpr

2018-08-21 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang updated this revision to Diff 161830. shuaiwang added a comment. Fix issue with implicit access. Repository: rC Clang https://reviews.llvm.org/D50617 Files: docs/LibASTMatchersReference.html include/clang/ASTMatchers/ASTMatchers.h

[PATCH] D50619: [clang-tidy] Handle unresolved expressions in ExprMutationAnalyzer

2018-08-21 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang added a comment. In https://reviews.llvm.org/D50619#1207785, @JonasToth wrote: > @shuaiwang Unfortunatly the analysis does not pass and fails on an assertion > > → ~/opt/llvm/build/bin/clang-tidy > -checks=-*,cppcoreguidelines-const-correctness ItaniumDemangle.cpp -- > clang-tidy:

[PATCH] D50953: [clang-tidy] Handle sugared reference types in ExprMutationAnalyzer

2018-08-19 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang created this revision. shuaiwang added reviewers: aaron.ballman, alexfh. Herald added subscribers: cfe-commits, Szelethus, a.sidorin, xazax.hun. Herald added a reviewer: george.karpenkov. This handles cases like this: typedef int& IntRef; void mutate(IntRef); void f() { int

[PATCH] D50619: [clang-tidy] Handle unresolved expressions in ExprMutationAnalyzer

2018-09-09 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang added a comment. Ping :) Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D50619 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[PATCH] D45679: [clang-tidy] Add ExprMutationAnalyzer, that analyzes whether an expression is mutated within a statement.

2018-09-10 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang added a comment. In https://reviews.llvm.org/D45679#1183116, @george.karpenkov wrote: > @aaron.ballman @alexfh @shuaiwang Would it be possible to move that code into > a matcher, or into a something which could be used from Clang? We would also > like to use similar functionality,

[PATCH] D50883: [clang-tidy] Handle unique owning smart pointers in ExprMutationAnalyzer

2018-09-10 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang added a comment. In https://reviews.llvm.org/D50883#1229297, @JonasToth wrote: > > Different from std::vector::operator[] which has two overloads for const > > and non-const access, std::unique_ptr only has one const version of > > `operator->`. > > > > So for SmartPtr x; x->mf();

[PATCH] D51884: [clang-tidy] ExprMutationAnalyzer: construct from references. Fixes PR38888

2018-09-10 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang accepted this revision. shuaiwang added a comment. This revision is now accepted and ready to land. LGTM :) Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D51884 ___ cfe-commits mailing list cfe-commits@lists.llvm.org

[PATCH] D45679: [clang-tidy] Add ExprMutationAnalyzer, that analyzes whether an expression is mutated within a statement.

2018-09-10 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang added a comment. I have a rough idea about how `findPointeeMutation` would look like, I'm pretty sure I can use a lot of your help :) My current plan: - Finish the few existing pending changes - Move the analyzer to `clang/lib/Analysis` (likely remove `PseudoConstantAnalysis` there

[PATCH] D50619: [clang-tidy] Handle unresolved expressions in ExprMutationAnalyzer

2018-09-10 Thread Shuai Wang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes. Closed by commit rCTE341848: [clang-tidy] Handle unresolved expressions in ExprMutationAnalyzer (authored by shuaiwang, committed by ). Changed prior to commit: https://reviews.llvm.org/D50619?vs=160960=164704#toc

[PATCH] D51898: Revert "[clang-tidy] Handle unresolved expressions in ExprMutationAnalyzer"

2018-09-10 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang updated this revision to Diff 164773. shuaiwang added a comment. rebase Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D51898 Files: clang-tidy/utils/ExprMutationAnalyzer.cpp unittests/clang-tidy/ExprMutationAnalyzerTest.cpp Index:

[PATCH] D51898: Revert "[clang-tidy] Handle unresolved expressions in ExprMutationAnalyzer"

2018-09-10 Thread Shuai Wang via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs Review". This revision was automatically updated to reflect the committed changes. Closed by commit rL341886: Revert [clang-tidy] Handle unresolved expressions in ExprMutationAnalyzer (authored by shuaiwang, committed by

[PATCH] D51898: Revert "[clang-tidy] Handle unresolved expressions in ExprMutationAnalyzer"

2018-09-10 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang created this revision. Herald added subscribers: cfe-commits, Szelethus, a.sidorin, xazax.hun. Herald added a reviewer: george.karpenkov. Tests somehow break on windows (and only on windows) http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/13003

[PATCH] D50883: [clang-tidy] Handle unique owning smart pointers in ExprMutationAnalyzer

2018-09-11 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang updated this revision to Diff 164810. shuaiwang marked an inline comment as done. shuaiwang added a comment. rebase & add test case Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D50883 Files: clang-tidy/utils/ExprMutationAnalyzer.cpp

[PATCH] D50883: [clang-tidy] Handle unique owning smart pointers in ExprMutationAnalyzer

2018-09-11 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang added inline comments. Comment at: unittests/clang-tidy/ExprMutationAnalyzerTest.cpp:658 + "void f() { UniquePtr x; x->mf(); }"); + Results = match(withEnclosingCompound(declRefTo("x")), AST->getASTContext()); + EXPECT_FALSE(isMutated(Results,

[PATCH] D50953: [clang-tidy] Handle sugared reference types in ExprMutationAnalyzer

2018-09-10 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang updated this revision to Diff 164806. shuaiwang marked 2 inline comments as done. shuaiwang added a comment. more test cases. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D50953 Files: clang-tidy/utils/ExprMutationAnalyzer.cpp

[PATCH] D50953: [clang-tidy] Handle sugared reference types in ExprMutationAnalyzer

2018-09-10 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang added a comment. In https://reviews.llvm.org/D50953#1229287, @JonasToth wrote: > What happens to pointers in a typedef (in the sense of `*` instead of `&`)? I checked around and I believe reference type is the only type we're explicitly matching right now. We'll need to handle

[PATCH] D48854: Use ExprMutationAnalyzer in performance-for-range-copy

2018-07-10 Thread Shuai Wang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes. shuaiwang marked an inline comment as done. Closed by commit rL336737: Use ExprMutationAnalyzer in performance-for-range-copy (authored by shuaiwang, committed by ). Herald added a subscriber: llvm-commits. Repository:

[PATCH] D48854: Use ExprMutationAnalyzer in performance-for-range-copy

2018-07-10 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang marked an inline comment as done. shuaiwang added inline comments. Comment at: test/clang-tidy/performance-for-range-copy.cpp:120 +struct Point { + ~Point() {} JonasToth wrote: > I feel that `const` methods should be added as a test as well. const

[PATCH] D51950: [clangtidy] Remove old copy of ExprMutationAnalyzer

2018-09-11 Thread Shuai Wang via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes. Closed by commit rCTE342006: [clangtidy] Remove old copy of ExprMutationAnalyzer (authored by shuaiwang, committed by ). Changed prior to commit: https://reviews.llvm.org/D51950?vs=164977=164991#toc Repository: rCTE

[PATCH] D45679: [clang-tidy] Add a helper function isModified, that checks whether an expression is modified within a statement.

2018-04-17 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang marked an inline comment as done. shuaiwang added a comment. Hi @alexfh, @hokein, @JonasToth, I've updated this diff to be just adding the helper function `isModified()` with a set of dedicated unit tests. What do you think of the approach of getting this change committed and then

[PATCH] D45679: [clang-tidy] Add a new check, readability-unmodified-non-const-variable, that finds declarations of non-const variables that never get modified.

2018-04-17 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang updated this revision to Diff 142739. shuaiwang added a comment. Change to just add a helper function `isModified` Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45679 Files: clang-tidy/utils/ASTUtils.cpp clang-tidy/utils/ASTUtils.h

[PATCH] D45679: [clang-tidy] Add a helper function isModified, that checks whether an expression is modified within a statement.

2018-04-17 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang updated this revision to Diff 142882. shuaiwang added a comment. Better range for loop handling. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45679 Files: clang-tidy/utils/ASTUtils.cpp clang-tidy/utils/ASTUtils.h unittests/clang-tidy/CMakeLists.txt

[PATCH] D45444: [clang-tidy] WIP: implement new check for const-correctness

2018-04-16 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang added a comment. >> I would imagine things could get messier if this check expands to also >> check for turning member functions const: it's basically checking >> CxxThisExpr, being a handle, is not modified within a member function, but >> note there's no VarDecl for "this". > >

[PATCH] D45444: [clang-tidy] WIP: implement new check for const-correctness

2018-04-16 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang added a comment. In https://reviews.llvm.org/D45444#1068967, @Eugene.Zelenko wrote: > In https://reviews.llvm.org/D45444#1068496, @shuaiwang wrote: > > > - I would imagine things could get messier if this check expands to also > > check for turning member functions const: it's

[PATCH] D45679: Add a new check, readability-unmodified-non-const-variable, that finds declarations of non-const variables that never get modified.

2018-04-15 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang created this revision. Herald added subscribers: cfe-commits, mgorny, klimek. shuaiwang added a reviewer: hokein. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45679 Files: clang-tidy/readability/CMakeLists.txt clang-tidy/readability/ReadabilityTidyModule.cpp

[PATCH] D45702: [clang-tidy] Add a new check, readability-redundant-data-call, that finds and removes redundant calls to .data().

2018-04-16 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang created this revision. Herald added subscribers: cfe-commits, xazax.hun, mgorny, klimek. shuaiwang added a reviewer: sbenza. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45702 Files: clang-tidy/readability/CMakeLists.txt

[PATCH] D45444: [clang-tidy] WIP: implement new check for const-correctness

2018-04-15 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang added a comment. Coming from https://reviews.llvm.org/D45679, which I should have sent out much earlier to get in front of you :p Kidding aside this check is more mature than mine and I'm happy to help incorporate mine into this one. I do have a strong opinion that requires

[PATCH] D45679: [clang-tidy] Add a helper function isModified, that checks whether an expression is modified within a statement.

2018-04-17 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang added a comment. In https://reviews.llvm.org/D45679#1069754, @Eugene.Zelenko wrote: > In https://reviews.llvm.org/D45679#1069638, @JonasToth wrote: > > > *hust* /llvm/tools/clang/lib/Analysis/PseudoConstantAnalysis.cpp > > > > I will check this one first, before we get crazy and

[PATCH] D45679: [clang-tidy] Add a helper function isModified, that checks whether an expression is modified within a statement.

2018-04-17 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang updated this revision to Diff 142878. shuaiwang added a comment. Handle range-based for loop Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45679 Files: clang-tidy/utils/ASTUtils.cpp clang-tidy/utils/ASTUtils.h unittests/clang-tidy/CMakeLists.txt

[PATCH] D45679: [clang-tidy] Add a new check, readability-unmodified-non-const-variable, that finds declarations of non-const variables that never get modified.

2018-04-16 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang updated this revision to Diff 142730. shuaiwang added a comment. Updated mostly `isModified()`. I'd like to mostly demonstrate that `isModified()` works given that there's https://reviews.llvm.org/D45444 and we'd like to merge. Repository: rCTE Clang Tools Extra

[PATCH] D45444: [clang-tidy] WIP: implement new check for const-correctness

2018-04-16 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang added a comment. I've updated https://reviews.llvm.org/D45679 and I think the `isModified()` function there is now sufficiently covering the cases you've covered here and can be used as a good starting version if you plan to use it here. I copied your const-values test cases and it

[PATCH] D45679: [clang-tidy] Add a helper function isModified, that checks whether an expression is modified within a statement.

2018-04-17 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang updated this revision to Diff 142870. shuaiwang edited the summary of this revision. shuaiwang added a comment. Handle casts, ternary operator and lambdas. Also optionally returns a chain of Stmt giving more details about how the conclusion is reached. Repository: rCTE Clang Tools

[PATCH] D45679: [clang-tidy] Add a helper function isModified, that checks whether an expression is modified within a statement.

2018-04-19 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang updated this revision to Diff 143197. shuaiwang marked 13 inline comments as done. shuaiwang added a comment. - Moved out of ASTUtils and becomes a separte class ExprMutationAnalyzer (bikeshedding on name a bit.) - Reverted back to return bool instead of tri-valued enum, the meanings

[PATCH] D45679: [clang-tidy] Add a helper function isModified, that checks whether an expression is modified within a statement.

2018-04-19 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang added a comment. Regarding full dependency analysis, I think it's out of the scope of this change at least for now. We're only trying to find //one// possible point where the given `Expr` is (assumed to be) mutated. This is known to be useful at this point for use cases like "check

[PATCH] D45702: [clang-tidy] Add a new check, readability-redundant-data-call, that finds and removes redundant calls to .data().

2018-04-19 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang updated this revision to Diff 143204. shuaiwang marked 7 inline comments as done. shuaiwang added a comment. Addressed review comments. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45702 Files: clang-tidy/readability/CMakeLists.txt

[PATCH] D45702: [clang-tidy] Add a new check, readability-redundant-data-call, that finds and removes redundant calls to .data().

2018-04-19 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang updated this revision to Diff 143207. shuaiwang marked 7 inline comments as done. shuaiwang added a comment. Addressed more comments. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45702 Files: clang-tidy/readability/CMakeLists.txt

[PATCH] D45702: [clang-tidy] Add a new check, readability-redundant-data-call, that finds and removes redundant calls to .data().

2018-04-19 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang added inline comments. Comment at: clang-tidy/readability/RedundantDataCallCheck.cpp:22 + +const char kDefaultTypes[] = +"::std::basic_string;::std::basic_string_view;::std::vector;::std::array"; Eugene.Zelenko wrote: > Actually you should use

[PATCH] D45153: test

2018-04-01 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang created this revision. Herald added subscribers: cfe-commits, klimek. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45153 Files: clang-tidy/utils/ASTUtils.cpp clang-tidy/utils/ASTUtils.h Index: clang-tidy/utils/ASTUtils.h

[PATCH] D54399: Move ExprMutationAnalyzer to Tooling/Analysis (1/3)

2018-11-11 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang created this revision. Herald added subscribers: cfe-commits, dkrupp, donat.nagy, Szelethus, a.sidorin, mgorny. Herald added a reviewer: george.karpenkov. This just copies ExprMutationAnalyzer to Tooling/Analysis with minor tweaks around including path & namespaces. 2/3 will change

[PATCH] D54400: Move ExprMutationAnalyzer to Tooling/Analysis (2/3)

2018-11-11 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang created this revision. shuaiwang added reviewers: george.karpenkov, rsmith, dblaikie. Herald added subscribers: cfe-commits, dkrupp, donat.nagy, Szelethus, a.sidorin, mgorny. shuaiwang added a dependency: D54399: Move ExprMutationAnalyzer to Tooling/Analysis (1/3). Reference the new

[PATCH] D52219: [analyzer] (1/n) Support pointee mutation analysis in ExprMutationAnalyzer.

2018-10-06 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang updated this revision to Diff 168578. shuaiwang marked 5 inline comments as done. shuaiwang added a comment. Resolved review comments. Repository: rC Clang https://reviews.llvm.org/D52219 Files: include/clang/Analysis/Analyses/ExprMutationAnalyzer.h

[PATCH] D52219: [analyzer] (1/n) Support pointee mutation analysis in ExprMutationAnalyzer.

2018-09-19 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang marked 5 inline comments as done. shuaiwang added inline comments. Comment at: unittests/Analysis/ExprMutationAnalyzerTest.cpp:67 +if (const auto *DRE = dyn_cast(E)) { + if (DRE->getNameInfo().getAsString()[0] == 'p') +Finder = PointeeMutationFinder;

[PATCH] D52219: [analyzer] (1/n) Support pointee mutation analysis in ExprMutationAnalyzer.

2018-09-21 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang updated this revision to Diff 166595. shuaiwang marked 5 inline comments as done. shuaiwang added a comment. Addresses review comments. Repository: rC Clang https://reviews.llvm.org/D52219 Files: include/clang/Analysis/Analyses/ExprMutationAnalyzer.h

  1   2   >