[PATCH] D149942: [IR] Drop const in DILocation::getMergedLocation
Christian Ulmann via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun May 21 23:22:51 PDT 2023
Dinistro added a comment.
In D149942#4351081 <https://reviews.llvm.org/D149942#4351081>, @dblaikie wrote:
> any particular examples of these problematic const_casts? (is there a subsequent cleanup patch showing the motivation/value in this patch?)
`DILocation` has a special relationship with constness. This revision removes the traces of constness in MLIR's import, which was the main motivation for this cleanup.
In general, once `DILocations` are treated like metadata, they are usually stripped from their constness, which can cause UB.
For example, the `DebugLoc` constructors (https://github.com/llvm/llvm-project/blob/main/llvm/lib/IR/DebugLoc.cpp#L17) contain `const_cast`s to strip away constness, which seems dangerous considering that they provided accessors to that casted pointer.
Currently, we have no plans to push this further, as constness changes can be invasive, and we do not have the resources to commit to this.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D149942/new/
https://reviews.llvm.org/D149942
More information about the llvm-commits
mailing list