Support non-type template parameters in #pragma loop

Tyler Nowicki tnowicki at apple.com
Fri May 30 10:49:21 PDT 2014


Hi Aaron,

Thanks for the feedback.

>> @@ -2974,0 +2975,59 @@ static Expr *BuildFloatingLiteral(Sema &S, NumericLiteralParser &Literal,
>> +bool Sema::DiagnoseLoopHintValue(SourceLocation Loc, Expr *ValueExpr,
>> +                                 StringRef OptionName) {
> 
> This should take a const Expr * and a const IdentifierInfo *.

I changed the option to an identifier info. However, the source location here is the location of the value not the option. I retained it so we can make sure the carrot points to the right thing. If I missed a way to get the location from the value expr please let me know.


>> +  CXXScopeSpec SS;
>> +  ExprResult DRE = BuildDeclRefExpr(D, D->getType().getNonReferenceType(),
>> +                                    VK_LValue, TemplateLoc, &SS);
>> +
>> +  if (DRE.isInvalid()) {
>> +    Diag(Tok.getLocation(), diag::err_pragma_loop_invalid_value) << OptionName;
>> +    return ExprError();
>> +  }
>> +
>> +  DRE.get()->setValueDependent(true);
> 
>  Also, should there be acessibility checks, since the lookup can
> find members and those members may be visible, but inaccessible?

I’m not exactly sure what you mean here. Is it something like #pragma loop vectorize(Foo.bar) where bar is a private member of Foo? Can non-type template parameters be inaccessible?


>> @@ -5426,3 +5434,17 @@ TreeTransform<Derived>::TransformLabelStmt(LabelStmt *S) {
>> -template<typename Derived>
>> -StmtResult
>> -TreeTransform<Derived>::TransformAttributedStmt(AttributedStmt *S) {
>> +template <typename Derived>
>> +const Attr *TreeTransform<Derived>::TransformAttr(const Attr *A) {
>> +  return A;
>> +}
>> +
>> +template <typename Derived>
>> +StmtResult TreeTransform<Derived>::TransformAttributedStmt(AttributedStmt *S) {
> 
> I think that declaration attributes should get the same treatment.

Declaration don’t use an equivalent to attributed stmt. From what I can tell declaration attributes are transformed using a tablegen generated function instantiateTemplateAttribute(). The generated function iterates over the arguments of each attribute and calls SubstExpr that calls TransformExpr. Humm… it may be possible to use this method for transforming LoopHintAttrs. I will look into it more.

In the mean time here are my latest patches.

Thanks, 

Tyler

-------------- next part --------------
A non-text attachment was scrubbed...
Name: pragma_pragmagroup.patch
Type: application/octet-stream
Size: 1789 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140530/89ee80a0/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pragma_nontypetemplate.patch
Type: application/octet-stream
Size: 23014 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140530/89ee80a0/attachment-0001.obj>


More information about the cfe-commits mailing list