[Clang] Fix instantiation of OpaqueValueExprs (Bug #45964)
authorJason Rice <ricejasonf@gmail.com>
Fri, 5 Nov 2021 10:30:39 +0000 (12:30 +0200)
committerRaul Tambre <raul@tambre.ee>
Sat, 6 Nov 2021 08:06:38 +0000 (10:06 +0200)
commitb5aef90d4656c5188759d03e2c5c3dc3d8bb398b
treee9f3c7e806c2b500ea5bf7a3046f55b7a315db4f
parent39ead64e3f73045c7e0c72aed08c14b277828fb4
[Clang] Fix instantiation of OpaqueValueExprs (Bug #45964)

The structured bindings decomposition of a non-dependent array in a dependent context (a template) were, upon instantiation, creating nested OpaqueValueExprs that would trigger assertions in CodeGen. Additionally the OpaqueValuesExpr's contained SourceExpr is being emitted in CodeGen, but there was no code for its transform in template instantiation. This would trigger other assertions such as when emitting a DeclRefExpr that refers to a VarDecl that is not marked as ODR-used.

This is all based on cursory deduction, but with the way the code flows from SemaTemplateInstantiate back to SemaInit, it is apparent that the nesting of OpaqueValueExpr is unintentional.

This commit fixes https://bugs.llvm.org/show_bug.cgi?id=45964 and possible other issues involving OpaqueValueExprs in template instantiations might be resolved.

Reviewed By: aaron.ballman, rjmccall

Differential Revision: https://reviews.llvm.org/D108482
clang/lib/Sema/TreeTransform.h
clang/test/CodeGenCXX/pr45964-decomp-transform.cpp [new file with mode: 0644]