[cfe-commits] [PATCH] llvm.annotation support

John McCall rjmccall at apple.com
Mon Sep 5 13:15:39 PDT 2011


On Aug 30, 2011, at 10:36 PM, Julien Lerouge wrote:
> Here is the second revision of this patch. It should address all the
> previous comments. Thanks for all the feedback!

This is looking a lot better, thanks.

+++ b/lib/CodeGen/CGBuiltin.cpp
@@ -456,7 +456,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
   }
 
   case Builtin::BI__builtin_isfinite: {
-    // isfinite(x) --> x == x && fabs(x) != infinity; }
+    // isfinite(x) --> x == x && fabs(x) != infinity;

This is fine, but please commit it separately.

+  case Builtin::BI__builtin_annotation: {
+    llvm::Value *AnnVal = EmitScalarExpr(E->getArg(0));
+    llvm::Value *F = CGM.getIntrinsic(llvm::Intrinsic::annotation,
+                                      AnnVal->getType());
+
+    // Get the annotation string, go through casts.
+    const Expr *AnnotationStrExpr = E->getArg(1)->IgnoreParenCasts();
+    llvm::StringRef Str = cast<StringLiteral>(AnnotationStrExpr)->getString();
+    return RValue::get(EmitAnnotationCall(F, AnnVal, Str, E->getExprLoc()));
+  }

Please have this comment say something like "Sema requires this to be a non-wide string literal, potentially casted", so that it's clear why this cast<> will always succeed.

And then you should make that true by adding the appropriate case to Sema::CheckBuiltinFunctionCall. :)

John.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20110905/f9a1a056/attachment.html>


More information about the cfe-commits mailing list