diff options
author | Reid Kleckner <rnk@google.com> | 2016-09-09 16:27:04 +0000 |
---|---|---|
committer | Reid Kleckner <rnk@google.com> | 2016-09-09 16:27:04 +0000 |
commit | c9404e103935abbada1a13fc0861247051538c23 (patch) | |
tree | eb7a290d8f6633155762252f111b9778ab3eafe0 /clang/lib/CodeGen/CGDebugInfo.cpp | |
parent | 5aea5653b39bb54c675a8b6729171f2069ed4238 (diff) | |
download | bcm5719-llvm-c9404e103935abbada1a13fc0861247051538c23.tar.gz bcm5719-llvm-c9404e103935abbada1a13fc0861247051538c23.zip |
[codeview] Extend the heuristic for detecting classes imported from DLLs
If a dynamic class contains a dllimport method, then assume the class
may not be constructed in this DLL, and therefore the vtable will live
in a different PDB.
This heuristic is still incomplete, and will miss things like abstract
base classes that are only constructed on one side of the DLL interface.
That said, this heuristic does detect some cases that are currently
problematic, and may be useful to other projects that don't use many
DLLs.
llvm-svn: 281053
Diffstat (limited to 'clang/lib/CodeGen/CGDebugInfo.cpp')
-rw-r--r-- | clang/lib/CodeGen/CGDebugInfo.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index dc0ca38b32c..71377224461 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -1707,6 +1707,16 @@ static bool isDefinedInClangModule(const RecordDecl *RD) { 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) { @@ -1729,10 +1739,12 @@ static bool shouldOmitDefinition(codegenoptions::DebugInfoKind DebugKind, // 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; |