[cfe-dev] Extracting object layout of ALL classes

Joshua Naismith fakju666 at o2.pl
Sun Jan 13 17:01:26 PST 2013


Hi everyone,

I've been looking for a way to extract object layout of all classes defined in a preprocessed file. I've stumbled upon the parameter "-fdump-record-layouts", which appears to do exactly what I want, but it doesn't seem to process every struct/class I define. Specifically, if I run the command "clang -cc1 -fdump-record-layouts test.cpp" on the following 3 files:

---------------------
case 1):

struct s { bool b; };

case 2):

struct s { bool b; };

int main(){
	s o;
	s *op = &o;
	return 1;
}

case 3):

struct s { bool b; };

int main(){
	s *op = new s;
	return 1;
}
---------------------

then I'll get the object layout of the struct "s" only in the 3rd case. Does anyone know how to extract this info in the cases 1 & 2 as well?




More information about the cfe-dev mailing list