Adding getTypeSizeInBytes to ASTContext

Sprinkled throughout clang are expressions of the form:

size = Context.getTypeSize(SomeType) / 8;

These expressions quite obviously assume that the width of a byte is 8
bits.

As a first step in eliminating this assumption and someday supporting
targets with byte widths other than 8 bits, the attached patch
introduces two new methods to ASTContext.

  1. getByteSize(): returns the width of the target's character type (on
all existing targets it returns 8).

  2: getTypeSizeInBytes(T): returns getTypeSize(T) / getByteSize(T),
i.e. the size of a given type in bytes.

With this patch applied, the above snippet could be replaced with:

  size = Context.getTypeSizeInBytes(SomeType);

The getByteSize() method is intended for use by a follow-on patch that
will introduce getTypeAlignInBytes() and to replace literal 8s in other
parts of the code.

Any objections? Comments?

-Ken

ASTContext-getTypeSizeInBytes.r89592.patch (890 Bytes)

Looks fine to me.

  - Doug

Great! Committed in 89760.

-Ken