[cfe-dev] Checking if function have been emitted
Piotr Padlewski via cfe-dev
cfe-dev at lists.llvm.org
Tue Jan 3 04:23:52 PST 2017
Maybe there is something I am missing, but I though vtables are being
generated at the end of translation unit.
If there is nothing clang emits after vtable (maybe except inline virtual
functions if they are reffered by vtable), then if there is a direct call
to inline function, the function has to be emitted before
vtables.
I would like to emit available_externally vtable only if all inline virtual
functions has been emitted.
It seems that I find function like virtual default destructor, that should
be emitted before vtables (because there is implicit destructor call), but
isDeclaration() return true for it.
Test case like:
struct A {
virtual void foo();
virtual ~A() {};
};
void test() {
A a; // This will force emit of A's destructor.
}
2017-01-03 3:55 GMT+01:00 Mehdi Amini <mehdi.amini at apple.com>:
>
> > On Dec 30, 2016, at 10:38 AM, Piotr Padlewski via cfe-dev <
> cfe-dev at lists.llvm.org> wrote:
> >
> > Hi,
> > I would like to check if there is inline virtual function that was not
> emitted.
> >
> > I tried to do something like this based on CodeGenModule::
> GetOrCreateLLVMFunction:
> >
> > StringRef Name = CGM.getMangledName(VFunction);
> > auto *Entry = CGM.GetGlobalValue(Name);
> >
> > // If function doesn't exist or doesn't have a definition.
> > if (!Entry || Entry->isDeclaration())
> > return true;
> >
> > But Entry->isDeclaration() returns True for functions that I would
> expect to be emited.
> > What is the proper way of checking that?
>
> isDeclaration() only returns true for a function that does not have a body
> / hasn’t been materialized yet. Do you observe that it is not the case in
> practice? Or are you trying to look if a function will be emitted by clang
> but hasn’t already?
>
> —
> Mehdi
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170103/4873bce5/attachment.html>
More information about the cfe-dev
mailing list