[LLVMdev] [cfe-dev] UB in TypeLoc casting

David Blaikie dblaikie at gmail.com
Thu Feb 21 14:52:16 PST 2013


On Fri, Feb 15, 2013 at 4:55 PM, Ted Kremenek <kremenek at apple.com> wrote:

> On Feb 11, 2013, at 12:02 PM, David Blaikie <dblaikie at gmail.com> wrote:
>
> Beyond that, though, I've hit one hierarchy in the Static Analyzer
> that does this as well: ProgramPoint. On IRC Jordan Rose mentioned
> that there's another more pervasive use of this pattern in the Static
> Analyzer, the SVal hierarchy.
>
> So, Ted, how objectionable would it be for me to introduce something
> like (names subject to adjustment):
>
> template<typename T>
> T SVal::castAs();
>
> template<typename T>
> llvm::Optional<T> SVal::getAs();
>
> (the implementations of these functions might involve invoking private
> FooSVal(SVal) ctors in each SVal derived type - so adding a bit of
> boilerplate ctors to all those classes)
>
> and replace "cast<FooSVal>(bar)" with "bar.castAs<FooSVal>()" and
> dyn_cast with getAs similarly? & similarly for the ProgramPoint (&
> TypeLoc - which I'm already working on) hierarchies?
>
>
> Sorry everyone for not seeing this.  Jordan was nice enough to ping me.  I
> would be perfectly fine with this change, and I think it looks cleaner
> anyways.  I think it is a great idea.
>

Thanks for your patience - the final change to llvm::cast & friends to
disallow rvalues (based on Eli's suggestion, tweaked to work with LLVM type
traits rather than C++11 traits) has been committed in r175462.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130221/52881f3c/attachment.html>


More information about the llvm-dev mailing list