[cfe-commits] r98874 - in /cfe/trunk: lib/AST/Expr.cpp test/SemaObjC/invalid-code.m
Ted Kremenek
kremenek at apple.com
Thu Mar 18 14:23:09 PDT 2010
Author: kremenek
Date: Thu Mar 18 16:23:08 2010
New Revision: 98874
URL: http://llvm.org/viewvc/llvm-project?rev=98874&view=rev
Log:
Make PredefinedExpr::ComputeName() more robust to incorrect
code when we are printing the name of an Objective-C method
whose class has not been declared. Fixes <rdar://problem/7495713>.
Modified:
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/test/SemaObjC/invalid-code.m
Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=98874&r1=98873&r2=98874&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Thu Mar 18 16:23:08 2010
@@ -227,7 +227,12 @@
llvm::raw_svector_ostream Out(Name);
Out << (MD->isInstanceMethod() ? '-' : '+');
Out << '[';
- Out << MD->getClassInterface()->getNameAsString();
+
+ // For incorrect code, there might not be an ObjCInterfaceDecl. Do
+ // a null check to avoid a crash.
+ if (const ObjCInterfaceDecl *ID = MD->getClassInterface())
+ Out << ID->getNameAsString();
+
if (const ObjCCategoryImplDecl *CID =
dyn_cast<ObjCCategoryImplDecl>(MD->getDeclContext())) {
Out << '(';
Modified: cfe/trunk/test/SemaObjC/invalid-code.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/invalid-code.m?rev=98874&r1=98873&r2=98874&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/invalid-code.m (original)
+++ cfe/trunk/test/SemaObjC/invalid-code.m Thu Mar 18 16:23:08 2010
@@ -5,3 +5,10 @@
void *p = @1; // expected-error {{unexpected '@' in program}}
}
+// <rdar://problem/7495713>
+// This previously triggered a crash because the class has not been defined.
+ at implementation RDar7495713 (rdar_7495713_cat) // expected-error{{cannot find interface declaration for 'RDar7495713'}}
+- (id) rdar_7495713 {
+ __PRETTY_FUNCTION__; // expected-warning{{expression result unused}}
+}
+ at end
More information about the cfe-commits
mailing list