[cfe-dev] Recovering the spelling of a typedef

Keno Fischer via cfe-dev cfe-dev at lists.llvm.org
Mon Jul 25 18:55:57 PDT 2016


Hi Everyone,

We're trying to integrate the CERN ROOT framework with Julia, both
of which use LLVM/Clang for C++ interoperability. As such, we're hoping
to harmonize the versions of clang used in both projects. One major
obstacle to this currently is a patch that the ROOT folks are carrying
to support their I/O system which uses the structure of C++ classes to
determine the on-disk format. The patch as is isn't really in a form
that could be submitted upstream, but we're hoping to solicit some advice
to come up with a solution that would be acceptable to clang, and not
require any local code patches.

With that in mind, let us describe the problem:

As mentioned, ROOT uses the structure of C++ classes to determine it's
IO format. The one wrinkle to that is that sometimes the I/O storage
format and the in-memory format are not exactly the same. In particular,
ROOT has a

typedef double Double32_t;

where if this typedef appears in a struct that is serialized to disk,
it indicates that it should be stored with 32bit precision on disk, but
with 64bit precision in memory.

That's *only* for I/O information; for anything regarding symbols we
need these two to share their instantiation data.

I.e. we want to distinguish the types of D<double>::m and
D<Double32_t>::m (and also D<vector<Double32_t>>::m and
D<vector<double>>::m) in

template <class T>
struct D {
using type = std::remove_reference<D>;
T m;
static int s;
};

But &D<double>::s must the the same as D<Double32_t>::s; more importantly:

void f(D<double>);

must be called by f(D<Double32_t>{}). That is (IIRC) in contrast of what
the C++ committee discussed for strong typedefs.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20160725/2b84d120/attachment.html>


More information about the cfe-dev mailing list