accessibility of codegen headers

Hi!

is it possible to move the following headers into the include directory:

CodeGenTypes.h
CodeGenModule.h
CGRecordLayout.h

I use them to extract some infos (layout of records) while compiling. Currently I have to set
an include directory into the clang/lib/CodeGen directory which of course
is a hack.

- Jochen

What are you using these for? They should be private implementation details of the IR generation module. The layout information for structs is known in the AST level.

-Chris

What are you using these for? They should be private implementation details of the IR generation module. The layout information for structs is known in the AST level.
   
In the AST level there is no information about the alignment, e.g.
struct {char a; double b}; may result in a being at index 0 and
b being at index 2 because some alignment padding is between a and b.

I need the index of a and b as they appear in the resulting IR because (in my
custom application) I need to know if a getelementptr accesses a or b.
Currently the only way for me to find this out is using CGRecordLayout.

-Jochen

This information should be available at the AST level, because offsetof and sizeof structs needs to be evaluated without codegen. Take a look at the include/clang/AST/RecordLayout.h header.

-Chris

This information should be available at the AST level, because offsetof and sizeof structs needs to be evaluated without codegen. Take a look at the include/clang/AST/RecordLayout.h header.
  
It looks that AST/RecordLayout hast info about alignment, field offsets and struct size,
but not about field index of the resulting llvm type.
For this I would need a getFieldIndexInIR(unsigned FieldNo) method.

-Jochen

Given the offset, you can compute that with TargetData's StructLayout helper, the StructLayout::getElementContainingOffset method does it.

-Chris