[LLVMdev] Using C++'11 language features in LLVM itself

David Tweed David.Tweed at arm.com
Thu Jan 10 02:55:42 PST 2013


> How crazy would it be for us to start using basic C++'11 language features (but not C++'11 library features) in LLVM:
> things like auto

| It can make code less readable because of missing types. When compiler can deduce type, it doesn't always mean that human do it easily when reading the code.

I'd argue that auto should only be used in cases where the precise type being used isn't something the human reader actually reads anyway. I've ended up with the habit of not registering the,
say, std::vector<tree<bin_expr<float,true,true,false> > >::iterator in

for(std::vector<tree<bin_expr<float,true,true,false> > >::iterator it = worklist.begin(); it != worklist.end(); ++it)

In cases like this auto increases readability by decreasing the amount of "pattern discarding" I have to do before spotting the things I'm going to pay attention to. If the actual type is something that the reader is going to think about, then IMO auto shouldn't be used as a coding style issue.

> rvalue-refs

| It is not very helpful when compiler can do return value optimization.

I thought the motivation for adding rvalue-refs in C++11 was that in practice compilers can almost never do enough analysis to do RVO on real-world code?

Regards,
Dave


-- IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium.  Thank you.





More information about the llvm-dev mailing list