[cfe-commits] r55299 - in /cfe/trunk/lib: AST/Expr.cpp CodeGen/CGExprConstant.cpp
Anders Carlsson
andersca at mac.com
Sun Aug 24 20:45:45 PDT 2008
24 aug 2008 kl. 20.38 skrev Daniel Dunbar:
> Nice, thanks! A few notes:
>
>
> return builtinID ==
> Builtin::BI__builtin___CFStringMakeConstantString ||
> - builtinID == Builtin::BI__builtin_classify_type;
> + builtinID == Builtin::BI__builtin_classify_type ||
> + builtinID == Builtin::BI__builtin_huge_valf;
>
> Quite a few builtins are treated as constant exprs. We should
> probably add another parameter to BUILTIN in Builtins.def to handle
> this instead of building a big disjunction here.
Sounds like a good idea!
>
>
> + llvm::Constant *VisitCallExpr(const CallExpr *E) {
> + if (const ImplicitCastExpr *IcExpr =
> + dyn_cast<const ImplicitCastExpr>(E->getCallee()))
> + if (const DeclRefExpr *DRExpr =
> + dyn_cast<const DeclRefExpr>(IcExpr->getSubExpr()))
> + if (const FunctionDecl *FDecl =
> + dyn_cast<const FunctionDecl>(DRExpr->getDecl()))
> + if (unsigned builtinID = FDecl->getIdentifier()-
> >getBuiltinID())
> + return EmitBuiltinExpr(builtinID, E);
> +
> + CGM.ErrorUnsupported(E, "constant call expression");
> + return llvm::Constant::getNullValue(ConvertType(E->getType()));
> + }
>
> This seems rather fragile and possibly broken. Two immediates issues:
> (1) The cast is being ignored, which probably means we may end up
> emitting the wrong type.
> (2) We also should handle the case when there is no ImplicitCastExpr
> of a builtin.
>
This code was more or less copied from CodeGenFunction::EmitCallExpr -
we should probably make both methods use the same code path.
Anders
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2415 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20080824/bedf5079/attachment.bin>
More information about the cfe-commits
mailing list