forked from OSchip/llvm-project
Add a macro-based enumeration of all of the Decl nodes (like we do
with Stmt/Expr nodes), and convert some of the more mundane switch-on-all-decl-kinds uses over to use this new file. llvm-svn: 63570
This commit is contained in:
parent
bf8c24ad89
commit
8bd3c2ebac
|
@ -443,38 +443,38 @@ protected:
|
|||
friend Decl* Decl::Create(llvm::Deserializer& D, ASTContext& C);
|
||||
};
|
||||
|
||||
/// ParmVarWithOriginalTypeDecl - Represent a parameter to a function, when
|
||||
/// OriginalParmVarDecl - Represent a parameter to a function, when
|
||||
/// the type of the parameter has been promoted. This node represents the
|
||||
/// parameter to the function with its original type.
|
||||
///
|
||||
class ParmVarWithOriginalTypeDecl : public ParmVarDecl {
|
||||
class OriginalParmVarDecl : public ParmVarDecl {
|
||||
friend class ParmVarDecl;
|
||||
protected:
|
||||
QualType OriginalType;
|
||||
private:
|
||||
ParmVarWithOriginalTypeDecl(DeclContext *DC, SourceLocation L,
|
||||
OriginalParmVarDecl(DeclContext *DC, SourceLocation L,
|
||||
IdentifierInfo *Id, QualType T,
|
||||
QualType OT, StorageClass S,
|
||||
Expr *DefArg)
|
||||
: ParmVarDecl(OriginalParmVar, DC, L, Id, T, S, DefArg), OriginalType(OT) {}
|
||||
public:
|
||||
static ParmVarWithOriginalTypeDecl *Create(ASTContext &C, DeclContext *DC,
|
||||
static OriginalParmVarDecl *Create(ASTContext &C, DeclContext *DC,
|
||||
SourceLocation L,IdentifierInfo *Id,
|
||||
QualType T, QualType OT,
|
||||
StorageClass S, Expr *DefArg);
|
||||
|
||||
// Implement isa/cast/dyncast/etc.
|
||||
static bool classof(const Decl *D) { return D->getKind() == OriginalParmVar; }
|
||||
static bool classof(const ParmVarWithOriginalTypeDecl *D) { return true; }
|
||||
static bool classof(const OriginalParmVarDecl *D) { return true; }
|
||||
|
||||
protected:
|
||||
/// EmitImpl - Serialize this ParmVarWithOriginalTypeDecl.
|
||||
/// EmitImpl - Serialize this OriginalParmVarDecl.
|
||||
/// Called by Decl::Emit.
|
||||
virtual void EmitImpl(llvm::Serializer& S) const;
|
||||
|
||||
/// CreateImpl - Deserialize a ParmVarWithOriginalTypeDecl.
|
||||
/// CreateImpl - Deserialize a OriginalParmVarDecl.
|
||||
/// Called by Decl::Create.
|
||||
static ParmVarWithOriginalTypeDecl* CreateImpl(llvm::Deserializer& D,
|
||||
static OriginalParmVarDecl* CreateImpl(llvm::Deserializer& D,
|
||||
ASTContext& C);
|
||||
|
||||
friend Decl* Decl::Create(llvm::Deserializer& D, ASTContext& C);
|
||||
|
|
|
@ -30,6 +30,7 @@ class FunctionDecl;
|
|||
class CXXRecordDecl;
|
||||
class EnumDecl;
|
||||
class ObjCMethodDecl;
|
||||
class ObjCContainerDecl;
|
||||
class ObjCInterfaceDecl;
|
||||
class ObjCCategoryDecl;
|
||||
class ObjCProtocolDecl;
|
||||
|
@ -44,67 +45,14 @@ class DeclarationName;
|
|||
///
|
||||
class Decl {
|
||||
public:
|
||||
/// \brief Lists the kind of concrete classes of Decl.
|
||||
enum Kind {
|
||||
// This lists the concrete classes of Decl in order of the inheritance
|
||||
// hierarchy. This allows us to do efficient classof tests based on the
|
||||
// enums below. The commented out names are abstract class names.
|
||||
// [DeclContext] indicates that the class also inherits from DeclContext.
|
||||
|
||||
// Decl
|
||||
TranslationUnit, // [DeclContext]
|
||||
// NamedDecl
|
||||
OverloadedFunction,
|
||||
Field,
|
||||
ObjCIvar,
|
||||
ObjCAtDefsField,
|
||||
Namespace, // [DeclContext]
|
||||
// TypeDecl
|
||||
Typedef,
|
||||
// TagDecl // [DeclContext]
|
||||
Enum,
|
||||
Record,
|
||||
CXXRecord,
|
||||
TemplateTypeParm,
|
||||
// ValueDecl
|
||||
EnumConstant,
|
||||
Function, // [DeclContext]
|
||||
CXXMethod,
|
||||
CXXConstructor,
|
||||
CXXDestructor,
|
||||
CXXConversion,
|
||||
Var,
|
||||
ImplicitParam,
|
||||
CXXClassVar,
|
||||
ParmVar,
|
||||
OriginalParmVar,
|
||||
NonTypeTemplateParm,
|
||||
ObjCMethod, // [DeclContext]
|
||||
ObjCContainer, // [DeclContext]
|
||||
ObjCCategory,
|
||||
ObjCProtocol,
|
||||
ObjCInterface,
|
||||
ObjCCategoryImpl, // [DeclContext]
|
||||
ObjCProperty,
|
||||
ObjCCompatibleAlias,
|
||||
LinkageSpec, // [DeclContext]
|
||||
ObjCPropertyImpl,
|
||||
ObjCImplementation, // [DeclContext]
|
||||
ObjCForwardProtocol,
|
||||
ObjCClass,
|
||||
FileScopeAsm,
|
||||
Block, // [DeclContext]
|
||||
|
||||
// For each non-leaf class, we now define a mapping to the first/last member
|
||||
// of the class, to allow efficient classof.
|
||||
NamedFirst = OverloadedFunction, NamedLast = ObjCCompatibleAlias,
|
||||
ObjCContainerFirst = ObjCContainer, ObjCContainerLast = ObjCInterface,
|
||||
FieldFirst = Field , FieldLast = ObjCAtDefsField,
|
||||
TypeFirst = Typedef , TypeLast = TemplateTypeParm,
|
||||
TagFirst = Enum , TagLast = CXXRecord,
|
||||
RecordFirst = Record , RecordLast = CXXRecord,
|
||||
ValueFirst = EnumConstant , ValueLast = NonTypeTemplateParm,
|
||||
FunctionFirst = Function , FunctionLast = CXXConversion,
|
||||
VarFirst = Var , VarLast = NonTypeTemplateParm
|
||||
#define DECL(Derived, Base) Derived,
|
||||
#define DECL_RANGE(CommonBase, Start, End) \
|
||||
CommonBase##First = Start, CommonBase##Last = End,
|
||||
#define LAST_DECL_RANGE(CommonBase, Start, End) \
|
||||
CommonBase##First = Start, CommonBase##Last = End
|
||||
#include "clang/AST/DeclNodes.def"
|
||||
};
|
||||
|
||||
/// IdentifierNamespace - According to C99 6.2.3, there are four namespaces,
|
||||
|
@ -822,19 +770,8 @@ public:
|
|||
|
||||
static bool classof(const Decl *D) {
|
||||
switch (D->getKind()) {
|
||||
case Decl::TranslationUnit:
|
||||
case Decl::Namespace:
|
||||
case Decl::Enum:
|
||||
case Decl::Record:
|
||||
case Decl::CXXRecord:
|
||||
case Decl::ObjCMethod:
|
||||
case Decl::ObjCInterface:
|
||||
case Decl::ObjCCategory:
|
||||
case Decl::ObjCProtocol:
|
||||
case Decl::ObjCImplementation:
|
||||
case Decl::ObjCCategoryImpl:
|
||||
case Decl::LinkageSpec:
|
||||
case Decl::Block:
|
||||
#define DECL_CONTEXT(Name) case Decl::Name:
|
||||
#include "clang/AST/DeclNodes.def"
|
||||
return true;
|
||||
default:
|
||||
if (D->getKind() >= Decl::FunctionFirst &&
|
||||
|
@ -844,20 +781,9 @@ public:
|
|||
}
|
||||
}
|
||||
static bool classof(const DeclContext *D) { return true; }
|
||||
static bool classof(const TranslationUnitDecl *D) { return true; }
|
||||
static bool classof(const NamespaceDecl *D) { return true; }
|
||||
static bool classof(const FunctionDecl *D) { return true; }
|
||||
static bool classof(const RecordDecl *D) { return true; }
|
||||
static bool classof(const CXXRecordDecl *D) { return true; }
|
||||
static bool classof(const EnumDecl *D) { return true; }
|
||||
static bool classof(const ObjCMethodDecl *D) { return true; }
|
||||
static bool classof(const ObjCInterfaceDecl *D) { return true; }
|
||||
static bool classof(const ObjCCategoryDecl *D) { return true; }
|
||||
static bool classof(const ObjCProtocolDecl *D) { return true; }
|
||||
static bool classof(const ObjCImplementationDecl *D) { return true; }
|
||||
static bool classof(const ObjCCategoryImplDecl *D) { return true; }
|
||||
static bool classof(const LinkageSpecDecl *D) { return true; }
|
||||
static bool classof(const BlockDecl *D) { return true; }
|
||||
#define DECL_CONTEXT(Name) \
|
||||
static bool classof(const Name##Decl *D) { return true; }
|
||||
#include "clang/AST/DeclNodes.def"
|
||||
|
||||
private:
|
||||
void buildLookup(DeclContext *DCtx);
|
||||
|
|
|
@ -0,0 +1,149 @@
|
|||
//===-- DeclNodes.def - Metadata about Decl AST nodes -----------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file defines the declaration nodes within the AST. The
|
||||
// description of the declaration nodes uses six macros:
|
||||
//
|
||||
// DECL(Derived, Base) describes a normal declaration type Derived
|
||||
// and specifies its base class. Note that Derived should not have
|
||||
// the Decl suffix on it, while Base should.
|
||||
//
|
||||
// LAST_DECL(Derived, Base) is like DECL, but is used for the last
|
||||
// declaration in the list.
|
||||
//
|
||||
// ABSTRACT_DECL(Derived, Base) describes an abstract class that is
|
||||
// used to specify a classification of declarations. For example,
|
||||
// TagDecl is an abstract class used to describe the various kinds of
|
||||
// "tag" declarations (unions, structs, classes, enums).
|
||||
//
|
||||
// DECL_CONTEXT(Decl) specifies that Decl is a kind of declaration
|
||||
// that is also a DeclContext.
|
||||
//
|
||||
// LAST_DECL_CONTEXT(Decl) is like DECL_CONTEXT, but is used for the
|
||||
// last declaration context.
|
||||
//
|
||||
// DECL_RANGE(CommonBase, Start, End) specifies a range of
|
||||
// declaration values that have a common (potentially indirect) base
|
||||
// class.
|
||||
//
|
||||
// LAST_DECL_RANGE(CommonBase, Start, End) is like DECL_RANGE, but is
|
||||
// used for the last declaration range.
|
||||
//
|
||||
// Note that, due to the use of ranges, the order of the these
|
||||
// declarations is significant. A declaration should be listed under
|
||||
// its base class.
|
||||
// ===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef DECL
|
||||
# define DECL(Derived, Base)
|
||||
#endif
|
||||
|
||||
#ifndef LAST_DECL
|
||||
# define LAST_DECL(Derived, Base) DECL(Derived, Base)
|
||||
#endif
|
||||
|
||||
#ifndef ABSTRACT_DECL
|
||||
# define ABSTRACT_DECL(Derived, Base)
|
||||
#endif
|
||||
|
||||
#ifndef DECL_CONTEXT
|
||||
# define DECL_CONTEXT(Decl)
|
||||
#endif
|
||||
|
||||
#ifndef LAST_DECL_CONTEXT
|
||||
# define LAST_DECL_CONTEXT(Decl) DECL_CONTEXT(Decl)
|
||||
#endif
|
||||
|
||||
#ifndef DECL_RANGE
|
||||
# define DECL_RANGE(CommonBase, Start, End)
|
||||
#endif
|
||||
|
||||
#ifndef LAST_DECL_RANGE
|
||||
# define LAST_DECL_RANGE(CommonBase, Start, End) \
|
||||
DECL_RANGE(CommonBase, Start, End)
|
||||
#endif
|
||||
|
||||
DECL(TranslationUnit, Decl)
|
||||
ABSTRACT_DECL(Named, Decl)
|
||||
DECL(OverloadedFunction, NamedDecl)
|
||||
DECL(Field, NameDecl)
|
||||
DECL(ObjCIvar, FieldDecl)
|
||||
DECL(ObjCAtDefsField, FieldDecl)
|
||||
DECL(Namespace, NamedDecl)
|
||||
ABSTRACT_DECL(Type, NamedDecl)
|
||||
DECL(Typedef, TypeDecl)
|
||||
ABSTRACT_DECL(Tag, TypeDecl)
|
||||
DECL(Enum, TagDecl)
|
||||
DECL(Record, TagDecl)
|
||||
DECL(CXXRecord, RecordDecl)
|
||||
DECL(TemplateTypeParm, TypeDecl)
|
||||
ABSTRACT_DECL(Value, NamedDecl)
|
||||
DECL(EnumConstant, ValueDecl)
|
||||
DECL(Function, ValueDecl)
|
||||
DECL(CXXMethod, FunctionDecl)
|
||||
DECL(CXXConstructor, CXXMethodDecl)
|
||||
DECL(CXXDestructor, CXXMethodDecl)
|
||||
DECL(CXXConversion, CXXMethodDecl)
|
||||
DECL(Var, ValueDecl)
|
||||
DECL(ImplicitParam, VarDecl)
|
||||
DECL(CXXClassVar, VarDecl)
|
||||
DECL(ParmVar, VarDecl)
|
||||
DECL(OriginalParmVar, ParmVarDecl)
|
||||
DECL(NonTypeTemplateParm, VarDecl)
|
||||
DECL(ObjCMethod, NamedDecl)
|
||||
DECL(ObjCContainer, NamedDecl)
|
||||
DECL(ObjCCategory, ObjCContainerDecl)
|
||||
DECL(ObjCProtocol, ObjCContainerDecl)
|
||||
DECL(ObjCInterface, ObjCContainerDecl)
|
||||
DECL(ObjCCategoryImpl, NamedDecl)
|
||||
DECL(ObjCProperty, NamedDecl)
|
||||
DECL(ObjCCompatibleAlias, NamedDecl)
|
||||
DECL(LinkageSpec, Decl)
|
||||
DECL(ObjCPropertyImpl, Decl)
|
||||
DECL(ObjCImplementation, Decl)
|
||||
DECL(ObjCForwardProtocol, Decl)
|
||||
DECL(ObjCClass, Decl)
|
||||
DECL(FileScopeAsm, Decl)
|
||||
LAST_DECL(Block, Decl)
|
||||
|
||||
// Declaration contexts
|
||||
DECL_CONTEXT(TranslationUnit)
|
||||
DECL_CONTEXT(Namespace)
|
||||
DECL_CONTEXT(Enum)
|
||||
DECL_CONTEXT(Record)
|
||||
DECL_CONTEXT(CXXRecord)
|
||||
DECL_CONTEXT(Function)
|
||||
DECL_CONTEXT(ObjCMethod)
|
||||
DECL_CONTEXT(ObjCContainer)
|
||||
DECL_CONTEXT(ObjCInterface)
|
||||
DECL_CONTEXT(ObjCProtocol)
|
||||
DECL_CONTEXT(ObjCCategory)
|
||||
DECL_CONTEXT(ObjCCategoryImpl)
|
||||
DECL_CONTEXT(LinkageSpec)
|
||||
DECL_CONTEXT(ObjCImplementation)
|
||||
LAST_DECL_CONTEXT(Block)
|
||||
|
||||
// Declaration ranges
|
||||
DECL_RANGE(Named, OverloadedFunction, ObjCCompatibleAlias)
|
||||
DECL_RANGE(ObjCContainer, ObjCContainer, ObjCInterface)
|
||||
DECL_RANGE(Field, Field, ObjCAtDefsField)
|
||||
DECL_RANGE(Type, Typedef, TemplateTypeParm)
|
||||
DECL_RANGE(Tag, Enum, CXXRecord)
|
||||
DECL_RANGE(Record, Record, CXXRecord)
|
||||
DECL_RANGE(Value, EnumConstant, NonTypeTemplateParm)
|
||||
DECL_RANGE(Function, Function, CXXConversion)
|
||||
LAST_DECL_RANGE(Var, Var, NonTypeTemplateParm)
|
||||
|
||||
#undef LAST_DECL_RANGE
|
||||
#undef DECL_RANGE
|
||||
#undef LAST_DECL_CONTEXT
|
||||
#undef DECL_CONTEXT
|
||||
#undef ABSTRACT_DECL
|
||||
#undef LAST_DECL
|
||||
#undef DECL
|
|
@ -58,7 +58,7 @@ public:
|
|||
DISPATCH_CASE(Function,FunctionDecl)
|
||||
DISPATCH_CASE(Var,VarDecl)
|
||||
DISPATCH_CASE(ParmVar,ParmVarDecl) // FIXME: (same)
|
||||
DISPATCH_CASE(OriginalParmVar,ParmVarWithOriginalTypeDecl) // FIXME: (same)
|
||||
DISPATCH_CASE(OriginalParmVar,OriginalParmVarDecl) // FIXME: (same)
|
||||
DISPATCH_CASE(ImplicitParam,ImplicitParamDecl)
|
||||
DISPATCH_CASE(EnumConstant,EnumConstantDecl)
|
||||
DISPATCH_CASE(Typedef,TypedefDecl)
|
||||
|
@ -71,7 +71,7 @@ public:
|
|||
|
||||
DEFAULT_DISPATCH(VarDecl)
|
||||
DEFAULT_DISPATCH(FunctionDecl)
|
||||
DEFAULT_DISPATCH_VARDECL(ParmVarWithOriginalTypeDecl)
|
||||
DEFAULT_DISPATCH_VARDECL(OriginalParmVarDecl)
|
||||
DEFAULT_DISPATCH_VARDECL(ParmVarDecl)
|
||||
DEFAULT_DISPATCH(ImplicitParamDecl)
|
||||
DEFAULT_DISPATCH(EnumConstantDecl)
|
||||
|
|
|
@ -54,18 +54,18 @@ ParmVarDecl *ParmVarDecl::Create(ASTContext &C, DeclContext *DC,
|
|||
}
|
||||
|
||||
QualType ParmVarDecl::getOriginalType() const {
|
||||
if (const ParmVarWithOriginalTypeDecl *PVD =
|
||||
dyn_cast<ParmVarWithOriginalTypeDecl>(this))
|
||||
if (const OriginalParmVarDecl *PVD =
|
||||
dyn_cast<OriginalParmVarDecl>(this))
|
||||
return PVD->OriginalType;
|
||||
return getType();
|
||||
}
|
||||
|
||||
ParmVarWithOriginalTypeDecl *ParmVarWithOriginalTypeDecl::Create(
|
||||
OriginalParmVarDecl *OriginalParmVarDecl::Create(
|
||||
ASTContext &C, DeclContext *DC,
|
||||
SourceLocation L, IdentifierInfo *Id,
|
||||
QualType T, QualType OT, StorageClass S,
|
||||
Expr *DefArg) {
|
||||
return new (C) ParmVarWithOriginalTypeDecl(DC, L, Id, T, OT, S, DefArg);
|
||||
return new (C) OriginalParmVarDecl(DC, L, Id, T, OT, S, DefArg);
|
||||
}
|
||||
|
||||
FunctionDecl *FunctionDecl::Create(ASTContext &C, DeclContext *DC,
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "clang/AST/DeclBase.h"
|
||||
#include "clang/AST/Decl.h"
|
||||
#include "clang/AST/DeclObjC.h"
|
||||
#include "clang/AST/DeclCXX.h"
|
||||
#include "clang/AST/ASTContext.h"
|
||||
|
@ -26,35 +27,8 @@ using namespace clang;
|
|||
// Statistics
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// temporary statistics gathering
|
||||
static unsigned nFuncs = 0;
|
||||
static unsigned nVars = 0;
|
||||
static unsigned nParmVars = 0;
|
||||
static unsigned nOriginalParmVars = 0;
|
||||
static unsigned nSUC = 0;
|
||||
static unsigned nCXXSUC = 0;
|
||||
static unsigned nEnumConst = 0;
|
||||
static unsigned nEnumDecls = 0;
|
||||
static unsigned nNamespaces = 0;
|
||||
static unsigned nOverFuncs = 0;
|
||||
static unsigned nTypedef = 0;
|
||||
static unsigned nFieldDecls = 0;
|
||||
static unsigned nInterfaceDecls = 0;
|
||||
static unsigned nClassDecls = 0;
|
||||
static unsigned nMethodDecls = 0;
|
||||
static unsigned nProtocolDecls = 0;
|
||||
static unsigned nForwardProtocolDecls = 0;
|
||||
static unsigned nCategoryDecls = 0;
|
||||
static unsigned nIvarDecls = 0;
|
||||
static unsigned nAtDefsFieldDecls = 0;
|
||||
static unsigned nObjCImplementationDecls = 0;
|
||||
static unsigned nObjCCategoryImpl = 0;
|
||||
static unsigned nObjCCompatibleAlias = 0;
|
||||
static unsigned nObjCPropertyDecl = 0;
|
||||
static unsigned nObjCPropertyImplDecl = 0;
|
||||
static unsigned nLinkageSpecDecl = 0;
|
||||
static unsigned nFileScopeAsmDecl = 0;
|
||||
static unsigned nBlockDecls = 0;
|
||||
#define DECL(Derived, Base) static int n##Derived##s = 0;
|
||||
#include "clang/AST/DeclNodes.def"
|
||||
|
||||
static bool StatSwitch = false;
|
||||
|
||||
|
@ -66,58 +40,17 @@ static DeclAttrMapTy *DeclAttrs = 0;
|
|||
|
||||
const char *Decl::getDeclKindName() const {
|
||||
switch (DeclKind) {
|
||||
default: assert(0 && "Unknown decl kind!");
|
||||
case Namespace: return "Namespace";
|
||||
case OverloadedFunction: return "OverloadedFunction";
|
||||
case Typedef: return "Typedef";
|
||||
case Function: return "Function";
|
||||
case Var: return "Var";
|
||||
case ParmVar: return "ParmVar";
|
||||
case OriginalParmVar: return "OriginalParmVar";
|
||||
case EnumConstant: return "EnumConstant";
|
||||
case ObjCIvar: return "ObjCIvar";
|
||||
case ObjCInterface: return "ObjCInterface";
|
||||
case ObjCImplementation: return "ObjCImplementation";
|
||||
case ObjCClass: return "ObjCClass";
|
||||
case ObjCMethod: return "ObjCMethod";
|
||||
case ObjCProtocol: return "ObjCProtocol";
|
||||
case ObjCProperty: return "ObjCProperty";
|
||||
case ObjCPropertyImpl: return "ObjCPropertyImpl";
|
||||
case ObjCForwardProtocol: return "ObjCForwardProtocol";
|
||||
case Record: return "Record";
|
||||
case CXXRecord: return "CXXRecord";
|
||||
case Enum: return "Enum";
|
||||
case Block: return "Block";
|
||||
case Field: return "Field";
|
||||
default: assert(0 && "Declaration not in DeclNodes.def!");
|
||||
#define DECL(Derived, Base) case Derived: return #Derived;
|
||||
#include "clang/AST/DeclNodes.def"
|
||||
}
|
||||
}
|
||||
|
||||
const char *DeclContext::getDeclKindName() const {
|
||||
switch (DeclKind) {
|
||||
default: assert(0 && "Unknown decl kind!");
|
||||
case Decl::TranslationUnit: return "TranslationUnit";
|
||||
case Decl::Namespace: return "Namespace";
|
||||
case Decl::OverloadedFunction: return "OverloadedFunction";
|
||||
case Decl::Typedef: return "Typedef";
|
||||
case Decl::Function: return "Function";
|
||||
case Decl::Var: return "Var";
|
||||
case Decl::ParmVar: return "ParmVar";
|
||||
case Decl::OriginalParmVar: return "OriginalParmVar";
|
||||
case Decl::EnumConstant: return "EnumConstant";
|
||||
case Decl::ObjCIvar: return "ObjCIvar";
|
||||
case Decl::ObjCInterface: return "ObjCInterface";
|
||||
case Decl::ObjCImplementation: return "ObjCImplementation";
|
||||
case Decl::ObjCClass: return "ObjCClass";
|
||||
case Decl::ObjCMethod: return "ObjCMethod";
|
||||
case Decl::ObjCProtocol: return "ObjCProtocol";
|
||||
case Decl::ObjCProperty: return "ObjCProperty";
|
||||
case Decl::ObjCPropertyImpl: return "ObjCPropertyImpl";
|
||||
case Decl::ObjCForwardProtocol: return "ObjCForwardProtocol";
|
||||
case Decl::Record: return "Record";
|
||||
case Decl::CXXRecord: return "CXXRecord";
|
||||
case Decl::Enum: return "Enum";
|
||||
case Decl::Block: return "Block";
|
||||
case Decl::Field: return "Field";
|
||||
default: assert(0 && "Declaration context not in DeclNodes.def!");
|
||||
#define DECL_CONTEXT(Node) case Decl::Node: return #Node;
|
||||
#include "clang/AST/DeclNodes.def"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -129,161 +62,30 @@ bool Decl::CollectingStats(bool Enable) {
|
|||
|
||||
void Decl::PrintStats() {
|
||||
fprintf(stderr, "*** Decl Stats:\n");
|
||||
fprintf(stderr, " %d decls total.\n",
|
||||
int(nFuncs+nVars+nParmVars+nOriginalParmVars+nFieldDecls+nSUC+nCXXSUC+
|
||||
nEnumDecls+nEnumConst+nTypedef+nInterfaceDecls+nClassDecls+
|
||||
nMethodDecls+nProtocolDecls+nCategoryDecls+nIvarDecls+
|
||||
nAtDefsFieldDecls+nNamespaces+nOverFuncs));
|
||||
fprintf(stderr, " %d namespace decls, %d each (%d bytes)\n",
|
||||
nNamespaces, (int)sizeof(NamespaceDecl),
|
||||
int(nNamespaces*sizeof(NamespaceDecl)));
|
||||
fprintf(stderr, " %d overloaded function decls, %d each (%d bytes)\n",
|
||||
nOverFuncs, (int)sizeof(OverloadedFunctionDecl),
|
||||
int(nOverFuncs*sizeof(OverloadedFunctionDecl)));
|
||||
fprintf(stderr, " %d function decls, %d each (%d bytes)\n",
|
||||
nFuncs, (int)sizeof(FunctionDecl), int(nFuncs*sizeof(FunctionDecl)));
|
||||
fprintf(stderr, " %d variable decls, %d each (%d bytes)\n",
|
||||
nVars, (int)sizeof(VarDecl),
|
||||
int(nVars*sizeof(VarDecl)));
|
||||
fprintf(stderr, " %d parameter variable decls, %d each (%d bytes)\n",
|
||||
nParmVars, (int)sizeof(ParmVarDecl),
|
||||
int(nParmVars*sizeof(ParmVarDecl)));
|
||||
fprintf(stderr, " %d original parameter variable decls, %d each (%d bytes)\n",
|
||||
nOriginalParmVars, (int)sizeof(ParmVarWithOriginalTypeDecl),
|
||||
int(nOriginalParmVars*sizeof(ParmVarWithOriginalTypeDecl)));
|
||||
fprintf(stderr, " %d field decls, %d each (%d bytes)\n",
|
||||
nFieldDecls, (int)sizeof(FieldDecl),
|
||||
int(nFieldDecls*sizeof(FieldDecl)));
|
||||
fprintf(stderr, " %d @defs generated field decls, %d each (%d bytes)\n",
|
||||
nAtDefsFieldDecls, (int)sizeof(ObjCAtDefsFieldDecl),
|
||||
int(nAtDefsFieldDecls*sizeof(ObjCAtDefsFieldDecl)));
|
||||
fprintf(stderr, " %d struct/union/class decls, %d each (%d bytes)\n",
|
||||
nSUC, (int)sizeof(RecordDecl),
|
||||
int(nSUC*sizeof(RecordDecl)));
|
||||
fprintf(stderr, " %d C++ struct/union/class decls, %d each (%d bytes)\n",
|
||||
nCXXSUC, (int)sizeof(CXXRecordDecl),
|
||||
int(nCXXSUC*sizeof(CXXRecordDecl)));
|
||||
fprintf(stderr, " %d enum decls, %d each (%d bytes)\n",
|
||||
nEnumDecls, (int)sizeof(EnumDecl),
|
||||
int(nEnumDecls*sizeof(EnumDecl)));
|
||||
fprintf(stderr, " %d enum constant decls, %d each (%d bytes)\n",
|
||||
nEnumConst, (int)sizeof(EnumConstantDecl),
|
||||
int(nEnumConst*sizeof(EnumConstantDecl)));
|
||||
fprintf(stderr, " %d typedef decls, %d each (%d bytes)\n",
|
||||
nTypedef, (int)sizeof(TypedefDecl),int(nTypedef*sizeof(TypedefDecl)));
|
||||
// Objective-C decls...
|
||||
fprintf(stderr, " %d interface decls, %d each (%d bytes)\n",
|
||||
nInterfaceDecls, (int)sizeof(ObjCInterfaceDecl),
|
||||
int(nInterfaceDecls*sizeof(ObjCInterfaceDecl)));
|
||||
fprintf(stderr, " %d instance variable decls, %d each (%d bytes)\n",
|
||||
nIvarDecls, (int)sizeof(ObjCIvarDecl),
|
||||
int(nIvarDecls*sizeof(ObjCIvarDecl)));
|
||||
fprintf(stderr, " %d class decls, %d each (%d bytes)\n",
|
||||
nClassDecls, (int)sizeof(ObjCClassDecl),
|
||||
int(nClassDecls*sizeof(ObjCClassDecl)));
|
||||
fprintf(stderr, " %d method decls, %d each (%d bytes)\n",
|
||||
nMethodDecls, (int)sizeof(ObjCMethodDecl),
|
||||
int(nMethodDecls*sizeof(ObjCMethodDecl)));
|
||||
fprintf(stderr, " %d protocol decls, %d each (%d bytes)\n",
|
||||
nProtocolDecls, (int)sizeof(ObjCProtocolDecl),
|
||||
int(nProtocolDecls*sizeof(ObjCProtocolDecl)));
|
||||
fprintf(stderr, " %d forward protocol decls, %d each (%d bytes)\n",
|
||||
nForwardProtocolDecls, (int)sizeof(ObjCForwardProtocolDecl),
|
||||
int(nForwardProtocolDecls*sizeof(ObjCForwardProtocolDecl)));
|
||||
fprintf(stderr, " %d category decls, %d each (%d bytes)\n",
|
||||
nCategoryDecls, (int)sizeof(ObjCCategoryDecl),
|
||||
int(nCategoryDecls*sizeof(ObjCCategoryDecl)));
|
||||
|
||||
fprintf(stderr, " %d class implementation decls, %d each (%d bytes)\n",
|
||||
nObjCImplementationDecls, (int)sizeof(ObjCImplementationDecl),
|
||||
int(nObjCImplementationDecls*sizeof(ObjCImplementationDecl)));
|
||||
|
||||
fprintf(stderr, " %d class implementation decls, %d each (%d bytes)\n",
|
||||
nObjCCategoryImpl, (int)sizeof(ObjCCategoryImplDecl),
|
||||
int(nObjCCategoryImpl*sizeof(ObjCCategoryImplDecl)));
|
||||
|
||||
fprintf(stderr, " %d compatibility alias decls, %d each (%d bytes)\n",
|
||||
nObjCCompatibleAlias, (int)sizeof(ObjCCompatibleAliasDecl),
|
||||
int(nObjCCompatibleAlias*sizeof(ObjCCompatibleAliasDecl)));
|
||||
|
||||
fprintf(stderr, " %d property decls, %d each (%d bytes)\n",
|
||||
nObjCPropertyDecl, (int)sizeof(ObjCPropertyDecl),
|
||||
int(nObjCPropertyDecl*sizeof(ObjCPropertyDecl)));
|
||||
int totalDecls = 0;
|
||||
#define DECL(Derived, Base) totalDecls += n##Derived##s;
|
||||
#include "clang/AST/DeclNodes.def"
|
||||
fprintf(stderr, " %d decls total.\n", totalDecls);
|
||||
|
||||
int totalBytes = 0;
|
||||
#define DECL(Derived, Base) \
|
||||
if (n##Derived##s > 0) { \
|
||||
totalBytes += (int)(n##Derived##s * sizeof(Derived##Decl)); \
|
||||
fprintf(stderr, " %d " #Derived " decls, %d each (%d bytes)\n", \
|
||||
n##Derived##s, (int)sizeof(Derived##Decl), \
|
||||
(int)(n##Derived##s * sizeof(Derived##Decl))); \
|
||||
}
|
||||
#include "clang/AST/DeclNodes.def"
|
||||
|
||||
fprintf(stderr, " %d property implementation decls, %d each (%d bytes)\n",
|
||||
nObjCPropertyImplDecl, (int)sizeof(ObjCPropertyImplDecl),
|
||||
int(nObjCPropertyImplDecl*sizeof(ObjCPropertyImplDecl)));
|
||||
|
||||
fprintf(stderr, "Total bytes = %d\n",
|
||||
int(nFuncs*sizeof(FunctionDecl)+
|
||||
nVars*sizeof(VarDecl)+nParmVars*sizeof(ParmVarDecl)+
|
||||
nOriginalParmVars*sizeof(ParmVarWithOriginalTypeDecl)+
|
||||
nFieldDecls*sizeof(FieldDecl)+nSUC*sizeof(RecordDecl)+
|
||||
nCXXSUC*sizeof(CXXRecordDecl)+
|
||||
nEnumDecls*sizeof(EnumDecl)+nEnumConst*sizeof(EnumConstantDecl)+
|
||||
nTypedef*sizeof(TypedefDecl)+
|
||||
nInterfaceDecls*sizeof(ObjCInterfaceDecl)+
|
||||
nIvarDecls*sizeof(ObjCIvarDecl)+
|
||||
nClassDecls*sizeof(ObjCClassDecl)+
|
||||
nMethodDecls*sizeof(ObjCMethodDecl)+
|
||||
nProtocolDecls*sizeof(ObjCProtocolDecl)+
|
||||
nForwardProtocolDecls*sizeof(ObjCForwardProtocolDecl)+
|
||||
nCategoryDecls*sizeof(ObjCCategoryDecl)+
|
||||
nObjCImplementationDecls*sizeof(ObjCImplementationDecl)+
|
||||
nObjCCategoryImpl*sizeof(ObjCCategoryImplDecl)+
|
||||
nObjCCompatibleAlias*sizeof(ObjCCompatibleAliasDecl)+
|
||||
nObjCPropertyDecl*sizeof(ObjCPropertyDecl)+
|
||||
nObjCPropertyImplDecl*sizeof(ObjCPropertyImplDecl)+
|
||||
nLinkageSpecDecl*sizeof(LinkageSpecDecl)+
|
||||
nFileScopeAsmDecl*sizeof(FileScopeAsmDecl)+
|
||||
nNamespaces*sizeof(NamespaceDecl)+
|
||||
nOverFuncs*sizeof(OverloadedFunctionDecl)));
|
||||
|
||||
fprintf(stderr, "Total bytes = %d\n", totalBytes);
|
||||
}
|
||||
|
||||
void Decl::addDeclKind(Kind k) {
|
||||
switch (k) {
|
||||
case Namespace: nNamespaces++; break;
|
||||
case OverloadedFunction: nOverFuncs++; break;
|
||||
case Typedef: nTypedef++; break;
|
||||
case Function: nFuncs++; break;
|
||||
case Var: nVars++; break;
|
||||
case ParmVar: nParmVars++; break;
|
||||
case OriginalParmVar: nOriginalParmVars++; break;
|
||||
case EnumConstant: nEnumConst++; break;
|
||||
case Field: nFieldDecls++; break;
|
||||
case Record: nSUC++; break;
|
||||
case Enum: nEnumDecls++; break;
|
||||
case ObjCContainer: break; // is abstract...no need to account for.
|
||||
case ObjCInterface: nInterfaceDecls++; break;
|
||||
case ObjCClass: nClassDecls++; break;
|
||||
case ObjCMethod: nMethodDecls++; break;
|
||||
case ObjCProtocol: nProtocolDecls++; break;
|
||||
case ObjCForwardProtocol: nForwardProtocolDecls++; break;
|
||||
case ObjCCategory: nCategoryDecls++; break;
|
||||
case ObjCIvar: nIvarDecls++; break;
|
||||
case ObjCAtDefsField: nAtDefsFieldDecls++; break;
|
||||
case ObjCImplementation: nObjCImplementationDecls++; break;
|
||||
case ObjCCategoryImpl: nObjCCategoryImpl++; break;
|
||||
case ObjCCompatibleAlias: nObjCCompatibleAlias++; break;
|
||||
case ObjCProperty: nObjCPropertyDecl++; break;
|
||||
case ObjCPropertyImpl: nObjCPropertyImplDecl++; break;
|
||||
case LinkageSpec: nLinkageSpecDecl++; break;
|
||||
case FileScopeAsm: nFileScopeAsmDecl++; break;
|
||||
case Block: nBlockDecls++; break;
|
||||
case ImplicitParam:
|
||||
case TranslationUnit: break;
|
||||
|
||||
case CXXRecord: nCXXSUC++; break;
|
||||
// FIXME: Statistics for C++ decls.
|
||||
case TemplateTypeParm:
|
||||
case NonTypeTemplateParm:
|
||||
case CXXMethod:
|
||||
case CXXConstructor:
|
||||
case CXXDestructor:
|
||||
case CXXConversion:
|
||||
case CXXClassVar:
|
||||
break;
|
||||
default: assert(0 && "Declaration not in DeclNodes.def!");
|
||||
#define DECL(Derived, Base) case Derived: ++n##Derived##s; break;
|
||||
#include "clang/AST/DeclNodes.def"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ Decl* Decl::Create(Deserializer& D, ASTContext& C) {
|
|||
break;
|
||||
|
||||
case OriginalParmVar:
|
||||
Dcl = ParmVarWithOriginalTypeDecl::CreateImpl(D, C);
|
||||
Dcl = OriginalParmVarDecl::CreateImpl(D, C);
|
||||
break;
|
||||
|
||||
case Function:
|
||||
|
@ -361,18 +361,18 @@ ParmVarDecl* ParmVarDecl::CreateImpl(Deserializer& D, ASTContext& C) {
|
|||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// ParmVarWithOriginalTypeDecl Serialization.
|
||||
// OriginalParmVarDecl Serialization.
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
void ParmVarWithOriginalTypeDecl::EmitImpl(llvm::Serializer& S) const {
|
||||
void OriginalParmVarDecl::EmitImpl(llvm::Serializer& S) const {
|
||||
ParmVarDecl::EmitImpl(S);
|
||||
S.Emit(OriginalType);
|
||||
}
|
||||
|
||||
ParmVarWithOriginalTypeDecl* ParmVarWithOriginalTypeDecl::CreateImpl(
|
||||
OriginalParmVarDecl* OriginalParmVarDecl::CreateImpl(
|
||||
Deserializer& D, ASTContext& C) {
|
||||
ParmVarWithOriginalTypeDecl* decl = new (C)
|
||||
ParmVarWithOriginalTypeDecl(0, SourceLocation(), NULL, QualType(),
|
||||
OriginalParmVarDecl* decl = new (C)
|
||||
OriginalParmVarDecl(0, SourceLocation(), NULL, QualType(),
|
||||
QualType(), None, NULL);
|
||||
|
||||
decl->ParmVarDecl::ReadImpl(D, C);
|
||||
|
|
|
@ -1362,10 +1362,10 @@ Sema::DeclTy *Sema::ActOnMethodDeclaration(
|
|||
ArgNames[i], argType,
|
||||
VarDecl::None, 0);
|
||||
else
|
||||
Param = ParmVarWithOriginalTypeDecl::Create(Context, ObjCMethod,
|
||||
SourceLocation(/*FIXME*/),
|
||||
ArgNames[i], argType, originalArgType,
|
||||
VarDecl::None, 0);
|
||||
Param = OriginalParmVarDecl::Create(Context, ObjCMethod,
|
||||
SourceLocation(/*FIXME*/),
|
||||
ArgNames[i], argType, originalArgType,
|
||||
VarDecl::None, 0);
|
||||
|
||||
Param->setObjCDeclQualifier(
|
||||
CvtQTToAstBitMask(ArgQT[i].getObjCDeclQualifier()));
|
||||
|
|
Loading…
Reference in New Issue