[cfe-commits] r119583 - in /cfe/trunk: include/clang/Basic/DiagnosticGroups.td include/clang/Basic/DiagnosticSemaKinds.td include/clang/Basic/LangOptions.h include/clang/Driver/CC1Options.td include/clang/Driver/Options.td include/clang/Sema/Sema.h lib/Driver/Tools.cpp lib/Frontend/CompilerInvocation.cpp lib/Sema/SemaDecl.cpp test/SemaCXX/warn-argument-larger-than.cpp

Argyrios Kyrtzidis kyrtzidis at apple.com
Thu Nov 18 11:16:04 PST 2010


On Nov 17, 2010, at 7:49 PM, Anders Carlsson wrote:

> 
> Nov 17, 2010 kl. 3:11 PM skrev Argyrios Kyrtzidis:
> 
>> Author: akirtzidis
>> Date: Wed Nov 17 17:11:54 2010
>> New Revision: 119583
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=119583&view=rev
>> Log:
>> Introduce option -Wargument-larger-than[=N] which warns about function definitions if they take by-value
>> or return by-value any POD that is larger than some threshold (default is 64 bytes).
> 
> Very cool!
> 
> However, I don't think "isPOD" is the right type here. It won't warn for:
> 
> struct A {
> private:
> int a[100];
> };
> 
> for example.
> 
> I think what you want to check for (on Itanium at least) is "record type with a trivial copy constructor or destructor." 
> If a record type has a non-trivial copy constructor or destructor it will always be passed by pointer.

I see your point but the standard doesn't make any guarantees about the layout of non-POD types so I'm not sure doing such a Sema check is the "right" thing.
Maybe check on the codegen side ?

-Argiris

> 
> - Anders
> 
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20101118/368c0d2b/attachment.html>


More information about the cfe-commits mailing list