From 61226d3fcf2c9b734f02c9ffa93b0e29c070e224 Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Fri, 13 May 2011 01:05:07 +0000 Subject: When determining whether we can make a declaration into a global constant, also consider whether it's a class type that has any mutable fields. If so, it can't be a global constant. llvm-svn: 131276 --- clang/lib/CodeGen/CGBlocks.cpp | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) (limited to 'clang/lib/CodeGen/CGBlocks.cpp') diff --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp index f26d79c0667..c6bedd28460 100644 --- a/clang/lib/CodeGen/CGBlocks.cpp +++ b/clang/lib/CodeGen/CGBlocks.cpp @@ -189,23 +189,6 @@ namespace { } } -/// Determines if the given record type has a mutable field. -static bool hasMutableField(const CXXRecordDecl *record) { - for (CXXRecordDecl::field_iterator - i = record->field_begin(), e = record->field_end(); i != e; ++i) - if ((*i)->isMutable()) - return true; - - for (CXXRecordDecl::base_class_const_iterator - i = record->bases_begin(), e = record->bases_end(); i != e; ++i) { - const RecordType *record = i->getType()->castAs(); - if (hasMutableField(cast(record->getDecl()))) - return true; - } - - return false; -} - /// Determines if the given type is safe for constant capture in C++. static bool isSafeForCXXConstantCapture(QualType type) { const RecordType *recordType = @@ -222,7 +205,7 @@ static bool isSafeForCXXConstantCapture(QualType type) { // Otherwise, we just have to make sure there aren't any mutable // fields that might have changed since initialization. - return !hasMutableField(record); + return !record->hasMutableFields(); } /// It is illegal to modify a const object after initialization. -- cgit v1.2.3