[cfe-dev] Parameters of Custom Attribute are not included in AST

LUIS MIGUEL SANCHEZ GARCIA lmsanche at inf.uc3m.es
Thu Dec 18 04:28:09 PST 2014


Hi everyone,

I included a C++11 attribute in clang, however I cannot see its integer
parameters in the AST.

Example:

*int main(){*

*int i = 0;*
*int j=1;*
*[[own::myattr(1,2,3)]]*
*int a = i + j;*
*return 0;*

*}*

AST output is:

clang++ test.cpp  -std=c++11 -Xclang -ast-dump -fsyntax-only


*TranslationUnitDecl 0x894a230 <<invalid sloc>> <invalid sloc>*
*|-TypedefDecl 0x894a770 <<invalid sloc>> <invalid sloc> implicit
__int128_t '__int128'*
*|-TypedefDecl 0x894a7d0 <<invalid sloc>> <invalid sloc> implicit
__uint128_t 'unsigned __int128'*
*|-TypedefDecl 0x894ab90 <<invalid sloc>> <invalid sloc> implicit
__builtin_va_list '__va_list_tag [1]'*
*`-FunctionDecl 0x894ac30 <hello.cpp:3:1, line:10:1> line:3:5 main 'int
(void)'*
*  `-CompoundStmt 0x898e668 <line:4:1, line:10:1>*
*    |-DeclStmt 0x894adb8 <line:5:5, col:14>*
*    | `-VarDecl 0x894ad40 <col:5, col:13> col:9 used i 'int' cinit*
*    |   `-IntegerLiteral 0x894ad98 <col:13> 'int' 0*
*    |-DeclStmt 0x894ae58 <line:6:5, col:14>*
*    | `-VarDecl 0x894ade0 <col:5, col:13> col:9 used j 'int' cinit*
*    |   `-IntegerLiteral 0x894ae38 <col:13> 'int' 1*
*    |-DeclStmt 0x898e610 <line:8:5, col:18>*
*    | `-VarDecl 0x894aee0 <col:5, col:16> col:10 a 'int':'int' cinit*
*    |   |-BinaryOperator 0x898e528 <col:14, col:16> 'int' '+'*
*    |   | |-ImplicitCastExpr 0x898e4f8 <col:14> 'int' <LValueToRValue>*
*    |   | | `-DeclRefExpr 0x898e4a8 <col:14> 'int' lvalue Var 0x894ad40
'i' 'int'*
*    |   | `-ImplicitCastExpr 0x898e510 <col:16> 'int' <LValueToRValue>*
*    |   |   `-DeclRefExpr 0x898e4d0 <col:16> 'int' lvalue Var 0x894ade0
'j' 'int'*
*    |   `-OWNMyattrAttr 0x894af40 <line:7:7, col:20>//**missing **parameters
1,2,3*
*    `-ReturnStmt 0x898e648 <line:9:5, col:12>*
*      `-IntegerLiteral 0x898e628 <col:12> 'int' 0*



I modified include/clang/Basic/Attr.td like this:


*//own::attr*
*def OWNAttr : Attr {*
*  let Spellings = [CXX11<"own", "attr">];*

*  let Args = [VariadicUnsignedArgument<"Args">];*
*  let Documentation = [Undocumented];*
*}*


Any help?


Regards,
Luis.


-- 
-- 
-- 
--------------------------------------------------
Luis Miguel Sánchez García
Computer Architecture and Technology Area.
Office 2.2.B08
Computer Science Department. UNIVERSIDAD CARLOS III DE MADRID
Universidad Carlos III de Madrid
Avda. de la Universidad, 30
28911 Leganés - Madrid - Spain
e-mail: lmsan at arcos.inf.uc3m.es
        luismiguel.sanchez at uc3m.es

Phone: (+34) 91 624 5951

Linked-In: http://es.linkedin.com/in/lmsan
Twitter: http://twitter.com/lmsanchezgarcia
--------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20141218/51b9a15a/attachment.html>


More information about the cfe-dev mailing list