r175649 - Process and handle attributes on conditions and for loop variables. Process and

Richard Smith richard at metafoo.co.uk
Wed Feb 20 16:27:38 PST 2013


On Wed, Feb 20, 2013 at 4:16 PM, Michael Han <fragmentshaders at gmail.com>wrote:

> Hi Richard,
>
> For attribute declarations, are they appertaining to the translation unit
> in which they are declared? If true then maybe TranslationUnitDecl is a
> place to store the AST nodes for these attributes? If not what would be the
> right place to store these attributes in AST? I am interested to work on
> this as I need declare attributes at TU scope then retrieve them later from
> AST.


Attribute declarations don't really appertain to anything (except maybe the
attribute-declaration itself). I think a reasonable representation would be
to introduce an EmptyDecl, for both attribute-declarations and
empty-declarations, and apply the attributes in an attribute-declaration to
that.


>
> Michael.
>
> On Wed, Feb 20, 2013 at 11:22 AM, Richard Smith <
> richard-llvm at metafoo.co.uk> wrote:
>
>> Author: rsmith
>> Date: Wed Feb 20 13:22:51 2013
>> New Revision: 175649
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=175649&view=rev
>> Log:
>> Process and handle attributes on conditions and for loop variables.
>> Process and
>> diagnose attributes on alias declarations, using directives, and attribute
>> declarations.
>>
>> Modified:
>>     cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>>     cfe/trunk/include/clang/Parse/Parser.h
>>     cfe/trunk/include/clang/Sema/Sema.h
>>     cfe/trunk/lib/Parse/ParseDecl.cpp
>>     cfe/trunk/lib/Parse/ParseDeclCXX.cpp
>>     cfe/trunk/lib/Parse/ParseExprCXX.cpp
>>     cfe/trunk/lib/Parse/ParseStmt.cpp
>>     cfe/trunk/lib/Parse/Parser.cpp
>>     cfe/trunk/lib/Sema/SemaDeclCXX.cpp
>>     cfe/trunk/lib/Sema/SemaType.cpp
>>     cfe/trunk/test/Parser/cxx0x-attributes.cpp
>>
>>
>>
>> ==============================================================================
>> --- cfe/trunk/lib/Parse/Parser.cpp (original)
>> +++ cfe/trunk/lib/Parse/Parser.cpp Wed Feb 20 13:22:51 2013
>> @@ -566,7 +566,6 @@ bool Parser::ParseTopLevelDecl(DeclGroup
>>  ///       external-declaration: [C99 6.9], declaration: [C++ dcl.dcl]
>>  ///         function-definition
>>  ///         declaration
>> -/// [C++0x] empty-declaration
>>  /// [GNU]   asm-definition
>>  /// [GNU]   __extension__ external-declaration
>>  /// [OBJC]  objc-class-definition
>> @@ -578,8 +577,10 @@ bool Parser::ParseTopLevelDecl(DeclGroup
>>  /// [C++]   linkage-specification
>>  /// [GNU] asm-definition:
>>  ///         simple-asm-expr ';'
>> +/// [C++11] empty-declaration
>> +/// [C++11] attribute-declaration
>>  ///
>> -/// [C++0x] empty-declaration:
>> +/// [C++11] empty-declaration:
>>  ///           ';'
>>  ///
>>  /// [C++0x/GNU] 'extern' 'template' declaration
>> @@ -624,6 +625,13 @@ Parser::ParseExternalDeclaration(ParsedA
>>      HandlePragmaOpenCLExtension();
>>      return DeclGroupPtrTy();
>>    case tok::semi:
>> +    // Either a C++11 empty-declaration or attribute-declaration.
>> +    if (attrs.Range.isValid()) {
>> +      // FIXME: Add an AST representation for this.
>> +      Actions.ActOnAttributeDeclaration(attrs.getList());
>> +      return DeclGroupPtrTy();
>> +    }
>> +
>>      ConsumeExtraSemi(OutsideFunction);
>>      // TODO: Invoke action for top-level semicolon.
>>      return DeclGroupPtrTy();
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130220/9f60253a/attachment.html>


More information about the cfe-commits mailing list