return true;
}
+/// Return true if the class or any of its methods are marked dllimport.
+static bool isClassOrMethodDLLImport(const CXXRecordDecl *RD) {
+ if (RD->hasAttr<DLLImportAttr>())
+ return true;
+ for (const CXXMethodDecl *MD : RD->methods())
+ if (MD->hasAttr<DLLImportAttr>())
+ return true;
+ return false;
+}
+
static bool shouldOmitDefinition(codegenoptions::DebugInfoKind DebugKind,
bool DebugTypeExtRefs, const RecordDecl *RD,
const LangOptions &LangOpts) {
// Only emit complete debug info for a dynamic class when its vtable is
// emitted. However, Microsoft debuggers don't resolve type information
- // across DLL boundaries, so skip this optimization if the class is marked
- // dllimport.
+ // across DLL boundaries, so skip this optimization if the class or any of its
+ // methods are marked dllimport. This isn't a complete solution, since objects
+ // without any dllimport methods can be used in one DLL and constructed in
+ // another, but it is the current behavior of LimitedDebugInfo.
if (CXXDecl->hasDefinition() && CXXDecl->isDynamicClass() &&
- !CXXDecl->hasAttr<DLLImportAttr>())
+ !isClassOrMethodDLLImport(CXXDecl))
return true;
TemplateSpecializationKind Spec = TSK_Undeclared;
// be imported from a DLL. Otherwise, the debugger wouldn't be able to show the
// members.
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "OutOfLineCtor",
+// CHECK-SAME: DIFlagFwdDecl
+// CHECK-SAME: ){{$}}
+
// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "ImportedBase",
// CHECK-NOT: DIFlagFwdDecl
// CHECK-SAME: ){{$}}
+// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "ImportedMethod",
+// CHECK-NOT: DIFlagFwdDecl
+// CHECK-SAME: ){{$}}
+
+struct OutOfLineCtor {
+ OutOfLineCtor();
+ virtual void Foo();
+};
+
struct __declspec(dllimport) ImportedBase {
ImportedBase();
virtual void Foo();
struct DerivedFromImported : public ImportedBase {};
+struct ImportedMethod {
+ ImportedMethod();
+ virtual void Foo();
+ static void __declspec(dllimport) create();
+};
+
int main() {
+ OutOfLineCtor o;
DerivedFromImported d;
+ ImportedMethod m;
}