LLVM 3.8 change in function argument lists?

Hi,

I am upgrading my project from 3.7 to 3.8. I find that following code
used to compile in 3.7 but doesn't in 3.8 and I can't understand why.

llvm::Function *mainFunc = ...;
auto argiter = mainFunc->arg_begin();
llvm::Value *arg1 = argiter++;
arg1->setName("obj");

But if I change the code to following it compiles:

auto argiter = mainFunc->arg_begin();
llvm::Value *arg1 = &(*argiter);
arg1->setName("obj");

As far as I can tell the first version should have worked as well. Any
pointers to why the first version is now failing to compile?

Thanks and Regards
Dibyendu

Duncan - I assume this is your ilist work?

Dibyendu: Iterators are not necessarily pointers, so you can’t always expect to convert an iterator straight to a pointer to the element type in general.

Hi,

I am upgrading my project from 3.7 to 3.8. I find that following code
used to compile in 3.7 but doesn't in 3.8 and I can't understand why.

llvm::Function *mainFunc = ...;
auto argiter = mainFunc->arg_begin();
llvm::Value *arg1 = argiter++;
arg1->setName("obj");

But if I change the code to following it compiles:

auto argiter = mainFunc->arg_begin();
llvm::Value *arg1 = &(*argiter);
arg1->setName("obj");

As far as I can tell the first version should have worked as well. Any
pointers to why the first version is now failing to compile?

From the release notes:

"ilist_iterator<T> no longer has implicit conversions to and from T*, since ilist_iterator<T> may be pointing at the sentinel (which is usually not of type T at all). To convert from an iterator I to a pointer, use &*I; to convert from a pointer P to an iterator, use P->getIterator(). Alternatively, explicit conversions via static_cast<T>(U) are still available."

This was done to fix UB in the ilist implementation, IIRC.

Jon

Ok thanks.

Regards
Dibyendu

Duncan - I assume this is your ilist work?

Yes. Looks like the rest has been answered by others!