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 | 361ffd947c1536614ce47d512bbedf2ea8de0851 (patch) | |
| tree | 54c7402804461725ff11e22cd038ac00f407df6f /clang/lib/AST/Expr.cpp | |
| parent | abb1dddfcd2e575e2782e653460efc377076df73 (diff) | |
| download | bcm5719-llvm-361ffd947c1536614ce47d512bbedf2ea8de0851.tar.gz bcm5719-llvm-361ffd947c1536614ce47d512bbedf2ea8de0851.zip | |
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>.
llvm-svn: 98874
Diffstat (limited to 'clang/lib/AST/Expr.cpp')
| -rw-r--r-- | clang/lib/AST/Expr.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp index a62dbc90126..6a71e925d9b 100644 --- a/clang/lib/AST/Expr.cpp +++ b/clang/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 << '('; |

