[cfe-dev] CGCalleeInfo set Decl to Null while using as dereferenced callee

Mustakimur Rahman Khandaker (Mustakim) via cfe-dev cfe-dev at lists.llvm.org
Thu Sep 13 14:26:38 PDT 2018


Hi
Recently I have faced an interesting case (spec benchmark, 471.omnetpp) while working with Clang. Following is the case

double cPar::doubleValue()
{
if (isRedirected())
return ind.par->doubleValue();

if (isInput()) read();
if (typechar=='B' || typechar=='L')
return (double)lng.val;
else if (typechar=='D')
return dbl.val;
else if (typechar=='T')
return fromstat();
else if (typechar=='X')
return evaluate();
else if (typechar=='C')
return cexpr.expr->evaluate();
else if (typechar=='F')
return func.argc==0 ? ((MathFuncNoArg)func.f)() :
func.argc==1 ? ((MathFunc1Arg) func.f)(func.p1) :
func.argc==2 ? ((MathFunc2Args)func.f)(func.p1,func.p2) :
func.argc==3 ? ((MathFunc3Args)func.f)(func.p1,func.p2,func.p3) :
((MathFunc4Args)func.f)(func.p1,func.p2,func.p3,func.p4);
else
throw new cException(this,eBADCAST,typechar,'D');
}
Where each func.f is an indirect call and declared here:

struct { MathFunc f; int argc;
double p1,p2,p3,p4; } func; // F:math function
So, clearly f is declared as MathFunc type which later dereferenced to MathFuncNoArg, MathFunc1Arg etc.

Now, in the CGCalleeInfo, compiler set the Decl for the Callee. What I have discovered is that Decl *Expr::getReferencedDeclOfCallee() returns nullptr and for that call callee set to Decl as Null from CGCallee CodeGenFunction::EmitCallee(const Expr *E). I beleive this is not an expected behavior because it is declared as MathFunc and it should be set as that.
I would like to understand why it kept like this?

Mustakimur R. Khandaker
Sent from Mailspring, the best free email app for work
E // mrk15e at my.fsu.edu (https://link.getmailspring.com/link/1536873021.local-d697679c-88c7-v1.4.2-f587b7b7@getmailspring.com/0?redirect=mailto%3Amrk15e%40my.fsu.edu&recipient=Y2ZlLWRldkBsaXN0cy5sbHZtLm9yZw%3D%3D)
P // 8509993635 (tel:8509993635)
W // http://ww2.cs.fsu.edu/~khandake/ (https://link.getmailspring.com/link/1536873021.local-d697679c-88c7-v1.4.2-f587b7b7@getmailspring.com/1?redirect=http%3A%2F%2Fww2.cs.fsu.edu%2F~khandake%2F&recipient=Y2ZlLWRldkBsaXN0cy5sbHZtLm9yZw%3D%3D)

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20180913/731697a3/attachment.html>


More information about the cfe-dev mailing list