#include "clang/Basic/TemplateKinds.h"
#include "clang/Basic/TypeTraits.h"
#include "clang/Parse/AccessSpecifier.h"
+#include "clang/Parse/DeclSpec.h"
#include "clang/Parse/Ownership.h"
#include "llvm/Support/PrettyStackTrace.h"
// what types are required to be identical for the actions.
typedef ActionBase::ExprTy ExprTy;
typedef ActionBase::StmtTy StmtTy;
- typedef OpaquePtr<0> DeclPtrTy;
- typedef OpaquePtr<1> DeclGroupPtrTy;
- typedef void TypeTy; // FIXME: Change TypeTy to use OpaquePtr<N>.
- typedef OpaquePtr<2> TemplateTy;
- typedef void AttrTy;
- typedef void BaseTy;
- typedef void MemInitTy;
- typedef void CXXScopeTy;
- typedef void TemplateParamsTy;
/// Expr/Stmt/Type/BaseResult - Provide a unique type to wrap
/// ExprTy/StmtTy/TypeTy/BaseTy, providing strong typing and
#ifndef LLVM_CLANG_ATTRLIST_H
#define LLVM_CLANG_ATTRLIST_H
-#include "clang/Parse/Action.h"
+#include "clang/Parse/Ownership.h"
+#include "clang/Basic/SourceLocation.h"
#include <cassert>
namespace clang {
+ class IdentifierInfo;
+ class Action;
/// AttributeList - Represents GCC's __attribute__ declaration. There are
/// 4 forms of this construct...they are:
SourceLocation AttrLoc;
IdentifierInfo *ParmName;
SourceLocation ParmLoc;
- Action::ExprTy **Args;
+ ActionBase::ExprTy **Args;
unsigned NumArgs;
AttributeList *Next;
AttributeList(const AttributeList &); // DO NOT IMPLEMENT
public:
AttributeList(IdentifierInfo *AttrName, SourceLocation AttrLoc,
IdentifierInfo *ParmName, SourceLocation ParmLoc,
- Action::ExprTy **args, unsigned numargs, AttributeList *Next);
+ ActionBase::ExprTy **args, unsigned numargs,
+ AttributeList *Next);
~AttributeList();
enum Kind { // Please keep this list alphabetized.
unsigned getNumArgs() const { return NumArgs; }
/// getArg - Return the specified argument.
- Action::ExprTy *getArg(unsigned Arg) const {
+ ActionBase::ExprTy *getArg(unsigned Arg) const {
assert(Arg < NumArgs && "Arg access out of range!");
return Args[Arg];
}
class arg_iterator {
- Action::ExprTy** X;
+ ActionBase::ExprTy** X;
unsigned Idx;
public:
- arg_iterator(Action::ExprTy** x, unsigned idx) : X(x), Idx(idx) {}
+ arg_iterator(ActionBase::ExprTy** x, unsigned idx) : X(x), Idx(idx) {}
arg_iterator& operator++() {
++Idx;
return !operator==(I);
}
- Action::ExprTy* operator*() const {
+ ActionBase::ExprTy* operator*() const {
return X[Idx];
}
#ifndef LLVM_CLANG_PARSE_DECLSPEC_H
#define LLVM_CLANG_PARSE_DECLSPEC_H
-#include "clang/Parse/Action.h"
#include "clang/Parse/AttributeList.h"
#include "clang/Lex/Token.h"
+#include "clang/Basic/OperatorKinds.h"
#include "llvm/ADT/SmallVector.h"
namespace clang {
class LangOptions;
class Diagnostic;
class IdentifierInfo;
+ class Preprocessor;
+ class Declarator;
/// DeclSpec - This class captures information about "declaration specifiers",
/// which encompasses storage-class-specifiers, type-specifiers,
/// TypeRep - This contains action-specific information about a specific TST.
/// For example, for a typedef or struct, it might contain the declaration for
/// these.
- Action::TypeTy *TypeRep;
+ ActionBase::TypeTy *TypeRep;
// attributes.
AttributeList *AttrList;
// List of protocol qualifiers for objective-c classes. Used for
// protocol-qualified interfaces "NString<foo>" and protocol-qualified id
// "id<foo>".
- const Action::DeclPtrTy *ProtocolQualifiers;
+ const ActionBase::DeclPtrTy *ProtocolQualifiers;
unsigned NumProtocolQualifiers;
// SourceLocation info. These are null if the item wasn't specified or if
return AL;
}
- typedef const Action::DeclPtrTy *ProtocolQualifierListTy;
+ typedef const ActionBase::DeclPtrTy *ProtocolQualifierListTy;
ProtocolQualifierListTy getProtocolQualifiers() const {
return ProtocolQualifiers;
}
unsigned getNumProtocolQualifiers() const {
return NumProtocolQualifiers;
}
- void setProtocolQualifiers(const Action::DeclPtrTy *Protos, unsigned NP) {
+ void setProtocolQualifiers(const ActionBase::DeclPtrTy *Protos, unsigned NP) {
if (NP == 0) return;
- ProtocolQualifiers = new Action::DeclPtrTy[NP];
- memcpy((void*)ProtocolQualifiers, Protos, sizeof(Action::DeclPtrTy)*NP);
+ ProtocolQualifiers = new ActionBase::DeclPtrTy[NP];
+ memcpy((void*)ProtocolQualifiers, Protos, sizeof(ActionBase::DeclPtrTy)*NP);
NumProtocolQualifiers = NP;
}
SourceLocation getBeginLoc() const { return Range.getBegin(); }
SourceLocation getEndLoc() const { return Range.getEnd(); }
- Action::CXXScopeTy *getScopeRep() const { return ScopeRep; }
- void setScopeRep(Action::CXXScopeTy *S) { ScopeRep = S; }
+ ActionBase::CXXScopeTy *getScopeRep() const { return ScopeRep; }
+ void setScopeRep(ActionBase::CXXScopeTy *S) { ScopeRep = S; }
bool isEmpty() const { return !Range.isValid(); }
bool isNotEmpty() const { return !isEmpty(); }
/// This is the size of the array, or null if [] or [*] was specified.
/// Since the parser is multi-purpose, and we don't want to impose a root
/// expression class on all clients, NumElts is untyped.
- Action::ExprTy *NumElts;
+ ActionBase::ExprTy *NumElts;
void destroy() {}
};
struct ParamInfo {
IdentifierInfo *Ident;
SourceLocation IdentLoc;
- Action::DeclPtrTy Param;
+ ActionBase::DeclPtrTy Param;
/// DefaultArgTokens - When the parameter's default argument
/// cannot be parsed immediately (because it occurs within the
ParamInfo() {}
ParamInfo(IdentifierInfo *ident, SourceLocation iloc,
- Action::DeclPtrTy param,
+ ActionBase::DeclPtrTy param,
CachedTokens *DefArgTokens = 0)
: Ident(ident), IdentLoc(iloc), Param(param),
DefaultArgTokens(DefArgTokens) {}
AttributeList *AttrList;
/// AsmLabel - The asm label, if specified.
- Action::ExprTy *AsmLabel;
+ ActionBase::ExprTy *AsmLabel;
union {
// When Kind is DK_Constructor, DK_Destructor, or DK_Conversion, the
// type associated with the constructor, destructor, or conversion
// operator.
- Action::TypeTy *Type;
+ ActionBase::TypeTy *Type;
/// When Kind is DK_Operator, this is the actual overloaded
/// operator that this declarator names.
/// setConstructor - Set this declarator to be a C++ constructor
/// declarator. Also extends the range.
- void setConstructor(Action::TypeTy *Ty, SourceLocation Loc) {
+ void setConstructor(ActionBase::TypeTy *Ty, SourceLocation Loc) {
IdentifierLoc = Loc;
Kind = DK_Constructor;
Type = Ty;
/// setDestructor - Set this declarator to be a C++ destructor
/// declarator. Also extends the range to End, which should be the identifier
/// token.
- void setDestructor(Action::TypeTy *Ty, SourceLocation Loc,
- SourceLocation EndLoc)
- {
+ void setDestructor(ActionBase::TypeTy *Ty, SourceLocation Loc,
+ SourceLocation EndLoc) {
IdentifierLoc = Loc;
Kind = DK_Destructor;
Type = Ty;
/// conversion function declarator (e.g., @c operator int const *).
/// Also extends the range to EndLoc, which should be the last token of the
/// type name.
- void setConversionFunction(Action::TypeTy *Ty, SourceLocation Loc,
+ void setConversionFunction(ActionBase::TypeTy *Ty, SourceLocation Loc,
SourceLocation EndLoc) {
Identifier = 0;
IdentifierLoc = Loc;
const AttributeList *getAttributes() const { return AttrList; }
AttributeList *getAttributes() { return AttrList; }
- void setAsmLabel(Action::ExprTy *E) { AsmLabel = E; }
- Action::ExprTy *getAsmLabel() const { return AsmLabel; }
+ void setAsmLabel(ActionBase::ExprTy *E) { AsmLabel = E; }
+ ActionBase::ExprTy *getAsmLabel() const { return AsmLabel; }
- Action::TypeTy *getDeclaratorIdType() const { return Type; }
+ ActionBase::TypeTy *getDeclaratorIdType() const { return Type; }
OverloadedOperatorKind getOverloadedOperator() const { return OperatorKind; }
/// structure field declarators, which is basically just a bitfield size.
struct FieldDeclarator {
Declarator D;
- Action::ExprTy *BitfieldSize;
+ ActionBase::ExprTy *BitfieldSize;
explicit FieldDeclarator(DeclSpec &DS) : D(DS, Declarator::MemberContext) {
BitfieldSize = 0;
}
#include "clang/Parse/Action.h"
namespace clang {
-
+
/// Designator - This class is a discriminated union which holds the various
/// different sorts of designators possible. A Designation is an array of
/// these. An example of a designator are things like this:
unsigned NameLoc;
};
struct ArrayDesignatorInfo {
- Action::ExprTy *Index;
+ ActionBase::ExprTy *Index;
unsigned LBracketLoc;
mutable unsigned RBracketLoc;
};
struct ArrayRangeDesignatorInfo {
- Action::ExprTy *Start, *End;
+ ActionBase::ExprTy *Start, *End;
unsigned LBracketLoc, EllipsisLoc;
mutable unsigned RBracketLoc;
};
return SourceLocation::getFromRawEncoding(FieldInfo.NameLoc);
}
- Action::ExprTy *getArrayIndex() const {
+ ActionBase::ExprTy *getArrayIndex() const {
assert(isArrayDesignator() && "Invalid accessor");
return ArrayInfo.Index;
}
- Action::ExprTy *getArrayRangeStart() const {
+ ActionBase::ExprTy *getArrayRangeStart() const {
assert(isArrayRangeDesignator() && "Invalid accessor");
return ArrayRangeInfo.Start;
}
- Action::ExprTy *getArrayRangeEnd() const {
+ ActionBase::ExprTy *getArrayRangeEnd() const {
assert(isArrayRangeDesignator() && "Invalid accessor");
return ArrayRangeInfo.End;
}
return D;
}
- static Designator getArray(Action::ExprTy *Index, SourceLocation LBracketLoc) {
+ static Designator getArray(ActionBase::ExprTy *Index,
+ SourceLocation LBracketLoc) {
Designator D;
D.Kind = ArrayDesignator;
D.ArrayInfo.Index = Index;
return D;
}
- static Designator getArrayRange(Action::ExprTy *Start, Action::ExprTy *End,
+ static Designator getArrayRange(ActionBase::ExprTy *Start,
+ ActionBase::ExprTy *End,
SourceLocation LBracketLoc,
SourceLocation EllipsisLoc) {
Designator D;
// Types - Though these don't actually enforce strong typing, they document
// what types are required to be identical for the actions.
+ typedef OpaquePtr<0> DeclPtrTy;
+ typedef OpaquePtr<1> DeclGroupPtrTy;
+ typedef OpaquePtr<2> TemplateTy;
+ typedef void AttrTy;
+ typedef void BaseTy;
+ typedef void MemInitTy;
typedef void ExprTy;
typedef void StmtTy;
typedef void TemplateParamsTy;
+ typedef void CXXScopeTy;
+ typedef void TypeTy; // FIXME: Change TypeTy to use OpaquePtr<N>.
/// ActionResult - This structure is used while parsing/acting on
/// expressions, stmts, etc. It encapsulates both the object returned by
//===----------------------------------------------------------------------===//
#include "clang/Parse/AttributeList.h"
+#include "clang/Basic/IdentifierTable.h"
using namespace clang;
AttributeList::AttributeList(IdentifierInfo *aName, SourceLocation aLoc,
IdentifierInfo *pName, SourceLocation pLoc,
- Action::ExprTy **ExprList, unsigned numArgs,
+ ActionBase::ExprTy **ExprList, unsigned numArgs,
AttributeList *n)
: AttrName(aName), AttrLoc(aLoc), ParmName(pName), ParmLoc(pLoc),
NumArgs(numArgs), Next(n) {
if (numArgs == 0)
Args = 0;
else {
- Args = new Action::ExprTy*[numArgs];
+ Args = new ActionBase::ExprTy*[numArgs];
memcpy(Args, ExprList, numArgs*sizeof(Args[0]));
}
}
AttributeList::~AttributeList() {
if (Args) {
// FIXME: before we delete the vector, we need to make sure the Expr's
- // have been deleted. Since Action::ExprTy is "void", we are dependent
+ // have been deleted. Since ActionBase::ExprTy is "void", we are dependent
// on the actions module for actually freeing the memory. The specific
// hooks are ActOnDeclarator, ActOnTypeName, ActOnParamDeclaratorType,
// ParseField, ParseTag. Once these routines have freed the expression,