[PATCH] D52738: [AST] Pack the bit-fields of FunctionProtoType into Type.

Bruno Ricci via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 1 11:38:22 PDT 2018


riccibruno created this revision.
riccibruno added a reviewer: rjmccall.
riccibruno added a project: clang.
Herald added a subscriber: cfe-commits.

Move the bit-fields of FunctionProtoType into FunctionTypeBitfields. This cuts the
size of FunctionProtoType by a pointer. Additionally use llvm::TrailingObjects instead
of manually doing the casts + arithmetic.

This patch is bigger then what could be expected for the following reasons:

1. As discussed before in https://reviews.llvm.org/D50631 it would be nice if there was some space left in FunctionTypeBitfields for future additions. This patch introduces an extra structure FunctionTypeExtraBitfields which is supposed to hold uncommon bits and is stored in a trailing object. The number of exception types NumExceptions is moved to this struct. As of this patch this trailing struct will only be allocated if we have > 0 types in a dynamic exception specification.

2. TrailingObjects cannot (at least I think it cannot) handle repeated types. Therefore the QualType representing an exception type is wrapped in a struct ExceptionType. The ExceptionType * is then reinterpret_cast'd to QualType * which I think is fine since QualType and ExceptionType are standard-layout classes (but please correct me if wrong).

3. TrailingObjects needs the definition of the various trailing classes. Therefore ExtParameterInfo, ExceptionType and FunctionTypeExtraBitfields are put in FunctionType.


Repository:
  rC Clang

https://reviews.llvm.org/D52738

Files:
  include/clang/AST/Type.h
  lib/AST/ASTContext.cpp
  lib/AST/Type.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52738.167777.patch
Type: text/x-patch
Size: 34077 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181001/b7db83c1/attachment-0001.bin>


More information about the cfe-commits mailing list