зеркало из https://github.com/microsoft/clang-1.git
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
This commit is contained in:
Родитель
b7c3fd7b49
Коммит
10ca337b1e
|
@ -345,7 +345,7 @@ Parser::ParseRHSOfBinaryExpression(OwningExprResult LHS, unsigned MinPrec) {
|
|||
&& Tok.is(tok::identifier)) {
|
||||
CXXScopeSpec SS;
|
||||
if (Actions.getTypeName(*Tok.getIdentifierInfo(),
|
||||
Tok.getLocation(), CurScope, &SS)) {
|
||||
Tok.getLocation(), CurScope, &SS)) {
|
||||
const char *Opc = OpToken.is(tok::periodstar) ? "'.*'" : "'->*'";
|
||||
Diag(OpToken, diag::err_pointer_to_member_type) << Opc;
|
||||
return ExprError();
|
||||
|
|
|
@ -138,44 +138,40 @@ 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 (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;
|
||||
// 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*
|
||||
|
|
Загрузка…
Ссылка в новой задаче