[PATCH] D52008: [analyzer] Handle forwarding reference better in ExprMutationAnalyzer.

Shuai Wang via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 13 10:37:00 PDT 2018


shuaiwang added a comment.

Just some quick comments, I'll take a deeper look into other comments later.

This diff along unfortunately won't be able to handle `emplace_back` just yet, the reason (I believe, haven't fully tested) is that `std::forward` is not handled properly and almost all std functions involving forwarding references at least `std::forward`'ed once.
I have some more changes locally that treats `std::move` and `std::forward` just as casts and that should be able to really push the analysis further down the forwarding chain instead of stopping at `std::forward` call.
Rephased diff description to be more clear. Sorry for the confusion.



================
Comment at: include/clang/Analysis/Analyses/ExprMutationAnalyzer.h:60
+public:
+  FunctionParmMutationAnalyzer(const FunctionDecl &Func, ASTContext &Context);
+
----------------
JonasToth wrote:
> Why do we need a separate class for this?
> I think you can just create another object of `ExprMutAnalyzer` and do the analysis with `findDeclMutation(FunctioParm)`.
> 
> The `Stmt` is the `functionDecl().getBody()`. Right now it could be that you pass in an functionDecl without body.
> 
> Could there something happen with extern templates that the body is not accessible?
It's mostly for the special handling of constructors in which case initializer list also could mutate param.


Repository:
  rC Clang

https://reviews.llvm.org/D52008





More information about the cfe-commits mailing list