forked from OSchip/llvm-project
Bug #:
Submitted by: Reviewed by: Add new file AttributeList.h llvm-svn: 39627
This commit is contained in:
parent
b8371e1e6a
commit
29ca72ae02
|
@ -22,6 +22,7 @@ namespace clang {
|
||||||
// Semantic.
|
// Semantic.
|
||||||
class DeclSpec;
|
class DeclSpec;
|
||||||
class Declarator;
|
class Declarator;
|
||||||
|
class AttributeList;
|
||||||
// Parse.
|
// Parse.
|
||||||
class Scope;
|
class Scope;
|
||||||
class Action;
|
class Action;
|
||||||
|
@ -154,7 +155,7 @@ public:
|
||||||
};
|
};
|
||||||
virtual DeclTy *ParseTag(Scope *S, unsigned TagType, TagKind TK,
|
virtual DeclTy *ParseTag(Scope *S, unsigned TagType, TagKind TK,
|
||||||
SourceLocation KWLoc, IdentifierInfo *Name,
|
SourceLocation KWLoc, IdentifierInfo *Name,
|
||||||
SourceLocation NameLoc) {
|
SourceLocation NameLoc, AttributeList *Attr) {
|
||||||
// TagType is an instance of DeclSpec::TST, indicating what kind of tag this
|
// TagType is an instance of DeclSpec::TST, indicating what kind of tag this
|
||||||
// is (struct/union/enum/class).
|
// is (struct/union/enum/class).
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -364,16 +365,6 @@ public:
|
||||||
tok::TokenKind Kind) {
|
tok::TokenKind Kind) {
|
||||||
return 0;
|
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
|
/// MinimalAction - Minimal actions are used by light-weight clients of the
|
||||||
|
|
|
@ -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
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
#include "clang/Basic/Diagnostic.h"
|
#include "clang/Basic/Diagnostic.h"
|
||||||
#include "clang/Parse/Action.h"
|
#include "clang/Parse/Action.h"
|
||||||
|
#include "clang/Parse/AttributeList.h"
|
||||||
#include "llvm/ADT/SmallVector.h"
|
#include "llvm/ADT/SmallVector.h"
|
||||||
|
|
||||||
namespace llvm {
|
namespace llvm {
|
||||||
|
@ -117,7 +118,7 @@ private:
|
||||||
void *TypeRep;
|
void *TypeRep;
|
||||||
|
|
||||||
// attributes.
|
// attributes.
|
||||||
void *AttributeList;
|
AttributeList *AttrList;
|
||||||
|
|
||||||
// SourceLocation info. These are null if the item wasn't specified or if
|
// SourceLocation info. These are null if the item wasn't specified or if
|
||||||
// the setting was synthesized.
|
// the setting was synthesized.
|
||||||
|
@ -219,8 +220,11 @@ public:
|
||||||
bool SetFunctionSpecInline(SourceLocation Loc, const char *&PrevSpec);
|
bool SetFunctionSpecInline(SourceLocation Loc, const char *&PrevSpec);
|
||||||
|
|
||||||
/// attributes
|
/// 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
|
/// Finish - This does final analysis of the declspec, issuing diagnostics for
|
||||||
/// things like "_Imaginary" (lacking an FP type). After calling this method,
|
/// things like "_Imaginary" (lacking an FP type). After calling this method,
|
||||||
/// DeclSpec is guaranteed self-consistent, even if an error occurred.
|
/// DeclSpec is guaranteed self-consistent, even if an error occurred.
|
||||||
|
@ -420,6 +424,8 @@ private:
|
||||||
/// DeclTypeInfo.back() will be the least closely bound.
|
/// DeclTypeInfo.back() will be the least closely bound.
|
||||||
SmallVector<DeclaratorChunk, 8> DeclTypeInfo;
|
SmallVector<DeclaratorChunk, 8> DeclTypeInfo;
|
||||||
|
|
||||||
|
// attributes.
|
||||||
|
AttributeList *AttrList;
|
||||||
public:
|
public:
|
||||||
Declarator(const DeclSpec &ds, TheContext C)
|
Declarator(const DeclSpec &ds, TheContext C)
|
||||||
: DS(ds), Identifier(0), Context(C) {
|
: DS(ds), Identifier(0), Context(C) {
|
||||||
|
@ -505,6 +511,13 @@ public:
|
||||||
return !DeclTypeInfo.empty() &&
|
return !DeclTypeInfo.empty() &&
|
||||||
DeclTypeInfo[0].Kind == DeclaratorChunk::Function;
|
DeclTypeInfo[0].Kind == DeclaratorChunk::Function;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// attributes
|
||||||
|
void AddAttribute(AttributeList *alist) {
|
||||||
|
if (AttrList)
|
||||||
|
alist->addAttributeList(AttrList);
|
||||||
|
AttrList = alist;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,7 @@ namespace llvm {
|
||||||
namespace clang {
|
namespace clang {
|
||||||
class DeclSpec;
|
class DeclSpec;
|
||||||
class Declarator;
|
class Declarator;
|
||||||
|
class AttributeList;
|
||||||
class Scope;
|
class Scope;
|
||||||
|
|
||||||
/// Parser - This implements a parser for the C family of languages. After
|
/// Parser - This implements a parser for the C family of languages. After
|
||||||
|
@ -355,7 +356,7 @@ private:
|
||||||
bool isTypeSpecifierQualifier() const;
|
bool isTypeSpecifierQualifier() const;
|
||||||
|
|
||||||
TypeTy *ParseTypeName();
|
TypeTy *ParseTypeName();
|
||||||
DeclTy *ParseAttributes();
|
AttributeList *ParseAttributes();
|
||||||
|
|
||||||
/// ParseDeclarator - Parse and verify a newly-initialized declarator.
|
/// ParseDeclarator - Parse and verify a newly-initialized declarator.
|
||||||
void ParseDeclarator(Declarator &D);
|
void ParseDeclarator(Declarator &D);
|
||||||
|
|
Loading…
Reference in New Issue