[LLVMdev] IRBuilder<>::CreateCall, CreateCall2, CreateCall3, ...

215 views
Skip to first unread message

Félix Cloutier

unread,
Jun 25, 2010, 9:24:21 PM6/25/10
to LLVM Developers Mailing List
Hey guys,

Whys are there like 5 variants of CreateCall in IRBuilder<> with numbers appended to them? The only difference I can see is the number of arguments. Aren't C++ function overloads be suited for this?

Félix

_______________________________________________
LLVM Developers mailing list
LLV...@cs.uiuc.edu http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

Chris Lattner

unread,
Jun 26, 2010, 12:00:50 AM6/26/10
to Félix Cloutier, LLVM Developers Mailing List

On Jun 25, 2010, at 6:24 PM, Félix Cloutier wrote:

> Hey guys,
>
> Whys are there like 5 variants of CreateCall in IRBuilder<> with numbers appended to them? The only difference I can see is the number of arguments. Aren't C++ function overloads be suited for this?

An overload could work, but this sort of API makes it more obvious which one you're trying to call and avoids overload ambiguity errors for the range case.

-Chris

Félix Cloutier

unread,
Jun 26, 2010, 12:49:08 PM6/26/10
to Chris Lattner, LLVM Developers Mailing List
The possible ambiguity between the "regular" calls and the range call is a good reason, though I don't really think suffixing function names with the number of arguments it takes can make anything more obvious. Besides, if it's forgotten, you get something like Invalid conversion from 'unsigned int' to 'llvm::Value*' initializing argument 3 of 'void llvm::CallInst::init(llvm::Value*, llvm::Value*, llvm::Value*)', which isn't very helpful. (I'm running llvm-gcc-4.2, I'm waiting for Xcode 4 to bring clang++ to my computer.)

Félix
Reply all
Reply to author
Forward
0 new messages