I am building a standalone tool (based on LibTooling) that needs accurate 
information about where constructors and implicit destructors are called in C++ 
code.  Building a CFG with options AddImplicitDtors and AddTemporaryDtors set 
to true seems like a good strategy for this.  However, that CFG does not 
reflect removals due to constructor elision: it is identical regardless of 
whether LangOptions::ElideConstructors is on or off.

For constructors, presumably I can use CXXConstructExpr::isElidable() and 
assume that all elidable constructor calls will indeed be elided if 
ElideConstructors is on.  But how do I recognize implicit destructor calls that 
would also be removed?  Put differently, suppose I have a particular 
CFGAutomaticObjDtor or CFGTemporaryDtor instance "dtor". Can I find the 
corresponding CXXConstructExpr "ctor" such that if "ctor" had been elided, then 
"dtor" would never have been added to the CFG in the first place?

As an alternative, is there a way for my tool to explicitly apply constructor 
elision *before* building the CFG?  That would seem simplest, if it is 
possible.  But a look through Clang's code suggests that elision happens 
on-the-fly during code generation, not as a distinct transformation.

Thanks for any suggestions,
Ben
_______________________________________________
cfe-users mailing list
cfe-users@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-users

Reply via email to