aboutsummaryrefslogtreecommitdiff
path: root/lib/Frontend
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Frontend')
-rw-r--r--lib/Frontend/PCHWriterDecl.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/Frontend/PCHWriterDecl.cpp b/lib/Frontend/PCHWriterDecl.cpp
index abe2b30d1f..06266d2282 100644
--- a/lib/Frontend/PCHWriterDecl.cpp
+++ b/lib/Frontend/PCHWriterDecl.cpp
@@ -1114,6 +1114,14 @@ static bool isRequiredDecl(const Decl *D, ASTContext &Context) {
} else {
const VarDecl *VD = cast<VarDecl>(D);
+ // Structs that have non-trivial constructors or destructors must be seen.
+ if (const RecordType *RT = VD->getType()->getAs<RecordType>()) {
+ if (const CXXRecordDecl *RD = dyn_cast<CXXRecordDecl>(RT->getDecl())) {
+ if (!RD->hasTrivialConstructor() || !RD->hasTrivialDestructor())
+ return true;
+ }
+ }
+
// In C++, this doesn't need to be seen if it is marked "extern".
if (Context.getLangOptions().CPlusPlus && !VD->getInit() &&
(VD->getStorageClass() == VarDecl::Extern ||