diff options
author | Sean Callanan <scallanan@apple.com> | 2016-03-03 01:21:28 +0000 |
---|---|---|
committer | Sean Callanan <scallanan@apple.com> | 2016-03-03 01:21:28 +0000 |
commit | bb33f58a1a48021165619af088050f8576d41576 (patch) | |
tree | 74b11d0a9c53077d19389e3e9a74d1d518c2e9da | |
parent | ae27b2380fe0b7fed17766ef8cba0683706cfc48 (diff) | |
download | bcm5719-llvm-bb33f58a1a48021165619af088050f8576d41576.tar.gz bcm5719-llvm-bb33f58a1a48021165619af088050f8576d41576.zip |
Fixed a problem where the ASTImporter mishandled in-class initializers.
Previously, the ASTImporter, when copying a FieldDecl, would make the
new FieldDecl use the exact same in-class initializer as the original
FieldDecl, which is a problem since the initializer is in the wrong AST.
The initializer must be imported, just like all the other parts of the
field.
Doug Gregor reviewed this fix.
<rdar://problem/24943405>
llvm-svn: 262572
-rw-r--r-- | clang/lib/AST/ASTImporter.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp index d6b9424fb4d..a21a7e56fcf 100644 --- a/clang/lib/AST/ASTImporter.cpp +++ b/clang/lib/AST/ASTImporter.cpp @@ -3038,8 +3038,13 @@ Decl *ASTNodeImporter::VisitFieldDecl(FieldDecl *D) { D->getInClassInitStyle()); ToField->setAccess(D->getAccess()); ToField->setLexicalDeclContext(LexicalDC); - if (ToField->hasInClassInitializer()) - ToField->setInClassInitializer(D->getInClassInitializer()); + if (Expr *FromInitializer = ToField->getInClassInitializer()) { + Expr *ToInitializer = Importer.Import(FromInitializer); + if (ToInitializer) + ToField->setInClassInitializer(ToInitializer); + else + return nullptr; + } ToField->setImplicit(D->isImplicit()); Importer.Imported(D, ToField); LexicalDC->addDeclInternal(ToField); |