[patch][pr17535] Reject alias attributes that point to undefined name (V2).

Richard Smith richard at metafoo.co.uk
Mon Oct 21 17:03:36 PDT 2013


@@ -929,9 +929,8 @@ static RValue EmitNewDeleteCall(CodeGenFunction &CGF,
   ///   to a replaceable global allocation function.
   ///
   /// We model such elidable calls with the 'builtin' attribute.
-  llvm::Function *Fn = dyn_cast<llvm::Function>(CalleeAddr);
   if (Callee->isReplaceableGlobalAllocationFunction() &&
-      Fn && Fn->hasFnAttribute(llvm::Attribute::NoBuiltin)) {
+      !Callee->hasAttr<AliasAttr>()) {

What's the purpose of this change? Was the previous code broken by
deferring the emission of aliases?


+  llvm::GlobalValue *GV = dyn_cast<llvm::GlobalValue>(Aliasee);
+  if (!GV) {
+    llvm::ConstantExpr *CE = cast<llvm::ConstantExpr>(Aliasee);
+    GV = cast<llvm::GlobalValue>(CE->getOperand(0));

Hm, what kinds of ConstantExpr can appear here? This would be more
self-documenting if you asserted that you'd got the right kind of
ConstantExpr.


On Mon, Oct 21, 2013 at 1:25 PM, Rafael EspĂ­ndola <
rafael.espindola at gmail.com> wrote:

> The attached patch causes clang to reject alias attributes that point
> to undefined names. For example, with this patch we now reject
>
> void f1(void) __attribute__((alias("g1")));
>
> Unlike the previous patch this one is implemented in CodeGen. It is
> quiet a bit simpler. The downside is that the errors only fire during
> -emit-llvm.
>
> Cheers,
> Rafael
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20131021/c725b8e1/attachment.html>


More information about the cfe-commits mailing list