[cfe-dev] Constructors vs Copy Constructors in Clang

Jim Goodnow II jim at thegoodnows.net
Fri Sep 17 02:30:35 PDT 2010


Hi,

One of the things that I'm seeing in several places is where 
VarDecl::getInit() is returning an Expr that is CXXConstructExpr when 
a class variable is declared. However, the logic that follows the 
getInit() call usually assumes that if a non-NULL value is returned, 
there is a value being assigned. In the case of a constructor, that's 
sort of true but not completely unless it is a copy constructor. So, 
a question of philosophy:

Should getInit() return NULL when the constructor is not a copy 
constructor to support the logic in most cases? This might break or 
require a rework of things that do handle getInit() correctly like 
CodeGen and require a different call to get a non-copy constructor initializer.

Or should the calls to getInit() be qualified by an additional call 
to an 'isCopyConstructor()' function where appropriate?

  - jim




More information about the cfe-dev mailing list