summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CGBlocks.cpp19
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp4
2 files changed, 4 insertions, 19 deletions
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<RecordType>();
- if (hasMutableField(cast<CXXRecordDecl>(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.
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index d99230b556e..ea2b2d16d61 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -946,7 +946,9 @@ static bool DeclIsConstantGlobal(ASTContext &Context, const VarDecl *D,
if (Context.getLangOptions().CPlusPlus) {
if (const RecordType *Record
= Context.getBaseElementType(D->getType())->getAs<RecordType>())
- return ConstantInit && cast<CXXRecordDecl>(Record->getDecl())->isPOD();
+ return ConstantInit &&
+ cast<CXXRecordDecl>(Record->getDecl())->isPOD() &&
+ !cast<CXXRecordDecl>(Record->getDecl())->hasMutableFields();
}
return true;
OpenPOWER on IntegriCloud