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 | 61226d3fcf2c9b734f02c9ffa93b0e29c070e224 (patch) | |
tree | 5bdc5396f101b96a4397d98b065d0ccd1ae22571 /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | 94f9cbf9986e68cb2279e2cc4aed05876ccf0d7a (diff) | |
download | bcm5719-llvm-61226d3fcf2c9b734f02c9ffa93b0e29c070e224.tar.gz bcm5719-llvm-61226d3fcf2c9b734f02c9ffa93b0e29c070e224.zip |
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
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
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; |