[cfe-dev] Patch for bug 8396, and similar issues

Ryan Gerleve aikavanak at gmail.com
Sat Nov 6 23:52:31 PDT 2010


Hello!
As my first project hacking on clang, I decided to fix the simple
bug 8396 (http://llvm.org/bugs/show_bug.cgi?id=8396). The problem
was that BuiltinTypeLocs were only storing one SourceLocation
(the beginning), but when there are specifiers, the type spans
multiple locations. I added an end SourceLocation to
BuiltinLocInfo and set it in TypeSpecLocFiller::VisitBuiltinTypeLoc.

There was also a bug where if a builtin type had a width specifier
before a sign specifier (as in "short unsigned int"), the SourceLocation
would remain at the sign specifier and wouldn't be updated by the width
specifier. This is also fixed in the patch.

And lastly, there was a bug with "long long." The DeclSpec class only
stores one SourceLocation for the width specifier, but "long long" spans
two locations. I added a TSWEndLoc member to DeclSpec and made
DeclSpec::SetTypeSpecWidth aware of it for proper handling of "long long."
As a result, clang now issues a correct diagnostic for programs like

long long int main() {},
long long main() {}, or
int long long main() {}.

A patch is attached. Please comment, as this is the first one I've submitted!

Ryan Gerleve
-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch_clang8396.patch
Type: application/octet-stream
Size: 5826 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20101107/55900f4d/attachment.obj>


More information about the cfe-dev mailing list