RESOLVED FIXED 97754
Clean up HasTrivialConstructor/Destructor
https://bugs.webkit.org/show_bug.cgi?id=97754
Summary Clean up HasTrivialConstructor/Destructor
Mark Hahnenberg
Reported 2012-09-26 20:25:00 PDT
As noted in bug 96980, TypeTraits.h could use a little cleaning up.
Attachments
Patch (14.42 KB, patch)
2012-09-26 20:55 PDT, Mark Hahnenberg
no flags
Patch (14.36 KB, patch)
2012-09-27 09:26 PDT, Mark Hahnenberg
no flags
Patch (15.79 KB, patch)
2012-09-27 09:58 PDT, Mark Hahnenberg
no flags
Patch (1.38 KB, patch)
2012-09-27 16:51 PDT, Mark Hahnenberg
no flags
Mark Hahnenberg
Comment 1 2012-09-26 20:55:20 PDT
Mark Hahnenberg
Comment 2 2012-09-27 09:26:36 PDT
Mark Hahnenberg
Comment 3 2012-09-27 09:58:09 PDT
Darin Adler
Comment 4 2012-09-27 10:20:54 PDT
Comment on attachment 166024 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=166024&action=review > Source/WTF/ChangeLog:3 > + Cleanup HasTrivialConstructor/Destructor The verb “clean up” is two words. > Source/WTF/wtf/TypeTraits.h:244 > // VC8 (VS2005) and later have built-in compiler support for HasTrivialConstructor / HasTrivialDestructor, I don’t think it’s right to say they have built-in compiler support for HasTrivialConstructor / HasTrivialDestructor. The comment should say: // VC8 (VS2005) and later has __has_trivial_constructor and __has_trivial_destructor, but the implementation // incorrectly returns false for built-in types. Work around that by explicitly checking IsPod. Also, if we wanted to cut down on copies of these templates, we could consider merging this case with the clang case. I see no harm in including the Visual Studio workaround even in the compilers that don’t need it. > Source/WTF/wtf/TypeTraits.h:245 > + // but for some unexplained reason it doesn't work on built-in types. We add the extra IsPod condition to I don’t think the phrase “for some unexplained reason” added anything to the old comment and adds nothing to the new either. It would be nice if the comment said something more specific than “it doesn’t work on” like “it returns false for”. > Source/WTF/wtf/TypeTraits.h:255 > + // For platforms that don't support HasTrivialConstructor/HasTrivialDestructor at all, we want to at least provide > + // some semblance of support. I think the comment should be more specific. I would have written something more like this: // For compilers that don't support detection of trivial constructors and destructors in classes, use a template // that returns true for any POD type but false for all class types. This will give false negatives, which can // hurt performance, but avoids false positives, which can result in incorrect behavior.
Mark Hahnenberg
Comment 5 2012-09-27 11:30:30 PDT
Darin Adler
Comment 6 2012-09-27 16:36:42 PDT
(In reply to comment #4) > Also, if we wanted to cut down on copies of these templates, we could consider merging this case with the clang case. I see no harm in including the Visual Studio workaround even in the compilers that don’t need it. Oops, my suggestion probably broke the VC10 case. It’s supposed to use std::tr1::has_trivial_constructor, right?
Mark Hahnenberg
Comment 7 2012-09-27 16:42:09 PDT
> Oops, my suggestion probably broke the VC10 case. It’s supposed to use std::tr1::has_trivial_constructor, right? Argh, I believe so. Reopening...
Mark Hahnenberg
Comment 8 2012-09-27 16:51:03 PDT
WebKit Review Bot
Comment 9 2012-09-30 17:28:34 PDT
Comment on attachment 166095 [details] Patch Clearing flags on attachment: 166095 Committed r129999: <http://trac.webkit.org/changeset/129999>
WebKit Review Bot
Comment 10 2012-09-30 17:28:38 PDT
All reviewed patches have been landed. Closing bug.
Note You need to log in before you can comment on or make changes to this bug.