[PATCH] D25001: [Module] Merge function prototype with a non-prototype function declaration

Akira Hatanaka via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 17 08:34:48 PST 2017

ahatanak added a comment.

Sorry for the delay in replying.

Comment at: lib/Serialization/ASTReaderDecl.cpp:2715
     return (FuncX->getLinkageInternal() == FuncY->getLinkageInternal()) &&
       FuncX->getASTContext().hasSameType(FuncX->getType(), FuncY->getType());
rsmith wrote:
> Instead of your change, can we change this to use `typesAreCompatible` instead of `hasSameType`?
Using typesAreCompatible instead of hasSameType fixes the crash in the test case I added.

However, if I declare the prototype in merge-non-prototype-fn.c and the non-prototype function in header2.h, the call to func1 in foo1 picks the non-prototype function. It seems to me that we should do something similar to what Sema::MergeFunctionDecl does, which is to copy the ParamDecls of the prototype to the non-prototype function, but I'm not sure how to go about it. Should we duplicate the logic in ASTReaderDecl.cpp? Or perhaps we should change the code that does the lookup for func1 to pick the prototype when we are handling modules (which seems to be what you are suggesting)?


More information about the cfe-commits mailing list