[clang] [clang-tools-extra] [clang] Avoid re-evaluating field bitwidth (PR #117732)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 27 09:13:38 PST 2024


Timm =?utf-8?q?Bäder?= <tbaeder at redhat.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/117732 at github.com>


erichkeane wrote:

> Meh, saving a `ConstantExpr` in the `FieldDecl` doesn't work properly, since we need to support having arbitrary exprs in case the bitwidth is dependent.

The idea is that you'd store an `Expr` like we do elsewhere, and then upon instantiating it/evaluating it, we'd replace it with a `ConstantExpr`.  So you don't need separate storage, just replace the current thing.

The instantiation of a `ConstantExpr` is to just return it, so you don't end up losing anything as a side effect.

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


More information about the cfe-commits mailing list