From: Daniel Dunbar Date: Sat, 1 Aug 2009 23:40:20 +0000 (+0000) Subject: Avoid accessing invalid std::vector element; this makes clang X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0908c333cc251540dfcf17ac4a9b07ea6da27aaf;p=clang Avoid accessing invalid std::vector element; this makes clang ENABLE_EXPENSIVE_CHECKS clean on x86_64-.*-darwin10. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77831 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/DeclCXX.cpp b/lib/AST/DeclCXX.cpp index cc481be6ba..4a2f799b27 100644 --- a/lib/AST/DeclCXX.cpp +++ b/lib/AST/DeclCXX.cpp @@ -348,8 +348,9 @@ CXXMethodDecl::method_iterator CXXMethodDecl::begin_overridden_methods() const { return 0; OverriddenMethodsMapTy::iterator it = OverriddenMethods->find(this); - if (it == OverriddenMethods->end()) + if (it == OverriddenMethods->end() || it->second->empty()) return 0; + return &(*it->second)[0]; } @@ -358,7 +359,7 @@ CXXMethodDecl::method_iterator CXXMethodDecl::end_overridden_methods() const { return 0; OverriddenMethodsMapTy::iterator it = OverriddenMethods->find(this); - if (it == OverriddenMethods->end()) + if (it == OverriddenMethods->end() || it->second->empty()) return 0; return &(*it->second)[it->second->size()];