Skip to content

Commit 5ae00a7

Browse files
authored
[llvm] annotate remaining Telemetry and ToolDrivers interfaces for DLL export (#145369)
## Purpose This patch is one in a series of code-mods that annotate LLVM’s public interface for export. This patch annotates the remaining Telemetry and ToolDrivers interfaces that were missed in, or modified since, previous patches. The annotations currently have no meaningful impact on the LLVM build; however, they are a prerequisite to support an LLVM Windows DLL (shared library) build. ## Background This effort is tracked in #109483. Additional context is provided in [this discourse](https://discourse.llvm.org/t/psa-annotating-llvm-public-interface/85307), and documentation for `LLVM_ABI` and related annotations is found in the LLVM repo [here](https://github.com/llvm/llvm-project/blob/main/llvm/docs/InterfaceExportAnnotations.rst). ## Overview The bulk of these changes were generated automatically using the [Interface Definition Scanner (IDS)](https://github.com/compnerd/ids) tool, followed formatting with `git clang-format`. The following manual adjustments were also applied after running IDS: - Add `#include "llvm/Support/Compiler.h"` to files where it was not automatically added by IDS because there were no pre-existing include statements. - Add default ctor and delete the copy ctor and copy assignment operator in the `Telemetry::Manager` class. This is required because the class is now annotated with `LLVM_ABI` and cannot otherwise be fully instantiated for export. ## Validation Local builds and tests to validate cross-platform compatibility. This included llvm, clang, and lldb on the following configurations: - Windows with MSVC - Windows with Clang - Linux with GCC - Linux with Clang - Darwin with Clang
1 parent c84d620 commit 5ae00a7

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

llvm/include/llvm/Telemetry/Telemetry.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "llvm/ADT/DenseMap.h"
1818
#include "llvm/ADT/StringExtras.h"
1919
#include "llvm/ADT/StringRef.h"
20+
#include "llvm/Support/Compiler.h"
2021
#include "llvm/Support/Error.h"
2122
#include <map>
2223
#include <memory>
@@ -101,7 +102,7 @@ struct EntryKind {
101102
/// For example, The LLDB debugger can define a DebugCommandInfo subclass
102103
/// which has additional fields about the debug-command being instrumented,
103104
/// such as `CommandArguments` or `CommandName`.
104-
struct TelemetryInfo {
105+
struct LLVM_ABI TelemetryInfo {
105106
// This represents a unique-id, conventionally corresponding to
106107
// a tool's session - i.e., every time the tool starts until it exits.
107108
//
@@ -141,10 +142,15 @@ class Destination {
141142
/// and this framework.
142143
/// It is responsible for collecting telemetry data from the tool being
143144
/// monitored and transmitting the data elsewhere.
144-
class Manager {
145+
class LLVM_ABI Manager {
145146
public:
147+
Manager() = default;
146148
virtual ~Manager() = default;
147149

150+
// Explicitly non-copyable.
151+
Manager(Manager const &) = delete;
152+
Manager &operator=(Manager const &) = delete;
153+
148154
// Dispatch Telemetry data to the Destination(s).
149155
// The argument is non-const because the Manager may add or remove
150156
// data from the entry.

llvm/include/llvm/ToolDrivers/llvm-dlltool/DlltoolDriver.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@
1414
#ifndef LLVM_TOOLDRIVERS_LLVM_DLLTOOL_DLLTOOLDRIVER_H
1515
#define LLVM_TOOLDRIVERS_LLVM_DLLTOOL_DLLTOOLDRIVER_H
1616

17+
#include "llvm/Support/Compiler.h"
18+
1719
namespace llvm {
1820
template <typename T> class ArrayRef;
1921

20-
int dlltoolDriverMain(ArrayRef<const char *> ArgsArr);
22+
LLVM_ABI int dlltoolDriverMain(ArrayRef<const char *> ArgsArr);
2123
} // namespace llvm
2224

2325
#endif

llvm/include/llvm/ToolDrivers/llvm-lib/LibDriver.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,12 @@
1414
#ifndef LLVM_TOOLDRIVERS_LLVM_LIB_LIBDRIVER_H
1515
#define LLVM_TOOLDRIVERS_LLVM_LIB_LIBDRIVER_H
1616

17+
#include "llvm/Support/Compiler.h"
18+
1719
namespace llvm {
1820
template <typename T> class ArrayRef;
1921

20-
int libDriverMain(ArrayRef<const char *> ARgs);
21-
22+
LLVM_ABI int libDriverMain(ArrayRef<const char *> ARgs);
2223
}
2324

2425
#endif

0 commit comments

Comments
 (0)