Mam nasledovnu strukturu:
struct X{
bool a, b;
X(const X& x){a = x.a; b = x.b;} //kopirovaci konstrutor
};
// + main atd...
Preco clang generuje 2 konstruktori (size pri -O1, ale aj tak), po prelozeni cez:
clang -cc1 main.cpp -emit-llvm -O1
%struct.X = type { i8, i8 }
//1. konstruktor ktory vola 2.
define linkonce_odr void @_ZN1XC1ERKS_(%struct.X* nocapture %this, %struct.X* nocapture %x) unnamed_addr nounwind align 2 {
tail call void @_ZN1XC2ERKS_(%struct.X* %this, %struct.X* %x)
ret void
}
//2. konstruktor (tento inicializuje premenne)
define linkonce_odr void @_ZN1XC2ERKS_(%struct.X* nocapture %this, %struct.X* nocapture %x) unnamed_addr nounwind align 2 {
%1 = getelementptr inbounds %struct.X* %x, i64 0, i32 0
%2 = load i8* %1, align 1, !tbaa !0
%3 = and i8 %2, 1
%4 = getelementptr inbounds %struct.X* %this, i64 0, i32 0
store i8 %3, i8* %4, align 1, !tbaa !0
%5 = getelementptr inbounds %struct.X* %x, i64 0, i32 1
%6 = load i8* %5, align 1, !tbaa !0
%7 = and i8 %6, 1
%8 = getelementptr inbounds %struct.X* %this, i64 0, i32 1
store i8 %7, i8* %8, align 1, !tbaa !0
ret void
}
Dalej by ma zaujimalo podla coho su generovane nazvy ako _ZN1XC2ERKS_, _ZN1XC1Ev, ..
Vie dakto?