diff options
author | Chris Lattner <sabre@nondot.org> | 2009-10-25 17:16:46 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-10-25 17:16:46 +0000 |
commit | 10ca337b1e3684547bd21021a23a566f30fa83b4 (patch) | |
tree | c28edb3ea39604c57f50ad9a4a6b59d0dbc26b2c /lib/Sema/SemaDecl.cpp | |
parent | b7c3fd7b493329550c29dec11d31aca4d537e23e (diff) |
simplify Sema::getTypeName a bit: if control gets out of the switch,
IIDecl cannot be null. There is no need to check for both C++ mode and
presence of CXXRecordDecl. ObjC interfaces can't have ScopeSpecs.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@85057 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDecl.cpp')
-rw-r--r-- | lib/Sema/SemaDecl.cpp | 64 |
1 files changed, 30 insertions, 34 deletions
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 4858321d51..d9da254588 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -138,44 +138,40 @@ Sema::TypeTy *Sema::getTypeName(IdentifierInfo &II, SourceLocation NameLoc, break; } - if (IIDecl) { - QualType T; - - if (TypeDecl *TD = dyn_cast<TypeDecl>(IIDecl)) { - // Check whether we can use this type. - (void)DiagnoseUseOfDecl(IIDecl, NameLoc); - - if (getLangOptions().CPlusPlus) { - // C++ [temp.local]p2: - // Within the scope of a class template specialization or - // partial specialization, when the injected-class-name is - // not followed by a <, it is equivalent to the - // injected-class-name followed by the template-argument s - // of the class template specialization or partial - // specialization enclosed in <>. - if (CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(TD)) - if (RD->isInjectedClassName()) - if (ClassTemplateDecl *Template = RD->getDescribedClassTemplate()) - T = Template->getInjectedClassNameType(Context); - } - - if (T.isNull()) - T = Context.getTypeDeclType(TD); - } else if (ObjCInterfaceDecl *IDecl = dyn_cast<ObjCInterfaceDecl>(IIDecl)) { - // Check whether we can use this interface. - (void)DiagnoseUseOfDecl(IIDecl, NameLoc); - - T = Context.getObjCInterfaceType(IDecl); - } else - return 0; - + assert(IIDecl && "Didn't find decl"); + + QualType T; + if (TypeDecl *TD = dyn_cast<TypeDecl>(IIDecl)) { + // Check whether we can use this type. + (void)DiagnoseUseOfDecl(IIDecl, NameLoc); + + // C++ [temp.local]p2: + // Within the scope of a class template specialization or + // partial specialization, when the injected-class-name is + // not followed by a <, it is equivalent to the + // injected-class-name followed by the template-argument s + // of the class template specialization or partial + // specialization enclosed in <>. + if (CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(TD)) + if (RD->isInjectedClassName()) + if (ClassTemplateDecl *Template = RD->getDescribedClassTemplate()) + T = Template->getInjectedClassNameType(Context); + + if (T.isNull()) + T = Context.getTypeDeclType(TD); + if (SS) T = getQualifiedNameType(*SS, T); + + } else if (ObjCInterfaceDecl *IDecl = dyn_cast<ObjCInterfaceDecl>(IIDecl)) { + // Check whether we can use this interface. + (void)DiagnoseUseOfDecl(IIDecl, NameLoc); - return T.getAsOpaquePtr(); - } + T = Context.getObjCInterfaceType(IDecl); + } else + return 0; - return 0; + return T.getAsOpaquePtr(); } /// isTagName() - This method is called *for error recovery purposes only* |