[cfe-dev] Do we intentionally 'transform' non-dependent expressions?

Keane, Erich via cfe-dev cfe-dev at lists.llvm.org
Fri Sep 20 09:14:32 PDT 2019


I decided to investigate https://bugs.llvm.org/show_bug.cgi?id=43370

First, this code is in a dependent context (but is not dependent itself):
uint64_t v[2];
    __atomic_store_n(v, 0, 0);

The function template declaration in the AST shows the first parameter as having an ArrayToPointerDecay implicit cast.

However, the AtomicExpr transform calls "TransformExpr" on this, which then strips off all implicit casts. The expression then is NOT checked later, since it was already checked the first time.  If the expression is dependent, it gets properly checked, and the cast is added back in.

It seems to me that transforming a dependent expression should be unnecessary at best, and a risk of crashing at worst (due to running out of Transform stack space).  SO, I put a test in the beginning of TransformExpr to just return the expr.

However, check-clang resulted in 600+ test failures.  I evaluated a couple, and all seem to be because they are re-checking a statement that doesn't need to be (since it isn't dependent!).  There is unfortunately no good way it seems to determine whether a Stmt is dependent, so I can't find anything to put into TransformStmt to skip like before.  So, I think I will have to manage these tests 1 by 1.

Before I deep-dive into this, I'd like to hear whether I'm missing something obvious and would just be wasting my time?  Does anyone know whether there is a good reason to still transform non-dependent expressions?

Thanks,
Erich

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20190920/20a6a2b5/attachment.html>


More information about the cfe-dev mailing list