diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-05-13 01:05:07 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-05-13 01:05:07 +0000 |
commit | 2bb110125e0e5adb7c1c65d12adfa34151ca1c47 (patch) | |
tree | 1d4cb0d79515f17727be015af2aa4d6a2936f95d /lib/CodeGen/CodeGenModule.cpp | |
parent | 7880bc34fd5818d8f1eb827fdce136c1de643ab5 (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@131276 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | lib/CodeGen/CodeGenModule.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index d99230b556..ea2b2d16d6 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/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; |