[clang] [clang][frontend] Support applying the annotate attribute to statements (PR #111841)

Erich Keane via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 10 07:25:52 PDT 2024


================
@@ -2125,6 +2126,19 @@ TemplateInstantiator::TransformTemplateParmRefExpr(DeclRefExpr *E,
                                          Arg, PackIndex);
 }
 
+const AnnotateAttr *
+TemplateInstantiator::TransformAnnotateAttr(const AnnotateAttr *AA) {
+  SmallVector<Expr *> Args;
+  for (Expr *Arg : AA->args()) {
+    ExprResult Res = getDerived().TransformExpr(Arg);
+    if (!Res.isUsable())
+      return AA;
----------------
erichkeane wrote:

Hmm... I see this elsewhere, and I'm not thrilled that this is our behavior (returning the uninstantiated version of the attribute).

For Annotate, I wonder if instead we should just continue and NOT add this argument (so if you have one that fails all its args, we continue, but you get an annotate with no args, if 1/2 transform, you get 1/2)? 

WDYT?

https://github.com/llvm/llvm-project/pull/111841


More information about the cfe-commits mailing list