[cfe-dev] Where to put exception spec source locations?

Sebastian Redl sebastian.redl at getdesigned.at
Sun May 31 11:42:36 PDT 2009


Hi,

Where in the AST would be a good home for exception specification source
locations? I store the thrown types in the Type hierarchy, but I
obviously can't do that for source locations.

If it was only functions, I could put them into the FunctionDecl:

void fn() throw(int);

However, what about this function pointer?

void (*fn)() throw(int);

It only has some kind of VarDecl. It would be very weird to extend
VarDecl with source locations for an exception spec, and it wouldn't
work anyway:

void (*fn)(void (*)() throw (int)) throw(int);

What we have here is a pointer to a function that could throw int, and
takes as its only parameter a pointer to a function that could throw
int. One VarDecl for the whole construct, and of course I could extend
it to as many parameters as Clang supports (2^20-1).

I need such source locations to accurately point to the types that are
mismatches. I also need them if I want to point to anything useful when
instantiating a type that has a template parameter in its throw list:

template <typename T> struct X {
  void fn() throw(T); // Obviously, this could just as well be a
function pointer.
};
X<void> x; // Oops, cannot have throw(void) in function type. But where
to point?

Any suggestions?

Sebastian



More information about the cfe-dev mailing list