[cfe-commits] r85057 - in /cfe/trunk/lib: Parse/ParseExpr.cpp Sema/SemaDecl.cpp
Chris Lattner
sabre at nondot.org
Sun Oct 25 10:16:47 PDT 2009
Author: lattner
Date: Sun Oct 25 12:16:46 2009
New Revision: 85057
URL: http://llvm.org/viewvc/llvm-project?rev=85057&view=rev
Log:
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.
Modified:
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=85057&r1=85056&r2=85057&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Sun Oct 25 12:16:46 2009
@@ -345,7 +345,7 @@
&& 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();
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=85057&r1=85056&r2=85057&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Sun Oct 25 12:16:46 2009
@@ -138,44 +138,40 @@
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*
More information about the cfe-commits
mailing list