Fixes http://llvm.org/PR7692
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109501
91177308-0d34-0410-b5e6-
96231b3b80d8
} 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 ||
--- /dev/null
+// Test this without pch.
+// RUN: %clang_cc1 -include %S/cxx-required-decls.h %s -emit-llvm -o - | FileCheck %s
+
+// Test with pch.
+// RUN: %clang_cc1 -x c++-header -emit-pch -o %t %S/cxx-required-decls.h
+// RUN: %clang_cc1 -include-pch %t %s -emit-llvm -o - | FileCheck %s
+
+// CHECK: @_ZL5globS = internal global %struct.S zeroinitializer
--- /dev/null
+// Header for PCH test cxx-required-decls.cpp
+
+struct S {
+ S();
+};
+
+static S globS;