[PATCH] Represent empty declaration using a new Decl node EmptyDecl and let attribute declarations appertain to EmptyDecl.
Richard Smith
richard at metafoo.co.uk
Thu Feb 21 18:38:00 PST 2013
================
Comment at: include/clang/Sema/Sema.h:1451-1453
@@ -1450,3 +1450,5 @@
/// \brief Handle a C++11 attribute-declaration.
- void ActOnAttributeDeclaration(AttributeList *AttrList);
+ Decl *ActOnAttributeDeclaration(AttributeList *AttrList,
+ SourceLocation AttrListEndLoc,
+ Scope *S);
----------------
Rename this to ActOnEmptyDeclaration. Rename AttrListEndLoc to SemiLoc or similar. The 'Scope *' parameter is usually the first parameter.
================
Comment at: lib/AST/DeclPrinter.cpp:724
@@ +723,3 @@
+void DeclPrinter::VisitEmptyDecl(EmptyDecl *D) {
+ Out << ";\n";
+}
----------------
Call prettyPrintAttributes(D); before this.
================
Comment at: lib/Parse/Parser.cpp:629-636
@@ -628,8 +628,9 @@
// 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();
+ Decl *D = Actions.ActOnAttributeDeclaration(attrs.getList(),
+ attrs.Range.getEnd(),
+ getCurScope());
+ return Actions.ConvertDeclToDeclGroup(D);
}
ConsumeExtraSemi(OutsideFunction);
----------------
Call ActOnEmptyDeclaration here whether or not we have attributes. Just set SingleDecl and break; the later code will do the ConvertDeclToDeclGroup for you.
================
Comment at: lib/Sema/SemaDeclCXX.cpp:10102
@@ -10101,3 @@
- ? diag::warn_unknown_attribute_ignored
- : diag::err_attribute_declaration)
- << AttrList->getName();
----------------
Please remove this from DiagnosticSemaKinds.td too.
http://llvm-reviews.chandlerc.com/D448
More information about the cfe-commits
mailing list