Sorry that my previous email was unclear. I have tried to clarify what i meant in this email by answering your questions.

Andrew Pinski wrote:

On Tue, 2006-10-24 at 02:30 +0000, Brendon Costa wrote:
I am trying to find the corresponding constructor from the basic_string class that should be called in place of the __comp_ctor function. There seems to be no FUNCTION_DECL node for the constructor:
basic_string(::char const*, ::char const*, ::std::allocator<char> const&)

which I would expect if there is a __comp_ctor () with those parameters.

Wait you say you have a function decl but cannot find the function decl
for the constructor?  I don't understand what you are getting at here.
Do you understand how templates work because that seems like where you
are getting lost.  Templates are instantiated with different types, in
this case, with _InputIterator being "const char*"

If there is a simple class like:

class MyClass
{
   MyClass()
   {}
};

int main()
{
   MyClass c;
   return 0;
}

This will produce at least 3 FUNCTION_DECL nodes:
1) main()
2) MyClass::MyClass(MyClass* this)
3) MyClass::__comp_ctor (MyClass* this)

I call (2) a "User Constructor" for want of a better name. But note that BOTH (2) and (3) are considered "constructors" as returned by DECL_CONSTRUCTOR_P(fndecl)


I have the FUNCTION_DECL node for (3) and want to find (2) from it. Basically as i understand it, main() will call (3) using a CALL_EXPR when it constructs the instance of MyClass. This __comp_ctor (MyClass* this) function (Which does not have an implementation i can find with DECL_SAVED_TREE) should call (2)

I have noticed that all __comp_ctor () and __base_ctor () FUNCTION_DECL nodes seem to correspond to a "User Constructor" for the same class that the __comp_ctor () was found in with exactly the same parameter list as the __comp_ctor () has.

For example:
SomeClass::__comp_ctor (const SomeClass&)

will some-how call:
SomeClass::SomeClass(const SomeClass&)

and:
SomeClass::__comp_ctor (int)

will some-how call:
SomeClass::SomeClass(int)



So hopefully that helps to understand what i mean by the two FUNCTION_DECL nodes.

The problem is that with the code in the previous email, i cant seem to find the associated "User Constructor" FUNCTION_DECL node given the __comp_ctor constructor FUNCTION_DECL node. In particular:

std::basic_string::__comp_ctor (::char const*, ::char const*, 
::std::allocator<char> const&)

exists, but i cant seem to find an associated:
std::basic_string::basic_string(::char const*, ::char const*, 
::std::allocator<char> const&)

NOTE: I have left the template parameters out to make this easier to read.



My questions are:

1) Which of the basic_string constructors would be being called in this situation?


template<class _InputIterator>
basic_string(_InputIterator, _InputIterator, const _Alloc& );

Instantiated with _InputIterator being "const char*".

Ignore this question. I think i know the answer, and yes i do understand how template instanciation works. I just wanted someone to say yes or no as to wether the above constructor from std::basic_string is the one that is being used when compiling the code I provided.

In particular, is the code I provided calling a different constructor from within std::basic_string class or is it instanciating this templated cosntructor and using the instanciated constructor with "const char*" as the template parameter?

I think the answer is yes it is using an instanciation of this constructor, but I wanted clarification.

I was interested in the answer to this as i am trying to reproduce the problem with the __comp_ctor () FUNCTION_DECL in a small test case (Not using std::basic_string). I have tried but seem unable to reproduce the problem in a smaller test case currently. An answer to that question above might help me in finding what exactly is causing the problem i have encountered.


Thanks,
Brendon.

Reply via email to