[cfe-commits] r95964 - in /cfe/trunk: include/clang/AST/Type.h include/clang/AST/TypeNodes.def lib/Sema/Sema.h

Douglas Gregor dgregor at apple.com
Fri Feb 12 08:00:02 PST 2010


On Feb 12, 2010, at 12:58 AM, Sebastian Redl wrote:

> 
> On Fri, 12 Feb 2010 03:41:31 -0000, John McCall <rjmccall at apple.com>
> wrote:
>> Author: rjmccall
>> Date: Thu Feb 11 21:41:30 2010
>> New Revision: 95964
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=95964&view=rev
>> Log:
>> Waste two bits in every clang::Type so that the type class can be read
>> in a single byte-load rather than some crazy bitmunging operation.
>> 
>> 
> ==============================================================================
>> --- cfe/trunk/include/clang/AST/Type.h (original)
>> +++ cfe/trunk/include/clang/AST/Type.h Thu Feb 11 21:41:30 2010
>> @@ -751,24 +751,22 @@
>> public:
>>   enum TypeClass {
>> #define TYPE(Class, Base) Class,
>> +#define LAST_TYPE(Class) TypeLast = Class,
>> #define ABSTRACT_TYPE(Class, Base)
>> #include "clang/AST/TypeNodes.def"
> 
> How about
> 
> + TypeBeyondLast,
> + TypeLast = TypeBeyondLast - 1,
> 
> and leaving TypeNodes.def alone?

If we do that, we'll get -Wswitch warnings for every switch-on-type-class we do, and have to add

	case Type::TypeLast: llvm_unreachable("impossible!");

in a bunch of places. Since it's only a small amount of effort required to avoid this particular issue, I think I prefer John's solution.

	- Doug



More information about the cfe-commits mailing list