I’m talking with a student whose BSc thesis I might end up supervising. I’ve offered him that he could work on a static analyzer checker to model std::any, which seems totally reasonable to me, but I admit that my knowledge is a bit rusty.
So, my question is, does this sound reasonable or meaningful enough? Is there any obstacles I haven’t considered?
Have you considered std::variant as well? It appears to be similar but arguably more practical. At least, that’s something I’ve reached for a few times myself (before remembering that in LLVM we use custom RTTI instead). After all, discriminated union types and algebraic type systems are hot right now.
How difficult are these classes to inline? Say, with smart pointers we were wary of null checks and, for shared pointers, reference count checks. But if the class doesn’t have any “unexpected” nested branches, maybe we should just force-inline it all? (By “expected” inlined branches I mean branches in nested stack frames such that hitting that branch is the whole point of calling the function, eg. isa(); such branches don’t cause unwanted execution paths to appear, so a state split over them is “justified” in the caller stack frame).
Technically this sounds straightforward enough, as long as you know how to deal with C++ value semantics (i.e., objects under construction and related problems). As usual, I’ll encourage you folks to build a better checker API around those, so that it wasn’t too painful to implement the related boilerplate in every checker ^.^