diff options
| author | John McCall <rjmccall@apple.com> | 2010-03-10 06:48:02 +0000 |
|---|---|---|
| committer | John McCall <rjmccall@apple.com> | 2010-03-10 06:48:02 +0000 |
| commit | 96f0b5f844bf1013ed49b49673b2a95af055e194 (patch) | |
| tree | 56945fd4e933f5c9e458444841eead982aa6cba1 /clang/lib/AST/ASTContext.cpp | |
| parent | 5ebe0c1e139de47c69616453ebd060eb51cf5be9 (diff) | |
| download | bcm5719-llvm-96f0b5f844bf1013ed49b49673b2a95af055e194.tar.gz bcm5719-llvm-96f0b5f844bf1013ed49b49673b2a95af055e194.zip | |
Allow the fast path through ASTContext::getTypeDeclType to be inlined.
llvm-svn: 98138
Diffstat (limited to 'clang/lib/AST/ASTContext.cpp')
| -rw-r--r-- | clang/lib/AST/ASTContext.cpp | 34 |
1 files changed, 16 insertions, 18 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index f134bfdf1f2..26b10b58713 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/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); } |

