aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/Decl.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-02-19 18:51:44 +0000
committerDouglas Gregor <dgregor@apple.com>2011-02-19 18:51:44 +0000
commitda2142f2e2b3a02ee6eb5de9f9e6ed6f7eb5a0c0 (patch)
treebdb4fdd5649f271c47b55ed687dc2b1f9feb3170 /lib/AST/Decl.cpp
parentf91ae524c01488ef2e525e5d73fa61424948e6c6 (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126033 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/Decl.cpp')
-rw-r--r--lib/AST/Decl.cpp87
1 files changed, 29 insertions, 58 deletions
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
index 7d4b461f5a..56db8c7e33 100644
--- a/lib/AST/Decl.cpp
+++ b/lib/AST/Decl.cpp
@@ -601,30 +601,6 @@ static void clearLinkageForClass(const CXXRecordDecl *record) {
}
}
-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 @@ void DeclaratorDecl::setQualifierInfo(NestedNameSpecifier *Qualifier,
}
}
-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 @@ void VarDecl::setStorageClass(StorageClass SC) {
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 @@ const Expr *VarDecl::getAnyInitializer(const VarDecl *&D) const {
}
bool VarDecl::isOutOfLine() const {
- if (getLexicalDeclContext() != getDeclContext())
+ if (Decl::isOutOfLine())
return true;
if (!isStaticDataMember())
@@ -1326,6 +1295,19 @@ bool ParmVarDecl::isParameterPack() const {
// 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 @@ SourceLocation FunctionDecl::getPointOfInstantiation() const {
}
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 @@ unsigned FieldDecl::getFieldIndex() const {
// 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 @@ RecordDecl::field_iterator RecordDecl::field_begin() const {
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 @@ void RecordDecl::LoadFieldsFromExternalStorage() const {
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
//===----------------------------------------------------------------------===//