Skip to content

Commit 364935f

Browse files
committed
PR feedback
1 parent daaadcb commit 364935f

File tree

1 file changed

+20
-8
lines changed

1 file changed

+20
-8
lines changed

llvm/docs/InterfaceExportAnnotations.rst

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -288,19 +288,26 @@ method is declared ``virtual`` or ``override``.
288288
member-level annotations are combined on a class, it will fail compilation on
289289
Windows.
290290

291-
If annotating a type with ``LLVM_ABI`` causes compilation issues such as those
292-
described
293-
`here <https://devblogs.microsoft.com/oldnewthing/20190927-00/?p=102932>`__,
294-
the class may require minor modification. Often, explicitly deleting the copy
295-
constructor and copy assignment operator will resolve the issue. It may also
296-
require an explicitly defaulted constructor.
291+
Compilation Errors
292+
++++++++++++++++++
293+
Annotating a class with ``LLVM_ABI`` causes the compiler to fully instantiate
294+
the class at compile time. This requires exporting every method that could be
295+
potentially used by a client even though no existing clients may actually use
296+
them. This can cause compilation errors that were not previously present.
297+
298+
The most common type of error occurs when the compiler attempts to instantiate
299+
and export a class' implicit copy constructor and copy assignment operator. If
300+
the class contains move-only members that cannot be copied (``std::unique_ptr``
301+
for example), the compiler will fail to instantiate these implicit
302+
methods.
303+
304+
This problem is easily addressed by explicitly deleting the class' copy
305+
constructor and copy assignment operator:
297306

298307
.. code:: cpp
299308
300309
#include "llvm/Support/Compiler.h"
301310
302-
#include <vector>
303-
304311
class LLVM_ABI ExportedClass {
305312
public:
306313
ExportedClass() = default;
@@ -310,6 +317,11 @@ require an explicitly defaulted constructor.
310317
ExportedClass& operator=(ExportedClass const&) = delete;
311318
};
312319
320+
We know this modification is harmless because any clients attempting to use
321+
these methods already would fail to compile. For a more detailed explanation,
322+
see `this Microsoft dev blog
323+
<https://devblogs.microsoft.com/oldnewthing/20190927-00/?p=102932>`__.
324+
313325
Templates
314326
~~~~~~~~~
315327
Most template classes are entirely header-defined and do not need to be exported

0 commit comments

Comments
 (0)