[cfe-dev] Reference counting

Jochen Wilhelmy j.wilhelmy at arcor.de
Thu Jan 21 10:10:20 CST 2010


Hi!

when developing with clang/llvm I have quite a mess with
pointers, references, llvm::OwningPtr and get()

My suggestion would be (which won't get accepted due to the huge
code base) to have a llvm::Object that has a reference counter and
then a llvm::Pointer that increments/decrements the ref-count inside
the object.
Then for every class there has to be decided if it derives from Object and
always allocated with new and always passed as Pointer<>
or a struct and never allocated with new.

I use this scheme quite long now and never have problems except ring
references in complex graphs which have to be broken manually.

- Jochen



More information about the cfe-dev mailing list