[PATCH] Getting the builtin types from the ASTContext knowing their type

Hi,

   I play with the type definitions in my code and I need to get a
builtin type from an ASTContext in a situation when I just know a
Builtin::Kind value associated to it. I'm not sure if want a patch
like that but still I attach it. It also adds a CVR Qualifiers setter
to clang::QualType.

Cheers,
   Lukasz

clang-ast-context-builtin-type-get-by-kind.patch (2.14 KB)

Hi,

  I play with the type definitions in my code and I need to get a
builtin type from an ASTContext in a situation when I just know a
Builtin::Kind value associated to it. I'm not sure if want a patch
like that but still I attach it.

Two things. First, on a picky front, the patch uses a different convention for whitespace than the rest of clang. Instead of things like "getBuiltinType( BuiltinType::Kind K )" please use "getBuiltinType(BuiltinType::Kind K)" etc.

Second, instead of building and maintaining an array, why not just make getBuiltinType switch on the kind and dispatch to the appropriate method? That would eliminate the storage for BuiltinTypes.

It also adds a CVR Qualifiers setter
to clang::QualType.

Ok, applied (after formating changes):
http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20081222/010456.html

-Chris

Two things. First, on a picky front, the patch uses a different convention
for whitespace than the rest of clang. Instead of things like
"getBuiltinType( BuiltinType::Kind K )" please use
"getBuiltinType(BuiltinType::Kind K)" etc.

   Ok, I will pay more attention next time.

Second, instead of building and maintaining an array, why not just make
getBuiltinType switch on the kind and dispatch to the appropriate method?
That would eliminate the storage for BuiltinTypes.

    Because the switch approach is more code and I'm a lazy person :))
And seriously, that's just a couple of extra bytes per context but
you're right that it might not have been the best idea to have an
array indexed with enums. I will redo the patch when I'm back from the
Xmas holidays.

Cheers,
   Lukasz