llvm-project
2d45a910 - [clang][bytecode] Fix void*-to-ptr casts originating from new/new[] (#174132)

Commit
29 days ago
[clang][bytecode] Fix void*-to-ptr casts originating from new/new[] (#174132) In void*-to-ptr casts, the type of the pointed-to object in the source operand needs to be compared to the target pointee type. If a block was created for a `new`/`new[]`/`std::allocator` expression, then a pointer needs to be stripped from the type of the expression (which points to the single-object allocation or first element of the allocation) to get the former. `Descriptor::getType` did not do this and `Descriptor::getDataType` returns an array type for array allocations. Therefore this introduces a new function `Descriptor::getDataElemType` with the same behavior as `Descriptor::getDataType`, except that it always produces the element type in the array case and avoids the need for an `ASTContext` reference. Make `Pointer::getType` use this function instead. Fixes #174131
Author
Parents
Loading