[clang] Resolve FIXME: Look at E, not M (PR #85541)

Richard Smith via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 29 00:51:46 PDT 2024


zygoloid wrote:

IIRC the issue here is that in C++98, the MTE is in a "weird" place in the AST, because of the different rules governing how and when temporaries are formed. For example, for `const int &r = C().a[0];`, we'll form an MTE wrapping just the `C()` expression, converting it to an xvalue, in C++11 onwards. But in C++98, xvalues mostly don't exist, the MTE wraps the whole `C().a[0]`, and you need to call `skipRValueSubobjectAdjustments` to get the actual expression that initializes the temporary, which I guess is what `E` is here.

So I think the idea is that `E` is always the expression that initializes the temporary, and the type of `M` in C++98 might be some subobject of that, with a type that doesn't reflect properties of the temporary. So we should generally look at properties of `E`, not `M`, to understand properties of the temporary object. But in C++11 onwards I think it doesn't matter, because we always materialize immediately.

(That's mostly from memory, I might have got some details wrong.)

https://github.com/llvm/llvm-project/pull/85541


More information about the cfe-commits mailing list