Prototype implementation of -funsigned-bitfields flag. This solution ignores explicit signdness of bitfields and will make them unsigned (except for char) , which not align with the expected behavior of this flag. The problem is that the explicit signdess information seems to be lost at this point for typedefs. It is possible to check DeclSpec of the Declarator for signdness, but if the current Declarator is a typename, then there is a problem with this approach, since that will not have the explicit signdess information of the underlying type. I looking for help/guidance how to proceed with this to make this feature work, that is: only make unsigned those bitfields which were not explicitly made signed.
Details
Details
Diff Detail
Diff Detail
Event Timeline
clang/lib/Sema/SemaDecl.cpp | ||
---|---|---|
18137 | The information seems preserved in BuiltinTypeLoc::getWrittenSignSpec | |
18146–18158 | ASTContext::getCorrespondingUnsignedType is probably the better way to do that |
The information seems preserved in BuiltinTypeLoc::getWrittenSignSpec
From TypedefType::getDecl, you can get a TypedefNameDecl, which has a getTypeSourceInfo, which gets you a TypeSourceInfo, that you can extract a TypeLoc from, and if you cast that to BuiltinTypeLoc, you might be able to find what you need. Good luck!