Instruction ctor: insertBefore

Hi,
the insertBefore parameter, present in all constructors, is declared like
this:

    Instruction *InsertBefore=0

any reason there's no "const" before "Instruction"

?

- Volodya

Vladimir,

Instructions are members of a linked list. Consequently if you insert
some Instruction, that instruction gets changed. So, its not const.

Simple enough?

Reid.

Hi Reid,

Instructions are members of a linked list. Consequently if you insert
some Instruction, that instruction gets changed. So, its not const.

Simple enough?

Yes, thank you.

I started thinking if "mutable" is right here, but that's long philosophical
issue :wink:

- Volodya

I'm not opposed to mutable and its probably reasonable in this case.
However, I'd defer to Chris' opinion for anything in VMCore. We try to
limit the number of changes/additions there because the impact can be
quite large if something goes wrong.

Reid.

I'm not opposed to mutable and its probably reasonable in this case.
However, I'd defer to Chris' opinion for anything in VMCore. We try to
limit the number of changes/additions there because the impact can be
quite large if something goes wrong.

I don't think that mutable is a good idea. The idea is that you are
modifying the code that you are inserting the instruction into. In the
C++ const sense, you are only modifying the next/prev pointers of the
surrounding instructions and autoinsertion of the instruction name into
the function symbol table.

In the logical sense (not just what is being enforced by C++'s const), the
code you are inserting into IS being modified. As such, I think that
keeping it non-const makes sense.

-Chris