aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/ASTContext.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2010-03-10 06:48:02 +0000
committerJohn McCall <rjmccall@apple.com>2010-03-10 06:48:02 +0000
commitbecb8d5a6ab5103393eac5344ae69bcb860601dd (patch)
treeb6df95fae3d01bfe0e12fa26376d6c9e3c7461ed /lib/AST/ASTContext.cpp
parentc8023788ace75cf0a0417b9b88e643ceebae91e2 (diff)
Allow the fast path through ASTContext::getTypeDeclType to be inlined.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98138 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/ASTContext.cpp')
-rw-r--r--lib/AST/ASTContext.cpp34
1 files changed, 16 insertions, 18 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index f134bfdf1f..26b10b5871 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -1957,38 +1957,36 @@ QualType ASTContext::getInjectedClassNameType(CXXRecordDecl *Decl,
/// getTypeDeclType - Return the unique reference to the type for the
/// specified type declaration.
-QualType ASTContext::getTypeDeclType(const TypeDecl *Decl,
- const TypeDecl* PrevDecl) {
+QualType ASTContext::getTypeDeclTypeSlow(const TypeDecl *Decl) {
assert(Decl && "Passed null for Decl param");
- if (Decl->TypeForDecl) return QualType(Decl->TypeForDecl, 0);
+ assert(!Decl->TypeForDecl && "TypeForDecl present in slow case");
if (const TypedefDecl *Typedef = dyn_cast<TypedefDecl>(Decl))
return getTypedefType(Typedef);
- else if (isa<TemplateTypeParmDecl>(Decl)) {
- assert(false && "Template type parameter types are always available.");
- } else if (const ObjCInterfaceDecl *ObjCInterface
+
+ if (const ObjCInterfaceDecl *ObjCInterface
= dyn_cast<ObjCInterfaceDecl>(Decl))
return getObjCInterfaceType(ObjCInterface);
+ assert(!isa<TemplateTypeParmDecl>(Decl) &&
+ "Template type parameter types are always available.");
+
if (const RecordDecl *Record = dyn_cast<RecordDecl>(Decl)) {
- if (PrevDecl)
- Decl->TypeForDecl = PrevDecl->TypeForDecl;
- else {
- assert(!NeedsInjectedClassNameType(Record));
- Decl->TypeForDecl = new (*this, TypeAlignment) RecordType(Record);
- }
+ assert(!Record->getPreviousDeclaration() &&
+ "struct/union has previous declaration");
+ assert(!NeedsInjectedClassNameType(Record));
+ Decl->TypeForDecl = new (*this, TypeAlignment) RecordType(Record);
} else if (const EnumDecl *Enum = dyn_cast<EnumDecl>(Decl)) {
- if (PrevDecl)
- Decl->TypeForDecl = PrevDecl->TypeForDecl;
- else
- Decl->TypeForDecl = new (*this, TypeAlignment) EnumType(Enum);
+ assert(!Enum->getPreviousDeclaration() &&
+ "enum has previous declaration");
+ Decl->TypeForDecl = new (*this, TypeAlignment) EnumType(Enum);
} else if (const UnresolvedUsingTypenameDecl *Using =
dyn_cast<UnresolvedUsingTypenameDecl>(Decl)) {
Decl->TypeForDecl = new (*this, TypeAlignment) UnresolvedUsingType(Using);
} else
- assert(false && "TypeDecl without a type?");
+ llvm_unreachable("TypeDecl without a type?");
- if (!PrevDecl) Types.push_back(Decl->TypeForDecl);
+ Types.push_back(Decl->TypeForDecl);
return QualType(Decl->TypeForDecl, 0);
}