[cfe-commits] r42790 - /cfe/trunk/Sema/SemaDecl.cpp
Fariborz Jahanian
fjahanian at apple.com
Tue Oct 9 10:05:22 PDT 2007
Author: fjahanian
Date: Tue Oct 9 12:05:22 2007
New Revision: 42790
URL: http://llvm.org/viewvc/llvm-project?rev=42790&view=rev
Log:
Prevent memory leak by not creating a category object when there is a
fatal error of category's undefined interface.
Modified:
cfe/trunk/Sema/SemaDecl.cpp
Modified: cfe/trunk/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaDecl.cpp?rev=42790&r1=42789&r2=42790&view=diff
==============================================================================
--- cfe/trunk/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/Sema/SemaDecl.cpp Tue Oct 9 12:05:22 2007
@@ -1063,17 +1063,17 @@
IdentifierInfo *CategoryName, SourceLocation CategoryLoc,
IdentifierInfo **ProtoRefNames, unsigned NumProtoRefs) {
ObjcInterfaceDecl *IDecl = getObjCInterfaceDecl(ClassName);
- ObjcCategoryDecl *CDecl = new ObjcCategoryDecl(AtInterfaceLoc, NumProtoRefs,
- CategoryName);
- bool err = false;
- CDecl->setClassInterface(IDecl);
-
+ ObjcCategoryDecl *CDecl;
+
/// Check that class of this category is already completely declared.
if (!IDecl || IDecl->isForwardDecl()) {
Diag(ClassLoc, diag::err_undef_interface, ClassName->getName());
- err = true;
+ return 0;
}
else {
+ CDecl = new ObjcCategoryDecl(AtInterfaceLoc, NumProtoRefs,
+ CategoryName);
+ CDecl->setClassInterface(IDecl);
/// Check for duplicate interface declaration for this category
ObjcCategoryDecl *CDeclChain;
for (CDeclChain = IDecl->getListCategories(); CDeclChain;
@@ -1081,7 +1081,6 @@
if (CDeclChain->getIdentifier() == CategoryName) {
Diag(CategoryLoc, diag::err_dup_category_def, ClassName->getName(),
CategoryName->getName());
- err = true;
break;
}
}
@@ -1097,12 +1096,11 @@
Diag(CategoryLoc, diag::err_undef_protocolref,
ProtoRefNames[i]->getName(),
CategoryName->getName());
- err = true;
}
CDecl->setCatReferencedProtocols((int)i, RefPDecl);
}
- return err ? 0 : CDecl;
+ return CDecl;
}
/// ActOnStartCategoryImplementation - Perform semantic checks on the
More information about the cfe-commits
mailing list