[cfe-dev] Scope::TemplateParamScope?

Dai Mikurube dmikurube at chromium.org
Tue May 22 01:44:31 PDT 2012


btw, what I eventually want is to know "whether it's in template
declaration or not" in Parser::ParseCXXNewExpression().  If there's an
easier way to do it, I wonder if someone could tell me that.

Thanks.

On Tue, May 22, 2012 at 5:27 PM, Dai Mikurube <dmikurube at chromium.org>wrote:

> Hi cfe-dev,
>
> I'm hacking on Clang and have a trouble about template scope.  Should
> 'Scope::TemplateParamScope (*1)' be turned on while parsing entire template
> declarations, or not?
>
> The description "Template parameter scope starts at the 'template' keyword
> and ends when the template declaration ends." (*1) sounds like it should be
> true.  I found that the flag is, however, sometimes turned off.  I wonder
> if I could know whether it's expected behavior or not.  (If it's not good
> behavior, I'm thinking about fixing it.)
>
>
> Let's think about the following simple template function.
>
> template<typename T>
> Object* make(T a) {
>   return new Object(&a);
> }
>
> I expected 'TemplateParamScope' is on while parsing the 'new' expression
> above.  But, it's actually turned off since the Scope is overwritten in
> ParseFunctionDefinition at (*2).
>
> (*1) TemplateParamScope:
> http://clang.llvm.org/doxygen/classclang_1_1Scope.html#afa7e82b8e23f84d0d73e27953b9afab7a40ab45d2b9c9fca9a32b710f457d449a
> (*2) http://clang.llvm.org/doxygen/Parser_8cpp_source.html#l00975
>
>
> Thanks in advance.
>
> --
> Dai MIKURUBE
>    dmikurube at chromium.org
>
>


-- 
Dai MIKURUBE
   dmikurube at chromium.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120522/5d039ffc/attachment.html>


More information about the cfe-dev mailing list