[PATCH] Have 'this'-returning constructors and destructors to take advantage of the new backend 'returned' attribute

Stephen Lin swlin at post.harvard.edu
Thu May 2 22:09:07 PDT 2013


> Hmm, I *thought* the return type check adequately covers that already
> actually: I have a test case to verify that non-virtual calls don't
> return 'this':
>
> +void test_destructor() {
> +  E* e1 = new E();
> +  E* e2 = gete();
> +  delete e1;
> +  delete e2;
>  }
> +
> +
> +// CHECKARM: define void @_Z15test_destructorv()
> +
> +// CHECKARM: {{%.*}} = call %class.E* @_ZN1EC1Ev(%class.E* %0)
> +
> +// CHECKARM: [[VFN:%.*]] = getelementptr inbounds void (%class.E*)** {{%v.*}}
> +// CHECKARM: [[THUNK:%.*]] = load void (%class.E*)** [[VFN]]
> +
> +// Make sure only non-virtual calls to destructors return 'this'
> +// CHECKARM: call void [[THUNK]](%class.E* {{%.*}})
>
> but upon further reflection I'm not 100% sure this logic is sufficient
> for any possible implementation of CGCXXABI with its current interface
> or if any checks/asserts need to be added (even if they don't make a
> difference currently). Let me examine it further...

Whoops! Never mind, I realized this test is incorrect since it's
calling a deleting destructor and the first check is checking the
constructor not the destructor. I will look into it and get back to
you.

Stephen



More information about the cfe-commits mailing list