[PATCH] D12922: Add support for function attribute "notail"

Akira Hatanaka via cfe-commits cfe-commits at lists.llvm.org
Sun Nov 1 23:28:09 PST 2015


ahatanak added inline comments.

================
Comment at: lib/Sema/SemaDecl.cpp:5374
@@ +5373,3 @@
+
+  // Virtual functions cannot be marked as 'notail'.
+  if (auto *Attr = ND.getAttr<NotTailCalledAttr>())
----------------
aaron.ballman wrote:
> Is there a reason this is here instead of SemaDeclAttr.cpp? It seems like the decl passed in with the attribute attached to it should already be known to be virtual or not?
I initially did the check in SemaDeclAttr.cpp but found out that methods declared override are not known to be virtual (isVirtual returns false) when ProcessDeclAttributes is called:

class Base {
  // This method is fine.
  virtual int foo1();
};

class Derived1 : public Base {
  // isVirtual() is false for the declaration of this method.
  int foo1() override;
};

This is because ProcessDeclAttributes is called before CheckFunctionDeclaration (in line 7952, which calls Sema::AddOverriddenMethods) is called in Sema::ActOnFunctionDeclarator. Unless there is another way to check if a method is virtual, I don't think we can move the check to SemaDeclAttr.cpp?


http://reviews.llvm.org/D12922





More information about the cfe-commits mailing list