7abc2a8334
CallFunc representation of a member function, we have its concrete address, and if there is derived class there is no way how to evaluate the vtable and call the correct virtual. In order to evaluate the member's vtable, we either have to calculate it (which is platform/implementation dependent) or create a trampoline function which calls the target function. Thus codegen will generate code for vtable evaluation. The trampolines are created for functions that could be possibly virtual - non-static member functions, declared as virutal. A trampoline looks like this: void unique_name(Base* This, MyClass2* a, MyClass3* b, double c, MyClass* ret) { if (ret) *ret = This->function(*a, *b, c); else This->function(*a, *b, c); } where we pass in explicitly the address that CallFunc is given (This), followed by set of arguments (possibly needing conversion) and if the target is non-void a last argument that is used to provide a storage for the return result. The given arguments and the required by *LLVM* IR may differ - in that case simple argument conversions are done. For now primary pointers and builtins, which covers pretty much entire LLVM type system. Note that the first implementation is very rough and suboptimal, however it is very good starting point (milestone): * Common code is extracted out in its separate routines (here a lot of refactoring more could be done). * cling::Value now stores besides clang::QualType, describing (soft-of inaccurately) the llvm::GenericValue, LLVM-type which is the actual description of the generic value. * cling::Value naming conventions improved; * cling::Interpreter::getLLVMType is added temporarily and soon will be removed. * TClingCallFunc now preallocates space for the this ptr and the return result. (instead of multiple array copies) * TClingCallFunc now stores not llvm::GenericValues but cling::StoredValueRefs because the type conversions need llvm::GenericValue's description (which essentially is the type). * Does better default argument evaluation: it could be even *more betterer* if we query Sema to fold for us the constant expressions instead of decompiling them to source and using cling for evaluation. * Return storage implemented. And, yes that is the longest commit message in my life... Implementation of argument conversion is revised. git-svn-id: http://root.cern.ch/svn/root/trunk@48537 27541ba8-7e3a-0410-8455-c3a389f83636