It is common practice to keep constructors lightweight. The reasons include:
- The vtable during the constructor's execution is set to the static type of the object, not to the vtable of the derived class. That is, method calls behave differently in constructors and ordinary methods. This way it is possible to call unimplemented methods of abstract classes, which usually results in a segmentation fault.
- If an exception is thrown in the constructor, the destructor is not called, potentially leaking memory.
- Code in constructors cannot be called in a regular way, e.g. from non-constructor methods of derived classes.
- Because it is common practice, people (including me) do not expect the constructor to do more than initializing data and skip them when looking for bugs.
Not all of these are applicable to LLVM (e.g. exceptions are disabled).
This patch refactors out the computational work in the constructors of Scop, ScopStmt and IslAst into regular init functions and introduces static create-functions as replacement. The constructor ScopArrayInfo also has calls, but it is small and does not call methods of its own class.