kframework/c-semantics

`clang-kast` inserts implicit calls to conversion functions

Opened this issue · 1 comments

The clang-kast tools inserts calls to conversion functions. As an example, take the following program:

int rv = 0;

struct A{};
struct B : A{};

struct C {
	A a; B b;
	operator A(){rv=1; return a;}
	operator B(){rv=2; return b;}
};

int main() {
	C c;
	A ra = c; // here calls `C::operator A()`
	return rv;
}

The inserted call:

`CallExpr`(`ExprLoc`(`UnknownCabsLoc_COMMON-SYNTAX`(.KList),`MemberExpr`(#token("false","Bool"),#token("false","Bool"),`Name`(`NoNNS`(.KList),`TypeId`(`Name`(`NoNNS`(.KList),`Identifier`(#token("\"A\"","String"))))),`ExprLoc`(`CabsLoc`(...),`Name`(`NoNNS`(.KList),`Identifier`(#token("\"c\"","String")))))),`list`(kSeqToList(.K)),`krlist`(`.List`(.KList)))

We may be able to get rid of the call using [anywhere] rules in the same way we eliminate ConstructorCalls (here) - but we would need to somehow mark those calls in clang-kast. Also, maybe we could have a separate semantics that would just strip the AST we get from clang?

let's not have a separate semantics as that considerably increases build times.