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



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to