[cfe-commits] r126033 - in /cfe/trunk: include/clang/AST/Decl.h include/clang/AST/DeclBase.h include/clang/AST/DeclCXX.h include/clang/AST/DeclObjC.h include/clang/AST/DeclTemplate.h lib/AST/Decl.cpp lib/AST/DeclBase.cpp lib/AST/DeclCXX.cpp lib/AST/DeclTemplate.cpp
Douglas Gregor
dgregor at apple.com
Sat Feb 19 10:51:44 PST 2011
Author: dgregor
Date: Sat Feb 19 12:51:44 2011
New Revision: 126033
URL: http://llvm.org/viewvc/llvm-project?rev=126033&view=rev
Log:
Revert all of my commits that devirtualized the Decl hierarchy, which
lead to a serious slowdown (4%) on parsing of Cocoa.h. This memory
optimization should be revisited later, when we have time to look at
the generated code.
Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/include/clang/AST/DeclBase.h
cfe/trunk/include/clang/AST/DeclCXX.h
cfe/trunk/include/clang/AST/DeclObjC.h
cfe/trunk/include/clang/AST/DeclTemplate.h
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/AST/DeclBase.cpp
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/AST/DeclTemplate.cpp
Modified: cfe/trunk/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=126033&r1=126032&r2=126033&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Sat Feb 19 12:51:44 2011
@@ -158,9 +158,14 @@
/// specializations are printed with their template arguments.
///
/// TODO: use an API that doesn't require so many temporary strings
- void getNameForDiagnostic(std::string &S,
- const PrintingPolicy &Policy,
- bool Qualified) const;
+ virtual void getNameForDiagnostic(std::string &S,
+ const PrintingPolicy &Policy,
+ bool Qualified) const {
+ if (Qualified)
+ S += getQualifiedNameAsString(Policy);
+ else
+ S += getNameAsString();
+ }
/// declarationReplaces - Determine whether this declaration, if
/// known to be well-formed within its context, will replace the
@@ -418,12 +423,12 @@
getOriginalNamespace()->OrigOrAnonNamespace.setPointer(D);
}
- NamespaceDecl *getCanonicalDecl() { return getOriginalNamespace(); }
+ virtual NamespaceDecl *getCanonicalDecl() { return getOriginalNamespace(); }
const NamespaceDecl *getCanonicalDecl() const {
return getOriginalNamespace();
}
- SourceRange getSourceRange() const {
+ virtual SourceRange getSourceRange() const {
return SourceRange(getLocation(), RBracLoc);
}
@@ -531,7 +536,7 @@
/// getInnerLocStart - Return SourceLocation representing start of source
/// range ignoring outer template declarations.
- SourceLocation getInnerLocStart() const;
+ virtual SourceLocation getInnerLocStart() const { return getLocation(); }
/// getOuterLocStart - Return SourceLocation representing start of source
/// range taking into account any outer template declarations.
@@ -662,9 +667,8 @@
}
typedef Redeclarable<VarDecl> redeclarable_base;
- VarDecl *getNextRedeclaration() { return RedeclLink.getNext(); }
- friend class Decl;
-
+ virtual VarDecl *getNextRedeclaration() { return RedeclLink.getNext(); }
+
public:
typedef redeclarable_base::redecl_iterator redecl_iterator;
redecl_iterator redecls_begin() const {
@@ -679,7 +683,8 @@
QualType T, TypeSourceInfo *TInfo, StorageClass S,
StorageClass SCAsWritten);
- SourceRange getSourceRange() const;
+ virtual SourceLocation getInnerLocStart() const;
+ virtual SourceRange getSourceRange() const;
StorageClass getStorageClass() const { return (StorageClass)SClass; }
StorageClass getStorageClassAsWritten() const {
@@ -767,7 +772,7 @@
return getKind() != Decl::ParmVar && getDeclContext()->isRecord();
}
- VarDecl *getCanonicalDecl();
+ virtual VarDecl *getCanonicalDecl();
const VarDecl *getCanonicalDecl() const {
return const_cast<VarDecl*>(this)->getCanonicalDecl();
}
@@ -806,7 +811,7 @@
/// \brief Determine whether this is or was instantiated from an out-of-line
/// definition of a static data member.
- bool isOutOfLine() const;
+ virtual bool isOutOfLine() const;
/// \brief If this is a static data member, find its out-of-line definition.
VarDecl *getOutOfLineDefinition();
@@ -1298,12 +1303,9 @@
DNLoc(NameInfo.getInfo()) {}
typedef Redeclarable<FunctionDecl> redeclarable_base;
- FunctionDecl *getNextRedeclaration() { return RedeclLink.getNext(); }
+ virtual FunctionDecl *getNextRedeclaration() { return RedeclLink.getNext(); }
- friend class Decl;
-
public:
-
typedef redeclarable_base::redecl_iterator redecl_iterator;
redecl_iterator redecls_begin() const {
return redeclarable_base::redecls_begin();
@@ -1336,7 +1338,11 @@
return DeclarationNameInfo(getDeclName(), getLocation(), DNLoc);
}
- SourceRange getSourceRange() const {
+ virtual void getNameForDiagnostic(std::string &S,
+ const PrintingPolicy &Policy,
+ bool Qualified) const;
+
+ virtual SourceRange getSourceRange() const {
return SourceRange(getOuterLocStart(), EndRangeLoc);
}
void setLocEnd(SourceLocation E) {
@@ -1350,7 +1356,7 @@
/// containing the body (if there is one).
bool hasBody(const FunctionDecl *&Definition) const;
- bool hasBody() const {
+ virtual bool hasBody() const {
const FunctionDecl* Definition;
return hasBody(Definition);
}
@@ -1364,7 +1370,7 @@
/// unnecessary AST de-serialization of the body.
Stmt *getBody(const FunctionDecl *&Definition) const;
- Stmt *getBody() const {
+ virtual Stmt *getBody() const {
const FunctionDecl* Definition;
return getBody(Definition);
}
@@ -1454,8 +1460,8 @@
void setPreviousDeclaration(FunctionDecl * PrevDecl);
- const FunctionDecl *getCanonicalDecl() const;
- FunctionDecl *getCanonicalDecl();
+ virtual const FunctionDecl *getCanonicalDecl() const;
+ virtual FunctionDecl *getCanonicalDecl();
unsigned getBuiltinID() const;
@@ -1708,7 +1714,7 @@
/// \brief Determine whether this is or was instantiated from an out-of-line
/// definition of a member function.
- bool isOutOfLine() const;
+ virtual bool isOutOfLine() const;
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
@@ -1908,10 +1914,8 @@
protected:
typedef Redeclarable<TypedefDecl> redeclarable_base;
- TypedefDecl *getNextRedeclaration() { return RedeclLink.getNext(); }
+ virtual TypedefDecl *getNextRedeclaration() { return RedeclLink.getNext(); }
- friend class Decl;
-
public:
typedef redeclarable_base::redecl_iterator redecl_iterator;
redecl_iterator redecls_begin() const {
@@ -2031,14 +2035,12 @@
}
typedef Redeclarable<TagDecl> redeclarable_base;
- TagDecl *getNextRedeclaration() { return RedeclLink.getNext(); }
+ virtual TagDecl *getNextRedeclaration() { return RedeclLink.getNext(); }
/// @brief Completes the definition of this tag declaration.
///
/// This is a helper function for derived classes.
void completeDefinition();
-
- friend class Decl;
public:
typedef redeclarable_base::redecl_iterator redecl_iterator;
@@ -2057,14 +2059,14 @@
/// getInnerLocStart - Return SourceLocation representing start of source
/// range ignoring outer template declarations.
- SourceLocation getInnerLocStart() const;
+ virtual SourceLocation getInnerLocStart() const { return TagKeywordLoc; }
/// getOuterLocStart - Return SourceLocation representing start of source
/// range taking into account any outer template declarations.
SourceLocation getOuterLocStart() const;
- SourceRange getSourceRange() const;
+ virtual SourceRange getSourceRange() const;
- TagDecl* getCanonicalDecl();
+ virtual TagDecl* getCanonicalDecl();
const TagDecl* getCanonicalDecl() const {
return const_cast<TagDecl*>(this)->getCanonicalDecl();
}
@@ -2478,8 +2480,9 @@
return field_begin() == field_end();
}
- /// \brief Indicates that the definition of this class is now complete.
- void completeDefinition();
+ /// completeDefinition - Notes that the definition of this type is
+ /// now complete.
+ virtual void completeDefinition();
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
static bool classof(const RecordDecl *D) { return true; }
@@ -2636,7 +2639,7 @@
const Capture *end,
bool capturesCXXThis);
- SourceRange getSourceRange() const;
+ virtual SourceRange getSourceRange() const;
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
Modified: cfe/trunk/include/clang/AST/DeclBase.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=126033&r1=126032&r2=126033&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Sat Feb 19 12:51:44 2011
@@ -270,10 +270,14 @@
if (Decl::CollectingStats()) add(DK);
}
+ virtual ~Decl();
+
public:
/// \brief Source range that this declaration covers.
- SourceRange getSourceRange() const;
+ virtual SourceRange getSourceRange() const {
+ return SourceRange(getLocation(), getLocation());
+ }
SourceLocation getLocStart() const { return getSourceRange().getBegin(); }
SourceLocation getLocEnd() const { return getSourceRange().getEnd(); }
@@ -455,10 +459,9 @@
return const_cast<Decl*>(this)->getLexicalDeclContext();
}
- /// \brief Determine whether this declaration was written out-of-line, which
- /// typically indicates that it was written with a qualified name in a scope
- /// outside of its semantic scope.
- bool isOutOfLine() const;
+ virtual bool isOutOfLine() const {
+ return getLexicalDeclContext() != getDeclContext();
+ }
/// setDeclContext - Set both the semantic and lexical DeclContext
/// to DC.
@@ -473,7 +476,7 @@
bool isDefinedOutsideFunctionOrMethod() const;
/// \brief Retrieves the "canonical" declaration of the given declaration.
- Decl *getCanonicalDecl();
+ virtual Decl *getCanonicalDecl() { return this; }
const Decl *getCanonicalDecl() const {
return const_cast<Decl*>(this)->getCanonicalDecl();
}
@@ -486,7 +489,7 @@
///
/// Decl subclasses that can be redeclared should override this method so that
/// Decl::redecl_iterator can iterate over them.
- Decl *getNextRedeclaration();
+ virtual Decl *getNextRedeclaration() { return this; }
public:
/// \brief Iterates through all the redeclarations of the same decl.
@@ -541,11 +544,11 @@
/// getBody - If this Decl represents a declaration for a body of code,
/// such as a function or method definition, this method returns the
/// top-level Stmt* of that body. Otherwise this method returns null.
- Stmt* getBody() const;
+ virtual Stmt* getBody() const { return 0; }
/// \brief Returns true if this Decl represents a declaration for a body of
/// code, such as a function or method definition.
- bool hasBody() const;
+ virtual bool hasBody() const { return getBody() != 0; }
/// getBodyRBrace - Gets the right brace of the body, if a body exists.
/// This works whether the body is a CompoundStmt or a CXXTryStmt.
Modified: cfe/trunk/include/clang/AST/DeclCXX.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=126033&r1=126032&r2=126033&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclCXX.h (original)
+++ cfe/trunk/include/clang/AST/DeclCXX.h Sat Feb 19 12:51:44 2011
@@ -447,9 +447,6 @@
void markedVirtualFunctionPure();
friend void FunctionDecl::setPure(bool);
- void completeDefinitionImpl(CXXFinalOverriderMap *FinalOverriders);
- friend class RecordDecl;
-
protected:
CXXRecordDecl(Kind K, TagKind TK, DeclContext *DC,
SourceLocation L, IdentifierInfo *Id,
@@ -475,10 +472,10 @@
typedef std::reverse_iterator<base_class_const_iterator>
reverse_base_class_const_iterator;
- CXXRecordDecl *getCanonicalDecl() {
+ virtual CXXRecordDecl *getCanonicalDecl() {
return cast<CXXRecordDecl>(RecordDecl::getCanonicalDecl());
}
- const CXXRecordDecl *getCanonicalDecl() const {
+ virtual const CXXRecordDecl *getCanonicalDecl() const {
return cast<CXXRecordDecl>(RecordDecl::getCanonicalDecl());
}
@@ -997,6 +994,9 @@
return (PathAccess > DeclAccess ? PathAccess : DeclAccess);
}
+ /// \brief Indicates that the definition of this class is now complete.
+ virtual void completeDefinition();
+
/// \brief Indicates that the definition of this class is now complete,
/// and provides a final overrider map to help determine
///
@@ -1922,7 +1922,7 @@
SourceLocation IdentLoc,
NamedDecl *Namespace);
- SourceRange getSourceRange() const {
+ virtual SourceRange getSourceRange() const {
return SourceRange(NamespaceLoc, IdentLoc);
}
Modified: cfe/trunk/include/clang/AST/DeclObjC.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=126033&r1=126032&r2=126033&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclObjC.h (original)
+++ cfe/trunk/include/clang/AST/DeclObjC.h Sat Feb 19 12:51:44 2011
@@ -182,9 +182,8 @@
/// \brief A definition will return its interface declaration.
/// An interface declaration will return its definition.
/// Otherwise it will return itself.
- ObjCMethodDecl *getNextRedeclaration();
- friend class Decl;
-
+ virtual ObjCMethodDecl *getNextRedeclaration();
+
public:
static ObjCMethodDecl *Create(ASTContext &C,
SourceLocation beginLoc,
@@ -199,7 +198,7 @@
ImplementationControl impControl = None,
unsigned numSelectorArgs = 0);
- ObjCMethodDecl *getCanonicalDecl();
+ virtual ObjCMethodDecl *getCanonicalDecl();
const ObjCMethodDecl *getCanonicalDecl() const {
return const_cast<ObjCMethodDecl*>(this)->getCanonicalDecl();
}
@@ -218,7 +217,7 @@
SourceLocation getLocStart() const { return getLocation(); }
SourceLocation getLocEnd() const { return EndLoc; }
void setEndLoc(SourceLocation Loc) { EndLoc = Loc; }
- SourceRange getSourceRange() const {
+ virtual SourceRange getSourceRange() const {
return SourceRange(getLocation(), EndLoc);
}
@@ -301,7 +300,7 @@
return ImplementationControl(DeclImplementation);
}
- Stmt *getBody() const {
+ virtual Stmt *getBody() const {
return (Stmt*) Body;
}
CompoundStmt *getCompoundBody() { return (CompoundStmt*)Body; }
@@ -394,7 +393,7 @@
AtEnd = atEnd;
}
- SourceRange getSourceRange() const {
+ virtual SourceRange getSourceRange() const {
return SourceRange(getLocation(), getAtEndRange().getEnd());
}
@@ -887,7 +886,7 @@
const SourceLocation *Locs = 0,
unsigned nElts = 0);
- SourceRange getSourceRange() const;
+ virtual SourceRange getSourceRange() const;
typedef const ObjCClassRef* iterator;
iterator begin() const { return ForwardDecls; }
@@ -1068,7 +1067,7 @@
SourceLocation getCategoryNameLoc() const { return CategoryNameLoc; }
void setCategoryNameLoc(SourceLocation Loc) { CategoryNameLoc = Loc; }
- SourceRange getSourceRange() const {
+ virtual SourceRange getSourceRange() const {
return SourceRange(AtLoc, getAtEndRange().getEnd());
}
@@ -1479,7 +1478,7 @@
return PropertyIvarDecl;
}
- SourceRange getSourceRange() const {
+ virtual SourceRange getSourceRange() const {
return SourceRange(AtLoc, getLocation());
}
@@ -1545,7 +1544,7 @@
ObjCIvarDecl *ivarDecl,
SourceLocation ivarLoc);
- SourceRange getSourceRange() const;
+ virtual SourceRange getSourceRange() const;
SourceLocation getLocStart() const { return AtLoc; }
void setAtLoc(SourceLocation Loc) { AtLoc = Loc; }
Modified: cfe/trunk/include/clang/AST/DeclTemplate.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclTemplate.h?rev=126033&r1=126032&r2=126033&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclTemplate.h (original)
+++ cfe/trunk/include/clang/AST/DeclTemplate.h Sat Feb 19 12:51:44 2011
@@ -561,7 +561,7 @@
/// for the common pointer.
CommonBase *getCommonPtr();
- CommonBase *newCommon(ASTContext &C);
+ virtual CommonBase *newCommon(ASTContext &C) = 0;
// Construct a template decl with name, parameters, and templated element.
RedeclarableTemplateDecl(Kind DK, DeclContext *DC, SourceLocation L,
@@ -651,7 +651,7 @@
return getInstantiatedFromMemberTemplateImpl();
}
- RedeclarableTemplateDecl *getNextRedeclaration();
+ virtual RedeclarableTemplateDecl *getNextRedeclaration();
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
@@ -773,8 +773,7 @@
}
friend class FunctionDecl;
- friend class RedeclarableTemplateDecl;
-
+
/// \brief Retrieve the set of function template specializations of this
/// function template.
llvm::FoldingSet<FunctionTemplateSpecializationInfo> &getSpecializations() {
@@ -1041,6 +1040,7 @@
using TemplateParmPosition::setPosition;
using TemplateParmPosition::getIndex;
+ SourceLocation getInnerLocStart() const;
SourceRange getSourceRange() const;
/// \brief Determine whether this template parameter has a default
@@ -1317,6 +1317,10 @@
static ClassTemplateSpecializationDecl *
Create(ASTContext &Context, EmptyShell Empty);
+ virtual void getNameForDiagnostic(std::string &S,
+ const PrintingPolicy &Policy,
+ bool Qualified) const;
+
ClassTemplateSpecializationDecl *getMostRecentDeclaration() {
CXXRecordDecl *Recent
= cast<CXXRecordDecl>(CXXRecordDecl::getMostRecentDeclaration());
@@ -1467,6 +1471,8 @@
return ExplicitInfo ? ExplicitInfo->TemplateKeywordLoc : SourceLocation();
}
+ SourceLocation getInnerLocStart() const { return getTemplateKeywordLoc(); }
+
void Profile(llvm::FoldingSetNodeID &ID) const {
Profile(ID, TemplateArgs->data(), TemplateArgs->size(), getASTContext());
}
@@ -1725,8 +1731,6 @@
return static_cast<Common *>(RedeclarableTemplateDecl::getCommonPtr());
}
- friend class RedeclarableTemplateDecl;
-
public:
/// Get the underlying class declarations of the template.
CXXRecordDecl *getTemplatedDecl() const {
Modified: cfe/trunk/lib/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=126033&r1=126032&r2=126033&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Sat Feb 19 12:51:44 2011
@@ -601,30 +601,6 @@
}
}
-void NamedDecl::getNameForDiagnostic(std::string &S,
- const PrintingPolicy &Policy,
- bool Qualified) const {
- if (Qualified)
- S += getQualifiedNameAsString(Policy);
- else
- S += getNameAsString();
-
- const TemplateArgumentList *TemplateArgs = 0;
-
- if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(this))
- TemplateArgs = FD->getTemplateSpecializationArgs();
- else if (const ClassTemplateSpecializationDecl *Spec
- = dyn_cast<ClassTemplateSpecializationDecl>(this))
- TemplateArgs = &Spec->getTemplateArgs();
-
-
- if (TemplateArgs)
- S += TemplateSpecializationType::PrintTemplateArgumentList(
- TemplateArgs->data(),
- TemplateArgs->size(),
- Policy);
-}
-
void NamedDecl::ClearLinkageCache() {
// Note that we can't skip clearing the linkage of children just
// because the parent doesn't have cached linkage: we don't cache
@@ -981,20 +957,6 @@
}
}
-SourceLocation DeclaratorDecl::getInnerLocStart() const {
- if (const VarDecl *Var = dyn_cast<VarDecl>(this)) {
- SourceLocation Start = Var->getTypeSpecStartLoc();
- if (Start.isValid())
- return Start;
- } else if (const NonTypeTemplateParmDecl *NTTP
- = dyn_cast<NonTypeTemplateParmDecl>(this)) {
- SourceLocation Start = NTTP->getTypeSpecStartLoc();
- if (Start.isValid())
- return Start;
- }
- return getLocation();
-}
-
SourceLocation DeclaratorDecl::getOuterLocStart() const {
return getTemplateOrInnerLocStart(this);
}
@@ -1055,6 +1017,13 @@
SClass = SC;
}
+SourceLocation VarDecl::getInnerLocStart() const {
+ SourceLocation Start = getTypeSpecStartLoc();
+ if (Start.isInvalid())
+ Start = getLocation();
+ return Start;
+}
+
SourceRange VarDecl::getSourceRange() const {
if (getInit())
return SourceRange(getOuterLocStart(), getInit()->getLocEnd());
@@ -1202,7 +1171,7 @@
}
bool VarDecl::isOutOfLine() const {
- if (getLexicalDeclContext() != getDeclContext())
+ if (Decl::isOutOfLine())
return true;
if (!isStaticDataMember())
@@ -1326,6 +1295,19 @@
// FunctionDecl Implementation
//===----------------------------------------------------------------------===//
+void FunctionDecl::getNameForDiagnostic(std::string &S,
+ const PrintingPolicy &Policy,
+ bool Qualified) const {
+ NamedDecl::getNameForDiagnostic(S, Policy, Qualified);
+ const TemplateArgumentList *TemplateArgs = getTemplateSpecializationArgs();
+ if (TemplateArgs)
+ S += TemplateSpecializationType::PrintTemplateArgumentList(
+ TemplateArgs->data(),
+ TemplateArgs->size(),
+ Policy);
+
+}
+
bool FunctionDecl::isVariadic() const {
if (const FunctionProtoType *FT = getType()->getAs<FunctionProtoType>())
return FT->isVariadic();
@@ -1913,7 +1895,7 @@
}
bool FunctionDecl::isOutOfLine() const {
- if (getLexicalDeclContext() != getDeclContext())
+ if (Decl::isOutOfLine())
return true;
// If this function was instantiated from a member function of a
@@ -1978,17 +1960,6 @@
// TagDecl Implementation
//===----------------------------------------------------------------------===//
-SourceLocation TagDecl::getInnerLocStart() const {
- if (const ClassTemplateSpecializationDecl *Spec
- = dyn_cast<ClassTemplateSpecializationDecl>(this)) {
- SourceLocation Start = Spec->getTemplateKeywordLoc();
- if (Start.isValid())
- return Start;
- }
-
- return getTagKeywordLoc();
-}
-
SourceLocation TagDecl::getOuterLocStart() const {
return getTemplateOrInnerLocStart(this);
}
@@ -2140,6 +2111,13 @@
return field_iterator(decl_iterator(FirstDecl));
}
+/// completeDefinition - Notes that the definition of this type is now
+/// complete.
+void RecordDecl::completeDefinition() {
+ assert(!isDefinition() && "Cannot redefine record!");
+ TagDecl::completeDefinition();
+}
+
void RecordDecl::LoadFieldsFromExternalStorage() const {
ExternalASTSource *Source = getASTContext().getExternalSource();
assert(hasExternalLexicalStorage() && Source && "No external storage?");
@@ -2165,13 +2143,6 @@
llvm::tie(FirstDecl, LastDecl) = BuildDeclChain(Decls);
}
-void RecordDecl::completeDefinition() {
- assert(!isDefinition() && "Cannot redefine record!");
- TagDecl::completeDefinition();
- if (CXXRecordDecl *CXXRecord = dyn_cast<CXXRecordDecl>(this))
- CXXRecord->completeDefinitionImpl(0);
-}
-
//===----------------------------------------------------------------------===//
// BlockDecl Implementation
//===----------------------------------------------------------------------===//
Modified: cfe/trunk/lib/AST/DeclBase.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=126033&r1=126032&r2=126033&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Sat Feb 19 12:51:44 2011
@@ -42,30 +42,6 @@
static bool StatSwitch = false;
-namespace {
- template<typename Class>
- inline SourceRange getSourceRangeImpl(const Decl *D,
- SourceRange (Class::*)() const) {
- return static_cast<const Class *>(D)->getSourceRange();
- }
-
- inline SourceRange getSourceRangeImpl(const Decl *D,
- SourceRange (Decl::*)() const) {
- return D->getLocation();
- }
-}
-
-SourceRange Decl::getSourceRange() const {
- switch (getKind()) {
-#define ABSTRACT_DECL(Type)
-#define DECL(Type, Base) \
- case Type: return getSourceRangeImpl(this, &Type##Decl::getSourceRange);
-#include "clang/AST/DeclNodes.inc"
- }
-
- return getLocation();
-}
-
const char *Decl::getDeclKindName() const {
switch (DeclKind) {
default: assert(0 && "Declaration not in DeclNodes.inc!");
@@ -167,101 +143,6 @@
return true;
}
-namespace {
- template<typename Class, typename Result>
- inline Result *getCanonicalDeclImpl(Decl *D, Result *(Class::*)()) {
- return static_cast<Class *>(D)->getCanonicalDecl();
- }
-
- inline Decl *getCanonicalDeclImpl(Decl *D, Decl *(Decl::*)()) {
- // No specific implementation.
- return D;
- }
-}
-
-Decl *Decl::getCanonicalDecl() {
- switch (getKind()) {
-#define ABSTRACT_DECL(Type)
-#define DECL(Type, Base) \
- case Type: \
- return getCanonicalDeclImpl(this, &Type##Decl::getCanonicalDecl);
-#include "clang/AST/DeclNodes.inc"
- }
-
- return this;
-}
-
-Decl *Decl::getNextRedeclaration() {
- switch (getKind()) {
- case Var:
- return static_cast<VarDecl *>(this)->getNextRedeclaration();
-
- case Function:
- case CXXMethod:
- case CXXConstructor:
- case CXXDestructor:
- case CXXConversion:
- return static_cast<FunctionDecl *>(this)->getNextRedeclaration();
-
- case Typedef:
- return static_cast<TypedefDecl *>(this)->getNextRedeclaration();
-
- case Enum:
- case Record:
- case CXXRecord:
- case ClassTemplateSpecialization:
- case ClassTemplatePartialSpecialization:
- return static_cast<TagDecl *>(this)->getNextRedeclaration();
-
- case ObjCMethod:
- return static_cast<ObjCMethodDecl *>(this)->getNextRedeclaration();
-
- case FunctionTemplate:
- case ClassTemplate:
- return static_cast<RedeclarableTemplateDecl *>(this)
- ->getNextRedeclaration();
-
- case Namespace:
- case UsingDirective:
- case NamespaceAlias:
- case Label:
- case UnresolvedUsingTypename:
- case TemplateTypeParm:
- case EnumConstant:
- case UnresolvedUsingValue:
- case IndirectField:
- case Field:
- case ObjCIvar:
- case ObjCAtDefsField:
- case ImplicitParam:
- case ParmVar:
- case NonTypeTemplateParm:
- case TemplateTemplateParm:
- case Using:
- case UsingShadow:
- case ObjCCategory:
- case ObjCProtocol:
- case ObjCInterface:
- case ObjCCategoryImpl:
- case ObjCImplementation:
- case ObjCProperty:
- case ObjCCompatibleAlias:
- case LinkageSpec:
- case ObjCPropertyImpl:
- case ObjCForwardProtocol:
- case ObjCClass:
- case FileScopeAsm:
- case AccessSpec:
- case Friend:
- case FriendTemplate:
- case StaticAssert:
- case Block:
- case TranslationUnit:
- return this;
- }
-
- return this;
-}
//===----------------------------------------------------------------------===//
// PrettyStackTraceDecl Implementation
@@ -288,14 +169,8 @@
// Decl Implementation
//===----------------------------------------------------------------------===//
-bool Decl::isOutOfLine() const {
- if (const VarDecl *VD = dyn_cast<VarDecl>(this))
- return VD->isOutOfLine();
- if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(this))
- return FD->isOutOfLine();
-
- return getLexicalDeclContext() != getDeclContext();
-}
+// Out-of-line virtual method providing a home for Decl.
+Decl::~Decl() { }
void Decl::setDeclContext(DeclContext *DC) {
if (isOutOfSemaDC())
@@ -546,24 +421,6 @@
}
}
-Stmt *Decl::getBody() const {
- if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(this))
- return FD->getBody();
- if (const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(this))
- return MD->getBody();
- if (const BlockDecl *BD = dyn_cast<BlockDecl>(this))
- return BD->getBody();
-
- return 0;
-}
-
-bool Decl::hasBody() const {
- if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(this))
- return FD->hasBody();
-
- return getBody() != 0;
-}
-
SourceLocation Decl::getBodyRBrace() const {
// Special handling of FunctionDecl to avoid de-serializing the body from PCH.
// FunctionDecl stores EndRangeLoc for this purpose.
Modified: cfe/trunk/lib/AST/DeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclCXX.cpp?rev=126033&r1=126032&r2=126033&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclCXX.cpp (original)
+++ cfe/trunk/lib/AST/DeclCXX.cpp Sat Feb 19 12:51:44 2011
@@ -819,8 +819,13 @@
return Dtor;
}
-void
-CXXRecordDecl::completeDefinitionImpl(CXXFinalOverriderMap *FinalOverriders) {
+void CXXRecordDecl::completeDefinition() {
+ completeDefinition(0);
+}
+
+void CXXRecordDecl::completeDefinition(CXXFinalOverriderMap *FinalOverriders) {
+ RecordDecl::completeDefinition();
+
// If the class may be abstract (but hasn't been marked as such), check for
// any pure final overriders.
if (mayBeAbstract()) {
@@ -860,12 +865,6 @@
data().Conversions.setAccess(I, (*I)->getAccess());
}
-void
-CXXRecordDecl::completeDefinition(CXXFinalOverriderMap *FinalOverriders) {
- TagDecl::completeDefinition();
- completeDefinitionImpl(FinalOverriders);
-}
-
bool CXXRecordDecl::mayBeAbstract() const {
if (data().Abstract || isInvalidDecl() || !data().Polymorphic ||
isDependentContext())
Modified: cfe/trunk/lib/AST/DeclTemplate.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclTemplate.cpp?rev=126033&r1=126032&r2=126033&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclTemplate.cpp (original)
+++ cfe/trunk/lib/AST/DeclTemplate.cpp Sat Feb 19 12:51:44 2011
@@ -112,14 +112,6 @@
}
-RedeclarableTemplateDecl::CommonBase *
-RedeclarableTemplateDecl::newCommon(ASTContext &C) {
- if (FunctionTemplateDecl *FunTmpl = dyn_cast<FunctionTemplateDecl>(this))
- return FunTmpl->newCommon(C);
-
- return cast<ClassTemplateDecl>(this)->newCommon(C);
-}
-
RedeclarableTemplateDecl *RedeclarableTemplateDecl::getCanonicalDeclImpl() {
RedeclarableTemplateDecl *Tmpl = this;
while (Tmpl->getPreviousDeclaration())
@@ -455,6 +447,13 @@
ExpandedTInfos);
}
+SourceLocation NonTypeTemplateParmDecl::getInnerLocStart() const {
+ SourceLocation Start = getTypeSpecStartLoc();
+ if (Start.isInvalid())
+ Start = getLocation();
+ return Start;
+}
+
SourceRange NonTypeTemplateParmDecl::getSourceRange() const {
return SourceRange(getOuterLocStart(), getLocation());
}
@@ -544,6 +543,19 @@
new (Context)ClassTemplateSpecializationDecl(ClassTemplateSpecialization);
}
+void
+ClassTemplateSpecializationDecl::getNameForDiagnostic(std::string &S,
+ const PrintingPolicy &Policy,
+ bool Qualified) const {
+ NamedDecl::getNameForDiagnostic(S, Policy, Qualified);
+
+ const TemplateArgumentList &TemplateArgs = getTemplateArgs();
+ S += TemplateSpecializationType::PrintTemplateArgumentList(
+ TemplateArgs.data(),
+ TemplateArgs.size(),
+ Policy);
+}
+
ClassTemplateDecl *
ClassTemplateSpecializationDecl::getSpecializedTemplate() const {
if (SpecializedPartialSpecialization *PartialSpec
More information about the cfe-commits
mailing list