Support non-type template parameters in #pragma loop

Richard Smith richard at metafoo.co.uk
Mon May 26 09:55:38 PDT 2014


On Fri, May 23, 2014 at 2:41 PM, Tyler Nowicki <tnowicki at apple.com> wrote:

> Hi,
>
> As requested here is the patch to support non-type template parameters in
> #pragma loop. The patch uses LookupName to build a DeclRefExpr to the
> template parameter and overloads TransformAttr in the template instantiator
> to transform the value expression and replace the LoopHintAttr. It is built
> on the PragmaAttr and Pragma Spelling patch listed in the 'Add PragmaAttr
> and Pragma Spelling to Tablegen’ thread. Since it is a git patch please use
> ‘patch -p1’ to apply it.
>

This seems like fundamentally the wrong approach to me. It doesn't make
much sense to me to accept only an identifier here; at a minimum you should
accept an id-expression, and ideally you should accept any
constant-expression. And that in turn means your approach of parsing the
pragma from the lexer is unworkable -- you need to move the parsing logic
to the parser in order to be able to actually parse an id-expression /
constant-expression. See HandlePragmaMSPragma for an example of an existing
pragma that does this.

Is there some pre-existing standard / specification we're implementing
here, or is this a pragma of our own invention?

Also:

+  if (ValueName == "enable" || ValueName == "disable")
+    return ExprEmpty();

If this is a pragma we invented, can we design it such that we don't have
an ambiguity between its pseudo-keywords and its identifier lookup?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140526/8274f382/attachment.html>


More information about the cfe-commits mailing list