[PATCH] D79121: Add nomerge function attribute to clang

Zequan Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 30 11:15:11 PDT 2020


zequanwu marked 2 inline comments as done.
zequanwu added inline comments.


================
Comment at: clang/include/clang/Basic/Attr.td:1799
+  let Spellings = [Clang<"nomerge">];
+  let Subjects = SubjectList<[Function]>;
+  let Documentation = [NoMergeDocs];
----------------
rnk wrote:
> Clang supports many function-like things that are not functions, for example, Objective C method declarations are not considered FunctionDecls in the AST. Blocks are another function-like thing. I see below there is a `FunctionLike` subject type. Lets use that here.
> 
> I would like to make it possible to apply this attribute directly to call expressions as well, but I don't see a good example of how to do that in the existing attribute. I'd like to be able to do this, for example:
> 
> ```
> void __attribute__((noreturn)) bar();
> void foo(bool cond) {
>   if (cond)
>     [[clang::nomerge]] bar();
>   else
>     [[clang::nomerge]] bar();
> }
> ```
> 
> This gives the user fine-grained control. It allows them to call some existing API, like perhaps RaiseException, of which they do not control the declaration, and mark the calls as unmergeable.
It seems like there is no exiting example of call site attributes. https://github.com/llvm/llvm-project/blob/master/clang/lib/CodeGen/CGCall.cpp#L4767. And the function `EmitCall` may not know existence of call site attributes.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79121/new/

https://reviews.llvm.org/D79121





More information about the cfe-commits mailing list