augusto2112 marked an inline comment as done.
augusto2112 added inline comments.

Comment at: clang/include/clang/Basic/
+  let Subjects = SubjectList<[Function, ObjCMethod]>;
+  let Args = [StringArgument<"Name">];
+  let Documentation = [TrampolineDocs];
aaron.ballman wrote:
> This is quite fragile, for a few reasons.
> 1) It's too easy for the user to get undiagnosed typos. e.g., they want to 
> dispatch to `bar` but accidentally dispatch to `barf` or `bar()` instead.
> 2) How does this work with overloaded functions? Templated functions with 
> specializations?
> It seems to me that this should be accepting an Expr argument that's either a 
> `CallExpr`/`MemberCallExpr` or is a `DeclRefExpr` that names a function, so 
> you could do:
> ```
> void bar();
> void baz(int), baz(float);
> __attribute__((trampoline(bar))) void foo() { bar(); }
> // or
> __attribute__((trampoline(baz(12))) void foo() { baz(12); }
> ```
> That said, this is still fragile in that it's easy to write the attribute and 
> then the function body drifts out of sync with the attribute over time. Given 
> that this only impacts debug information, that sort of latent issue is likely 
> to hide in the code for a long time. Should we consider a warning if the 
> function named by the attribute is not called within the function carrying 
> the attribute?
I understand the concerns you brought up as I didn't make it clear initially 
that this isn't supposed to be used by users, but meant to be used in compiler 
generated code. Given that, do you still think this should be an `Expr`? I 
think that'd be more error prone for tools to generate the correct C++ code to 
write, when compared with the mangled name.

  rG LLVM Github Monorepo


cfe-commits mailing list

Reply via email to