[cfe-dev] Newbie Related Dependency Questions

Friedman, Eli via cfe-dev cfe-dev at lists.llvm.org
Tue Dec 27 10:14:57 PST 2016


On 12/26/2016 7:08 PM, Andrew Gozillon via cfe-dev wrote:
>
> Hi Erik,
>
>
> Thanks very much for the quick reply and the great answer! I will try 
> elaborate on my first question a little bit to try and clear it up (I 
> apologise if it doesn't, I'm not great for explanations).
>
>
> Within SemaType.cpp some of the type attributes take in integer 
> parameters, however they can not be dependent or value dependent (for 
> example by a template'd const int) as shown by the below snippet from 
> the HandleVectorSizeAttr function which will emit an error if its tried:
>
> Expr <http://clang.llvm.org/doxygen/classclang_1_1Expr.html>*sizeExpr 
> = static_cast<Expr 
> <http://clang.llvm.org/doxygen/classclang_1_1Expr.html>*>(Attr.getArgAsExpr 
> <http://clang.llvm.org/doxygen/classclang_1_1AttributeList.html#a265d2e7800361a5124d7455fdd432424>(0));
>
> llvm::APSInt vecSize(32);
>
> if(sizeExpr->isTypeDependent 
> <http://clang.llvm.org/doxygen/classclang_1_1Expr.html#a48cd7038510f42d44e314d1b8d294824>() 
> || sizeExpr->isValueDependent 
> <http://clang.llvm.org/doxygen/classclang_1_1Expr.html#a34f1652a9072dfd3c7119d23e1a14fa5>() 
> || !sizeExpr->isIntegerConstantExpr 
> <http://clang.llvm.org/doxygen/classclang_1_1Expr.html#a664cbf5948aae551f2080170628ea5ac>(vecSize, 
> S.Context 
> <http://clang.llvm.org/doxygen/classclang_1_1Sema.html#a3ccddacb1f4f71b084296175cc9e5b0e>)) 
> { S.Diag 
> <http://clang.llvm.org/doxygen/classclang_1_1Sema.html#ad29dfd1f2677772bf6b1da186a7583c3>(Attr.getLoc 
> <http://clang.llvm.org/doxygen/classclang_1_1AttributeList.html#a764e55754a52aa43b991dbbb24fa1450>(), 
> diag::err_attribute_argument_type)<< Attr.getName 
> <http://clang.llvm.org/doxygen/classclang_1_1AttributeList.html#ad33e72a3989e9a61697da22d0211bf15>() 
> << AANT_ArgumentIntegerConstant 
> <http://clang.llvm.org/doxygen/namespaceclang.html#a702b0ec61c5bb9df98d3364a170c0dfca026f679d45ce5b7f618b89ac18d8595e><< 
> sizeExpr->getSourceRange 
> <http://clang.llvm.org/doxygen/classclang_1_1Stmt.html#a6844392ee6148b5fe821f211b95e5d1b>();Attr.setInvalid 
> <http://clang.llvm.org/doxygen/classclang_1_1AttributeList.html#ad2ce5246eed483669e582893448602d8>();
>
> return;
>
> }
>
>

vector_size in particular doesn't work just because it isn't 
implemented... attributes which affect the type system require some 
relatively complicated handling to make template instantiation work 
correctly.  ext_vector_type is an example of an attribute which takes an 
integer parameter which is allowed to be dependent; see 
Sema::BuildExtVectorType / TransformDependentSizedExtVectorType in 
TreeTransform.h / etc.

-Eli


-- 
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20161227/34917d7e/attachment.html>


More information about the cfe-dev mailing list