diff options
author | Ted Kremenek <kremenek@apple.com> | 2010-03-18 21:23:08 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2010-03-18 21:23:08 +0000 |
commit | b03d33edaf24af2893a50caee4d2c99839242c44 (patch) | |
tree | 3b6ff9de63e4cc90209999d0e3145bdf1daa812f /lib/AST/Expr.cpp | |
parent | 1857f628cb3acc4df2cd368b8fbd7d984486a06c (diff) |
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>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98874 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/Expr.cpp')
-rw-r--r-- | lib/AST/Expr.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index a62dbc9012..6a71e925d9 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -227,7 +227,12 @@ std::string PredefinedExpr::ComputeName(IdentType IT, const Decl *CurrentDecl) { 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 << '('; |