[cfe-commits] [PATCH] Analyzer: model trivial copy constructors directly

Jordan Rose jordan_rose at apple.com
Thu Jan 24 17:35:01 PST 2013


Hi, Anna. This is the analyzer patch I was working on: modeling the evaluation of a trivial copy constructor with a bind. The idea is pretty straightforward, but I wondered if you had any opinions on the design. Does it make sense to do this as a replacement for defaultEvalCall in VisitCXXConstructExpr? Is there another place to fit it in that would make more sense?

(Part of why I'm hesitant is because this is modifying Core when it could just be a core checker in theory. That requires talking about switching to evalCall(CallEvent), though, instead of the current limited evalCall(CallExpr). In practice, I don't think checkers can properly model a user-level bind right now, and using BodyFarm wouldn't work because you can't copy structs by value in C++.)

Besides making it cheaper to process these constructors (which in C don't even have the preCall/postCall overhead), this eliminates the spurious warning for copying a not-fully-initialized POD struct, which would match our C behavior. (It's not such an uncommon thing to do.)

CGPoint p;
p.x = 0;
CGPoint p2 = p; // no-warning

This is <rdar://problem/12305288>. If we don't want to do this at all, though, I'll just not emit the warning when in a trivial copy-or-move constructor.

What do you think?
Jordan

-------------- next part --------------
A non-text attachment was scrubbed...
Name: trivial-copy-ctors.patch
Type: application/octet-stream
Size: 7862 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130124/effcb7ae/attachment.obj>


More information about the cfe-commits mailing list