summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-02-16 21:26:43 +0000
committerChris Lattner <sabre@nondot.org>2009-02-16 21:26:43 +0000
commit9018ca8df89bba37bc082143375f3688d3d59d22 (patch)
tree2ddd95199263bc29fb9758de378e33eb40954218 /clang/lib/Sema
parent6c7ce109e0460bf06b23eef8592cf284375b47f7 (diff)
downloadbcm5719-llvm-9018ca8df89bba37bc082143375f3688d3d59d22.tar.gz
bcm5719-llvm-9018ca8df89bba37bc082143375f3688d3d59d22.zip
early exit on error. This code is creating an invalid decl on error. This is
dubious, but at least mark it as an invalid decl. llvm-svn: 64668
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r--clang/lib/Sema/SemaDeclObjC.cpp47
1 files changed, 23 insertions, 24 deletions
diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp
index 6e8154c3964..76a5c2c42a3 100644
--- a/clang/lib/Sema/SemaDeclObjC.cpp
+++ b/clang/lib/Sema/SemaDeclObjC.cpp
@@ -325,8 +325,7 @@ Sema::DiagnosePropertyMismatch(ObjCPropertyDecl *Property,
/// declarations in base and its super class, if any, and issues
/// diagnostics in a variety of inconsistant situations.
///
-void
-Sema::ComparePropertiesInBaseAndSuper(ObjCInterfaceDecl *IDecl) {
+void Sema::ComparePropertiesInBaseAndSuper(ObjCInterfaceDecl *IDecl) {
ObjCInterfaceDecl *SDecl = IDecl->getSuperClass();
if (!SDecl)
return;
@@ -390,10 +389,8 @@ Sema::MergeOneProtocolPropertiesIntoClass(Decl *CDecl,
/// declared in 'MergeItsProtocols' objects (which can be a class or an
/// inherited protocol into the list of properties for class/category 'CDecl'
///
-
-void
-Sema::MergeProtocolPropertiesIntoClass(Decl *CDecl,
- DeclTy *MergeItsProtocols) {
+void Sema::MergeProtocolPropertiesIntoClass(Decl *CDecl,
+ DeclTy *MergeItsProtocols) {
Decl *ClassDecl = static_cast<Decl *>(MergeItsProtocols);
ObjCInterfaceDecl *IDecl = dyn_cast_or_null<ObjCInterfaceDecl>(CDecl);
@@ -478,32 +475,34 @@ ActOnStartCategoryInterface(SourceLocation AtInterfaceLoc,
DeclTy * const *ProtoRefs,
unsigned NumProtoRefs,
SourceLocation EndProtoLoc) {
- ObjCInterfaceDecl *IDecl = getObjCInterfaceDecl(ClassName);
-
ObjCCategoryDecl *CDecl =
ObjCCategoryDecl::Create(Context, CurContext, AtInterfaceLoc, CategoryName);
// FIXME: PushOnScopeChains?
CurContext->addDecl(CDecl);
- CDecl->setClassInterface(IDecl);
-
+
+ ObjCInterfaceDecl *IDecl = getObjCInterfaceDecl(ClassName);
/// Check that class of this category is already completely declared.
- if (!IDecl || IDecl->isForwardDecl())
+ if (!IDecl || IDecl->isForwardDecl()) {
+ CDecl->setInvalidDecl();
Diag(ClassLoc, diag::err_undef_interface) << ClassName;
- else {
- /// Check for duplicate interface declaration for this category
- ObjCCategoryDecl *CDeclChain;
- for (CDeclChain = IDecl->getCategoryList(); CDeclChain;
- CDeclChain = CDeclChain->getNextClassCategory()) {
- if (CategoryName && CDeclChain->getIdentifier() == CategoryName) {
- Diag(CategoryLoc, diag::warn_dup_category_def)
- << ClassName << CategoryName;
- Diag(CDeclChain->getLocation(), diag::note_previous_definition);
- break;
- }
+ return CDecl;
+ }
+
+ CDecl->setClassInterface(IDecl);
+
+ /// Check for duplicate interface declaration for this category
+ ObjCCategoryDecl *CDeclChain;
+ for (CDeclChain = IDecl->getCategoryList(); CDeclChain;
+ CDeclChain = CDeclChain->getNextClassCategory()) {
+ if (CategoryName && CDeclChain->getIdentifier() == CategoryName) {
+ Diag(CategoryLoc, diag::warn_dup_category_def)
+ << ClassName << CategoryName;
+ Diag(CDeclChain->getLocation(), diag::note_previous_definition);
+ break;
}
- if (!CDeclChain)
- CDecl->insertNextClassCategory();
}
+ if (!CDeclChain)
+ CDecl->insertNextClassCategory();
if (NumProtoRefs) {
CDecl->addReferencedProtocols((ObjCProtocolDecl**)ProtoRefs, NumProtoRefs);
OpenPOWER on IntegriCloud