diff options
| author | Douglas Gregor <dgregor@apple.com> | 2008-04-13 21:07:44 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2008-04-13 21:07:44 +0000 |
| commit | 83a586ec19dd0db7fe4bc3b8e881173ae07f74f4 (patch) | |
| tree | eb1f1dc07b92bcc6b7b1b2ac434ee743a0dee18b /clang/lib/AST/ASTContext.cpp | |
| parent | f8f945499c169b5bb24cfa55d3d22f5bb23cda79 (diff) | |
| download | bcm5719-llvm-83a586ec19dd0db7fe4bc3b8e881173ae07f74f4.tar.gz bcm5719-llvm-83a586ec19dd0db7fe4bc3b8e881173ae07f74f4.zip | |
Introduce support for finding class and enum names via ordinary name lookup in C++
llvm-svn: 49621
Diffstat (limited to 'clang/lib/AST/ASTContext.cpp')
| -rw-r--r-- | clang/lib/AST/ASTContext.cpp | 32 |
1 files changed, 23 insertions, 9 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 5af59aadd37..e4b48e21e44 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -788,6 +788,28 @@ QualType ASTContext::getFunctionType(QualType ResultTy, QualType *ArgArray, return QualType(FTP, 0); } +/// getTypeDeclType - Return the unique reference to the type for the +/// specified type declaration. +QualType ASTContext::getTypeDeclType(TypeDecl *Decl) { + if (Decl->TypeForDecl) return QualType(Decl->TypeForDecl, 0); + + if (TypedefDecl *Typedef = dyn_cast_or_null<TypedefDecl>(Decl)) + return getTypedefType(Typedef); + else if (ObjCInterfaceDecl *ObjCInterface + = dyn_cast_or_null<ObjCInterfaceDecl>(Decl)) + return getObjCInterfaceType(ObjCInterface); + else if (RecordDecl *Record = dyn_cast_or_null<RecordDecl>(Decl)) { + Decl->TypeForDecl = new RecordType(Record); + Types.push_back(Decl->TypeForDecl); + return QualType(Decl->TypeForDecl, 0); + } else if (EnumDecl *Enum = dyn_cast_or_null<EnumDecl>(Decl)) { + Decl->TypeForDecl = new EnumType(Enum); + Types.push_back(Decl->TypeForDecl); + return QualType(Decl->TypeForDecl, 0); + } else + assert(false && "TypeDecl without a type?"); +} + /// getTypedefType - Return the unique reference to the type for the /// specified typename decl. QualType ASTContext::getTypedefType(TypedefDecl *Decl) { @@ -913,15 +935,7 @@ QualType ASTContext::getTypeOfType(QualType tofType) { /// specified TagDecl (struct/union/class/enum) decl. QualType ASTContext::getTagDeclType(TagDecl *Decl) { assert (Decl); - - // The decl stores the type cache. - if (Decl->TypeForDecl) return QualType(Decl->TypeForDecl, 0); - - TagType* T = new TagType(Decl, QualType()); - Types.push_back(T); - Decl->TypeForDecl = T; - - return QualType(T, 0); + return getTypeDeclType(Decl); } /// getSizeType - Return the unique type for "size_t" (C99 7.17), the result |

