[clang] [clang][bytecode] Fix void*-to-ptr casts originating from new/new[] (PR #174132)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 2 17:05:07 PST 2026
================
@@ -433,6 +433,22 @@ QualType Descriptor::getDataType(const ASTContext &Ctx) const {
return getType();
}
+QualType Descriptor::getDataElemType() const {
+ if (const auto *E = asExpr()) {
----------------
keinflue wrote:
I could factor out the conditions for the `new`/`allocate` expressions into another function which would then return the element type before it is (possibly) turned into an array type. But that function then also needs to return whether or not the special handling applies (rather than the default path `return getType();`), e.g. by returning an empty `QualType`, maybe?
Alternatively I could add a parameter `bool ElemTypeOnly` to switch between the two variants in a single function. That would look cleaner in the implementation, but has the usual problems of a `bool` parameter affecting the semantics of a function.
Any opinions on these approaches?
https://github.com/llvm/llvm-project/pull/174132
More information about the cfe-commits
mailing list