Move computations out of constructors
authorMichael Kruse <llvm@meinersbur.de>
Thu, 30 Jul 2015 19:27:04 +0000 (19:27 +0000)
committerMichael Kruse <llvm@meinersbur.de>
Thu, 30 Jul 2015 19:27:04 +0000 (19:27 +0000)
commit471a5e3388b00f7a5172d3f7faa448f8a412e599
treee6c251276109146ae6690d0ba01be9f614471160
parentc0d4b00fee2768bac7dca3362360ad993e0db75b
Move computations out of constructors

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 may 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 and IslAst into regular init functions and introduces static
create-functions as replacement.

Differential revision: http://reviews.llvm.org/D11491

Reviewers: grosser, jdoerfert
llvm-svn: 243677
polly/include/polly/ScopInfo.h
polly/lib/Analysis/ScopInfo.cpp
polly/lib/CodeGen/IslAst.cpp