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.

llvm-svn: 85057
This commit is contained in:
Chris Lattner 2009-10-25 17:16:46 +00:00
parent 5566290b34
commit 17e15f18c5
2 changed files with 29 additions and 33 deletions

View File

@ -138,14 +138,13 @@ Sema::TypeTy *Sema::getTypeName(IdentifierInfo &II, SourceLocation NameLoc,
break;
}
if (IIDecl) {
QualType T;
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);
if (getLangOptions().CPlusPlus) {
// C++ [temp.local]p2:
// Within the scope of a class template specialization or
// partial specialization, when the injected-class-name is
@ -157,10 +156,13 @@ Sema::TypeTy *Sema::getTypeName(IdentifierInfo &II, SourceLocation NameLoc,
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);
@ -169,13 +171,7 @@ Sema::TypeTy *Sema::getTypeName(IdentifierInfo &II, SourceLocation NameLoc,
} else
return 0;
if (SS)
T = getQualifiedNameType(*SS, T);
return T.getAsOpaquePtr();
}
return 0;
}
/// isTagName() - This method is called *for error recovery purposes only*