[cfe-commits] r39627 - in /cfe/cfe/trunk/include/clang/Parse: Action.h AttributeList.h DeclSpec.h Parser.h
Steve Naroff
snaroff at apple.com
Wed Jul 11 09:46:24 PDT 2007
Author: snaroff
Date: Wed Jul 11 11:46:23 2007
New Revision: 39627
URL: http://llvm.org/viewvc/llvm-project?rev=39627&view=rev
Log:
Bug #:
Submitted by:
Reviewed by:
Add new file AttributeList.h
Added:
cfe/cfe/trunk/include/clang/Parse/AttributeList.h (with props)
Modified:
cfe/cfe/trunk/include/clang/Parse/Action.h
cfe/cfe/trunk/include/clang/Parse/DeclSpec.h
cfe/cfe/trunk/include/clang/Parse/Parser.h
Modified: cfe/cfe/trunk/include/clang/Parse/Action.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/include/clang/Parse/Action.h?rev=39627&r1=39626&r2=39627&view=diff
==============================================================================
--- cfe/cfe/trunk/include/clang/Parse/Action.h (original)
+++ cfe/cfe/trunk/include/clang/Parse/Action.h Wed Jul 11 11:46:23 2007
@@ -22,6 +22,7 @@
// Semantic.
class DeclSpec;
class Declarator;
+ class AttributeList;
// Parse.
class Scope;
class Action;
@@ -154,7 +155,7 @@
};
virtual DeclTy *ParseTag(Scope *S, unsigned TagType, TagKind TK,
SourceLocation KWLoc, IdentifierInfo *Name,
- SourceLocation NameLoc) {
+ SourceLocation NameLoc, AttributeList *Attr) {
// TagType is an instance of DeclSpec::TST, indicating what kind of tag this
// is (struct/union/enum/class).
return 0;
@@ -364,16 +365,6 @@
tok::TokenKind Kind) {
return 0;
}
- /// ParseAttribute GCC __attribute__
- virtual AttrTy *ParseAttribute(
- IdentifierInfo *AttrName, SourceLocation AttrNameLoc, AttrTy *PrevAttr,
- IdentifierInfo *ParmName = 0, SourceLocation ParmNameLoc = SourceLocation(),
- ExprTy **Args = 0, unsigned NumArgs = 0,
- SourceLocation LParenLoc = SourceLocation(),
- SourceLocation RParenLoc = SourceLocation()) {
- return 0;
- }
-
};
/// MinimalAction - Minimal actions are used by light-weight clients of the
Added: cfe/cfe/trunk/include/clang/Parse/AttributeList.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/include/clang/Parse/AttributeList.h?rev=39627&view=auto
==============================================================================
--- cfe/cfe/trunk/include/clang/Parse/AttributeList.h (added)
+++ cfe/cfe/trunk/include/clang/Parse/AttributeList.h Wed Jul 11 11:46:23 2007
@@ -0,0 +1,76 @@
+//===--- AttributeList.h ----------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file was developed by Steve Naroff and is distributed under
+// the University of Illinois Open Source License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines the AttributeList class interface
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CLANG_ATTRLIST_H
+#define LLVM_CLANG_ATTRLIST_H
+
+#include "clang/Parse/Action.h"
+#include <assert.h>
+
+namespace llvm {
+namespace clang {
+class IdentifierInfo;
+
+/// AttributeList - Represents GCC's __attribute__ declaration. There are
+/// 4 forms of this construct...they are:
+///
+/// 1: __attribute__(( const )). ParmName/Args/NumArgs will all be unused.
+/// 2: __attribute__(( mode(byte) )). ParmName used, Args/NumArgs unused.
+/// 3: __attribute__(( format(printf, 1, 2) )). ParmName/Args/NumArgs all used.
+/// 4: __attribute__(( aligned(16) )). ParmName is unused, Args/Num used.
+///
+class AttributeList {
+ IdentifierInfo *AttrName;
+ SourceLocation AttrLoc;
+ IdentifierInfo *ParmName;
+ SourceLocation ParmLoc;
+ Action::ExprTy **Args;
+ unsigned NumArgs;
+ AttributeList *Next;
+public:
+ AttributeList(IdentifierInfo *AttrName, SourceLocation AttrLoc,
+ IdentifierInfo *ParmName, SourceLocation ParmLoc,
+ Action::ExprTy **args, unsigned numargs, AttributeList *Next);
+ ~AttributeList() {
+ delete [] Args;
+ }
+
+ IdentifierInfo *getAttributeName() const { return AttrName; }
+ IdentifierInfo *getParameterName() const { return ParmName; }
+
+ AttributeList *getNext() const { return Next; }
+ void setNext(AttributeList *N) { Next = N; }
+
+ void addAttributeList(AttributeList *alist) {
+ AttributeList *next = this, *prev;
+ do {
+ prev = next;
+ next = next->getNext();
+ } while (next);
+ prev->setNext(alist);
+ }
+
+ /// getNumArgs - Return the number of actual arguments to this attribute.
+ unsigned getNumArgs() const { return NumArgs; }
+
+ /// getArg - Return the specified argument.
+ Action::ExprTy *getArg(unsigned Arg) const {
+ assert(Arg < NumArgs && "Arg access out of range!");
+ return Args[Arg];
+ }
+};
+
+} // end namespace clang
+} // end namespace llvm
+
+#endif
Propchange: cfe/cfe/trunk/include/clang/Parse/AttributeList.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cfe/cfe/trunk/include/clang/Parse/AttributeList.h
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: cfe/cfe/trunk/include/clang/Parse/DeclSpec.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/include/clang/Parse/DeclSpec.h?rev=39627&r1=39626&r2=39627&view=diff
==============================================================================
--- cfe/cfe/trunk/include/clang/Parse/DeclSpec.h (original)
+++ cfe/cfe/trunk/include/clang/Parse/DeclSpec.h Wed Jul 11 11:46:23 2007
@@ -16,6 +16,7 @@
#include "clang/Basic/Diagnostic.h"
#include "clang/Parse/Action.h"
+#include "clang/Parse/AttributeList.h"
#include "llvm/ADT/SmallVector.h"
namespace llvm {
@@ -117,7 +118,7 @@
void *TypeRep;
// attributes.
- void *AttributeList;
+ AttributeList *AttrList;
// SourceLocation info. These are null if the item wasn't specified or if
// the setting was synthesized.
@@ -219,8 +220,11 @@
bool SetFunctionSpecInline(SourceLocation Loc, const char *&PrevSpec);
/// attributes
- void SetAttributeList(void *alist) { AttributeList = alist; }
-
+ void AddAttribute(AttributeList *alist) {
+ if (AttrList)
+ alist->addAttributeList(AttrList);
+ AttrList = alist;
+ }
/// Finish - This does final analysis of the declspec, issuing diagnostics for
/// things like "_Imaginary" (lacking an FP type). After calling this method,
/// DeclSpec is guaranteed self-consistent, even if an error occurred.
@@ -419,7 +423,9 @@
/// #0 will be the most closely bound to the identifier, and
/// DeclTypeInfo.back() will be the least closely bound.
SmallVector<DeclaratorChunk, 8> DeclTypeInfo;
-
+
+ // attributes.
+ AttributeList *AttrList;
public:
Declarator(const DeclSpec &ds, TheContext C)
: DS(ds), Identifier(0), Context(C) {
@@ -505,6 +511,13 @@
return !DeclTypeInfo.empty() &&
DeclTypeInfo[0].Kind == DeclaratorChunk::Function;
}
+
+ /// attributes
+ void AddAttribute(AttributeList *alist) {
+ if (AttrList)
+ alist->addAttributeList(AttrList);
+ AttrList = alist;
+ }
};
Modified: cfe/cfe/trunk/include/clang/Parse/Parser.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/include/clang/Parse/Parser.h?rev=39627&r1=39626&r2=39627&view=diff
==============================================================================
--- cfe/cfe/trunk/include/clang/Parse/Parser.h (original)
+++ cfe/cfe/trunk/include/clang/Parse/Parser.h Wed Jul 11 11:46:23 2007
@@ -21,6 +21,7 @@
namespace clang {
class DeclSpec;
class Declarator;
+ class AttributeList;
class Scope;
/// Parser - This implements a parser for the C family of languages. After
@@ -355,7 +356,7 @@
bool isTypeSpecifierQualifier() const;
TypeTy *ParseTypeName();
- DeclTy *ParseAttributes();
+ AttributeList *ParseAttributes();
/// ParseDeclarator - Parse and verify a newly-initialized declarator.
void ParseDeclarator(Declarator &D);
More information about the cfe-commits
mailing list