[cfe-dev] Fixits for invalid main declarations
Douglas Gregor
dgregor at apple.com
Mon Aug 29 09:30:30 PDT 2011
On Aug 29, 2011, at 9:29 AM, David Blaikie wrote:
> > I can't seem to figure out how to get the
> > SourceRange of the static/inline keyword from the FunctionDecl. Is
> > this possible? Could someone point me to the right place to find those
> > SourceRanges?
>
> I don't think we maintain that information in the FunctionDecl. It's in the DeclSpec, if it's still hanging around.
>
> Thanks Doug - that at least got me looking for the right type (the DeclSpec).
>
> It seems (according to http://clang.llvm.org/doxygen/classclang_1_1Sema.html#a9b8436b6e81170462bf184c4755ba180 ) there are 3 callers of CheckFunctionDeclaration:
>
> * ActOnFunctionDeclarator()
> * clang::TemplateDeclInstantiator::VisitCXXMethodDecl()
> * clang::TemplateDeclInstantiator::VisitFunctionDecl().
>
> The first actually has access to the DeclSpec (through the Declarator parameter).
> The latter two are for member functions and templates - & I don't believe main can be templated, can it?
No, main cannot be a template.
> So should we just push the isMain/checkMain checking up into ActOnFunctionDeclarator instead? Then it wouldn't add any overhead to irrelevant contexts (methods & templates) & the checking could be more descriptive.
Works for me!
- Doug
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110829/9eaf6bb0/attachment.html>
More information about the cfe-dev
mailing list