================
@@ -316,10 +316,15 @@ class TrivialFunctionAnalysisVisitor
 
     if (UO->isIncrementOp() || UO->isDecrementOp()) {
       // Allow increment or decrement of a POD type.
-      if (auto *RefExpr = dyn_cast<DeclRefExpr>(UO->getSubExpr())) {
+      auto *SubExpr = UO->getSubExpr();
+      if (auto *RefExpr = dyn_cast<DeclRefExpr>(SubExpr)) {
----------------
haoNoQ wrote:

Hmm. You're jumping two steps at a time here: exploring `UnaryOperator` and the 
inner `DeclRefExrpr`/`MemberExpr` together simultaneously, as opposed to fully 
relying on the `Visit()` method which already has slightly different behavior.

For example, it looks like an access to a global variable is considered trivial 
_unless it's an increment_. In particular, `global += 1` is still considered 
trivial but `++global` isn't. (This has actually already been the case before 
your patch, you just added more similar behavior.)

Is this intended? Maybe it's better to check for these extra conditions by 
default?

https://github.com/llvm/llvm-project/pull/91102
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to