[PATCH] D58035: [clang/DIVar] Emit flag for params that have unchanged values

Djordje Todorovic via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Feb 26 07:12:43 PST 2019


djtodoro marked an inline comment as done.
djtodoro added inline comments.


================
Comment at: lib/Sema/SemaExpr.cpp:11292
+}
+
+/// Argument's value might be modified, so update the info.
----------------
riccibruno wrote:
> Hmm, I don't think that this will work. Suppose that you have an expression like `(a, b) += c`  You want to mark `b` as modified, but not `a`. What is needed I believe is:
> 
> Given an expression `E` find the variable that this expression designate if any, and if it is a function parameter mark it "known to be modified".
> 
> Visiting all of the children just looking for `DeclRefExpr`s is a bit too blunt I believe.
You are right. We thought it is possible implementing this with some basic analysis (with low overhead), but in order to support all cases it would take much time and it is not good idea.

I tried to use `ExprMutationAnalyzer ` (that @lebedev.ri mentioned) and it seems to be useful for this. It seems that it can be used a little bit later than in this phase, because it takes ASTContext, but in this stage we have ASTContext finished up to node we are currently observing (an expression from which we are extracting DeclRef). But, even using it in the right time, it seems that `ExprMutationAnalyzer ` does not have support for comma operator. I'm trying to extend this analyzer in order to add support for that. ASAP I will post new changes.
For the other cases I tried, it works.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D58035/new/

https://reviews.llvm.org/D58035





More information about the cfe-commits mailing list