Function and inheritance

Hello guys,

So, I’m stucked in a problem involving a Function and a derived class. Well, I was refactoring part of my pass code, and created two classes in this process that are interesting here: class A and class B. Class B inherits from class A; on the other hand, class A has some pure virtual methods (already implemented in class B), and a Module, that holds only one auxiliary function (a working copy of the function being processed by the pass with some adjustments).

Ok, the derived class, B, calls a method inherited from A (let’s say, initialize()), that uses the implementation in B of the virtual methods in A. So far, so good. This initialize method basically builds my module and initializes its function. Here comes the strange part: if I dump the function in the very end of initialize(), I can access without problems the basic blocks on it. But once I’d returned to the B method that called initialize(), if I dump the function (which is a protected attribute in A, btw), I get a message like that:

Assertion failed: (!empty() && “Called front() on empty list!”), function front, file /Developer/llvm/include/llvm/ADT/ilist.h, line 388.
[…]

Is there some tricky way to do this that I’m not seeing?

Thanks in advance,

Hello again,

So, after some changes, I inserted intentionally values with use in other modules, and I get the following error:

While deleting: i1 %

Use still stuck around after Def is destroyed: %c = phi i1 [ false, ]

[…]

Assertion failed: (use_empty() && “Uses remain when a value is destroyed!”), function ~Value, file /Developer/llvm/lib/VMCore/Value.cpp, line 75.

[…]

This error occurred in between the return of the initialize() method and the actual return to the derived class method. Any one of you could help me to avoid this behavior?

Best regards,

Btw, problem solved. Apparently I needed only to save a reference to the LLVMContext, that was being deleted.

Best,