refu-lang / refu

Refu language
21 stars 4 forks source link

Fix the module name in the LLVM debug output #41

Closed axic closed 7 years ago

axic commented 7 years ago

Explanation: https://github.com/refu-lang/refu/pull/40#discussion_r103035526

LefterisJP commented 7 years ago

Thank you @axic. But why make a separate PR?

axic commented 7 years ago

This was a bugfix, the other one was a feature, wasn't sure the other one would be accepted soon.

LefterisJP commented 7 years ago

I see.

But perhaps I did not make myself clear when explaining. As long as you never wanted to use mod_name later, which the code did not want to do before it was fine. Not really a bug as mod_name was just a temporary variable meant to only be passed into LLVM and then never be used again.

The moment you needed to use it again the RFS scope needed to move further which is what this commit achieved.

axic commented 7 years ago

I did had function_end in every DEBUG output though, so that was a bug in my opinion.

LefterisJP commented 7 years ago

oh you did? In that case it would be a bug yes but it would also be rather strange and may signify another problem. Unless LLVMModuleCreateWithNameInContext()does not make a deep copy.

llvm-c is rather under-documented so I can't say for sure but I had gathered from my research that they always make a deep copy of the c strings passed to them.

LefterisJP commented 7 years ago

@axic Argghhh! No I see it now. It was a bug yes! mod_name was also used in bllvm_mod_debug() just above your addition.

axic commented 7 years ago

mod_name was also used in bllvm_mod_debug() just above your addition.

Yep, hence my reason for this PR :)