From: Douglas Gregor Date: Tue, 23 Dec 2008 21:31:30 +0000 (+0000) Subject: When determining whether a class type has a const copy constructor, be X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fdfab6b5ee678cd4b6a1c6d01c46ea5d0e3153ed;p=clang When determining whether a class type has a const copy constructor, be sure to look at all of the results returned by name lookup. Fixes git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61388 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/DeclCXX.cpp b/lib/AST/DeclCXX.cpp index 3faf5ac0c7..d213385d91 100644 --- a/lib/AST/DeclCXX.cpp +++ b/lib/AST/DeclCXX.cpp @@ -14,6 +14,7 @@ #include "clang/AST/DeclCXX.h" #include "clang/AST/ASTContext.h" #include "clang/Basic/IdentifierTable.h" +#include "llvm/ADT/STLExtras.h" using namespace clang; //===----------------------------------------------------------------------===// @@ -80,24 +81,14 @@ bool CXXRecordDecl::hasConstCopyConstructor(ASTContext &Context) const { = Context.DeclarationNames.getCXXConstructorName( Context.getCanonicalType(ClassType)); unsigned TypeQuals; - DeclContext::lookup_const_result Lookup - = this->lookup(Context, ConstructorName); - if (Lookup.first == Lookup.second) - return false; - else if (OverloadedFunctionDecl *Constructors - = dyn_cast(*Lookup.first)) { - for (OverloadedFunctionDecl::function_const_iterator Con - = Constructors->function_begin(); - Con != Constructors->function_end(); ++Con) { + DeclContext::lookup_const_iterator Con, ConEnd; + for (llvm::tie(Con, ConEnd) = this->lookup(Context, ConstructorName); + Con != ConEnd; ++Con) { if (cast(*Con)->isCopyConstructor(Context, TypeQuals) && (TypeQuals & QualType::Const) != 0) return true; - } - } else if (CXXConstructorDecl *Constructor - = dyn_cast(*Lookup.first)) { - return Constructor->isCopyConstructor(Context, TypeQuals) && - (TypeQuals & QualType::Const) != 0; } + return false; }