Why does LLVM bitcode have duplicate symbols for constructors?

Viewed 102

Consider the following files

foo.h

class Foo
{
  Foo();
  Foo(int x);
  void bar();
}

foo.cc

# include foo.h

Foo::Foo() {}
Foo::Foo(int x) {}
void Foo::bar() {}

When compiling these files to LLVM bitcode foo.bc as follows

clang++ -c -o foo.bc -emit-llvm foo.cc

the resulting LLVM bitcode file, foo.bc contains two symbols for every constructor definition but only one symbol for the function definition. Why is this?

I have tested this on both LLVM versions 3.4 and 4.0.1, and the behaviour occurs with both versions. For reference, here is the output of

llvm-nm foo.bc

T _ZN3Foo3barEv
T _ZN3FooC1Ei
T _ZN3FooC1Ev
T _ZN3FooC2Ei
T _ZN3FooC2Ev

-- Edit --

Based on milleniumbug's comment below, here is some additional information on complete object constructors:

0 Answers
Related