diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2014-03-11 18:56:18 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2014-03-11 18:56:18 +0000 |
commit | 0c325319cfe3faff586c77f90b880032d802a4e9 (patch) | |
tree | c0745b1f408c8760ad6bd5baeef24c7c557e4e54 /clang/lib/AST/DeclObjC.cpp | |
parent | 83f858e578d3efa07549c1757d675293bc844b9a (diff) | |
download | bcm5719-llvm-0c325319cfe3faff586c77f90b880032d802a4e9.tar.gz bcm5719-llvm-0c325319cfe3faff586c77f90b880032d802a4e9.zip |
Objective-C. Prevent an assertion crash due to buggy code
as it can commonly happen. // rdar://16261494
llvm-svn: 203598
Diffstat (limited to 'clang/lib/AST/DeclObjC.cpp')
-rw-r--r-- | clang/lib/AST/DeclObjC.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/clang/lib/AST/DeclObjC.cpp b/clang/lib/AST/DeclObjC.cpp index b76fc5cf38a..094110fecf8 100644 --- a/clang/lib/AST/DeclObjC.cpp +++ b/clang/lib/AST/DeclObjC.cpp @@ -415,7 +415,9 @@ bool ObjCInterfaceDecl::inheritsDesignatedInitializers() const { void ObjCInterfaceDecl::getDesignatedInitializers( llvm::SmallVectorImpl<const ObjCMethodDecl *> &Methods) const { - assert(hasDefinition()); + // Check for a complete definition and recover if not so. + if (!isThisDeclarationADefinition()) + return; if (data().ExternallyCompleted) LoadExternalDefinition(); @@ -433,7 +435,9 @@ void ObjCInterfaceDecl::getDesignatedInitializers( bool ObjCInterfaceDecl::isDesignatedInitializer(Selector Sel, const ObjCMethodDecl **InitMethod) const { - assert(hasDefinition()); + // Check for a complete definition and recover if not so. + if (!isThisDeclarationADefinition()) + return false; if (data().ExternallyCompleted) LoadExternalDefinition(); @@ -1197,12 +1201,16 @@ void ObjCInterfaceDecl::setExternallyCompleted() { } void ObjCInterfaceDecl::setHasDesignatedInitializers() { - assert(hasDefinition() && "Forward declarations can't contain methods"); + // Check for a complete definition and recover if not so. + if (!isThisDeclarationADefinition()) + return; data().HasDesignatedInitializers = true; } bool ObjCInterfaceDecl::hasDesignatedInitializers() const { - assert(hasDefinition() && "Forward declarations can't contain methods"); + // Check for a complete definition and recover if not so. + if (!isThisDeclarationADefinition()) + return false; if (data().ExternallyCompleted) LoadExternalDefinition(); |