[cfe-dev] Type Uniquing with noexcept specifiers

John McCall rjmccall at apple.com
Mon Mar 7 15:35:45 PST 2011


On Mar 7, 2011, at 2:57 PM, Douglas Gregor wrote:
> On Mar 7, 2011, at 12:46 PM, Sebastian Redl wrote:
>> With noexcept, FunctionProtoType gained an Expr* member. This is a problem for uniquing types: to profile an Expr, I need an ASTContext, but I can't get one into FunctionProtoType::Profile(). Other types with an Expr* member (e.g. DependentTypeOfExprType) store their own ASTContext, but I'm loath to store one in a type as common as FunctionProtoType.
>> 
>> Do I have a choice?
> 
> In this case, I would add a FunctionProtoWithNoExceptType node that's a "hidden" subclass adding the Expr* and the ASTContext&. We've done this elsewhere, for rarely-used fields of common Type nodes.

To resolve the immediate problem, there's an llvm::ContextualFoldingSet now, so we should really never be doing this ASTContext&-stashing thing anymore.

We can't make subclasses of FunctionProtoType, though, because we store the argument types after the type node.  I'd suggest redesigning the existing exception-spec bits, maybe like this:
  /// 0 - no exception spec, NumExceptions is zero
  /// 1 - throw(a,b), NumExceptions is the number of types
  /// 2 - throw(...), NumExceptions is zero
  /// 3 - noexcept, NumExceptions is the number of expressions
  unsigned EHSpecKind : 2;

John.



More information about the cfe-dev mailing list