Skip to content

Commit 1e40254

Browse files
committed
[lldb] Move SBLanguages.h out of API tree
This patch moves `SBLanguages.h` out of the API tree. This file gets generated at build time using DWARF table-gen file and contains an enumeration of the DWARF supported source language names and there respective code/identifier. Since this is an enum, this shouldn't be part of the API tree but rather it should be included in the `lldb-enumeration` header. Also, that enum was used in internal methods in `lldb_private` by down-casting the enum value type to an `uint16_t`. This patch changes that by making those internal methods use the enum type. This should address the feedbacks from #111907. Signed-off-by: Med Ismail Bennani <[email protected]>
1 parent 706e710 commit 1e40254

File tree

17 files changed

+53
-47
lines changed

17 files changed

+53
-47
lines changed

lldb/bindings/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ file(GLOB_RECURSE SWIG_SOURCES *.swig)
33
file(GLOB SWIG_HEADERS
44
${LLDB_SOURCE_DIR}/include/lldb/API/*.h
55
${LLDB_SOURCE_DIR}/include/lldb/*.h
6-
${LLDB_BINARY_DIR}/include/lldb/API/SBLanguages.h
6+
${LLDB_BINARY_DIR}/include/lldb/SourceLanguageNames.h
77
)
88
file(GLOB SWIG_PRIVATE_HEADERS
99
${LLDB_SOURCE_DIR}/include/lldb/lldb-private*.h

lldb/bindings/headers.swig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
#include "lldb/API/SBHostOS.h"
4040
#include "lldb/API/SBInstruction.h"
4141
#include "lldb/API/SBInstructionList.h"
42-
#include "lldb/API/SBLanguages.h"
4342
#include "lldb/API/SBLanguageRuntime.h"
4443
#include "lldb/API/SBLaunchInfo.h"
4544
#include "lldb/API/SBLineEntry.h"

lldb/bindings/interfaces.swig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@
120120
%include "lldb/API/SBHostOS.h"
121121
%include "lldb/API/SBInstruction.h"
122122
%include "lldb/API/SBInstructionList.h"
123-
%include "lldb/API/SBLanguages.h"
124123
%include "lldb/API/SBLanguageRuntime.h"
125124
%include "lldb/API/SBLaunchInfo.h"
126125
%include "lldb/API/SBLineEntry.h"

lldb/cmake/modules/LLDBFramework.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ endif()
7171
# At configuration time, collect headers for the framework bundle and copy them
7272
# into a staging directory. Later we can copy over the entire folder.
7373
file(GLOB public_headers ${LLDB_SOURCE_DIR}/include/lldb/API/*.h)
74-
set(generated_public_headers ${LLDB_OBJ_DIR}/include/lldb/API/SBLanguages.h)
74+
set(generated_public_headers ${LLDB_OBJ_DIR}/include/lldb/SourceLanguageNames.h)
7575
file(GLOB root_public_headers ${LLDB_SOURCE_DIR}/include/lldb/lldb-*.h)
7676
file(GLOB root_private_headers ${LLDB_SOURCE_DIR}/include/lldb/lldb-private*.h)
7777
list(REMOVE_ITEM root_public_headers ${root_private_headers})

lldb/include/lldb/API/LLDB.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@
4242
#include "lldb/API/SBInstruction.h"
4343
#include "lldb/API/SBInstructionList.h"
4444
#include "lldb/API/SBLanguageRuntime.h"
45-
#include "lldb/API/SBLanguages.h"
4645
#include "lldb/API/SBLaunchInfo.h"
4746
#include "lldb/API/SBLineEntry.h"
4847
#include "lldb/API/SBListener.h"

lldb/include/lldb/API/SBExpressionOptions.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#define LLDB_API_SBEXPRESSIONOPTIONS_H
1111

1212
#include "lldb/API/SBDefines.h"
13-
#include "lldb/API/SBLanguages.h"
1413

1514
#include <vector>
1615

@@ -71,7 +70,7 @@ class LLDB_API SBExpressionOptions {
7170
/// Set the language using a pair of language code and version as
7271
/// defined by the DWARF 6 specification.
7372
/// WARNING: These codes may change until DWARF 6 is finalized.
74-
void SetLanguage(lldb::SBSourceLanguageName name, uint32_t version);
73+
void SetLanguage(lldb::SourceLanguageName name, uint32_t version);
7574

7675
#ifndef SWIG
7776
void SetCancelCallback(lldb::ExpressionCancelCallback callback, void *baton);

lldb/include/lldb/Target/Target.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ class EvaluateExpressionOptions {
324324
/// Set the language using a pair of language code and version as
325325
/// defined by the DWARF 6 specification.
326326
/// WARNING: These codes may change until DWARF 6 is finalized.
327-
void SetLanguage(uint16_t name, uint32_t version) {
327+
void SetLanguage(lldb::SourceLanguageName name, uint32_t version) {
328328
m_language = SourceLanguage(name, version);
329329
}
330330

lldb/include/lldb/lldb-enumerations.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
#include <cstdint>
1313
#include <type_traits>
1414

15+
#include "lldb/SourceLanguageNames.h"
16+
1517
#ifndef SWIG
1618
// Macro to enable bitmask operations on an enum. Without this, Enum | Enum
1719
// gets promoted to an int, so you have to say Enum a = Enum(eFoo | eBar). If

lldb/include/lldb/lldb-private-types.h

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,18 +103,19 @@ struct RegisterSet {
103103
struct SourceLanguage {
104104
SourceLanguage() = default;
105105
SourceLanguage(lldb::LanguageType language_type);
106-
SourceLanguage(uint16_t name, uint32_t version)
106+
SourceLanguage(lldb::SourceLanguageName name, uint32_t version)
107107
: name(name), version(version) {}
108-
SourceLanguage(std::optional<std::pair<uint16_t, uint32_t>> name_vers)
109-
: name(name_vers ? name_vers->first : 0),
108+
SourceLanguage(
109+
std::optional<std::pair<lldb::SourceLanguageName, uint32_t>> name_vers)
110+
: name(name_vers ? std::optional(name_vers->first) : std::nullopt),
110111
version(name_vers ? name_vers->second : 0) {}
111-
operator bool() const { return name > 0; }
112+
operator bool() const { return name.has_value(); }
112113
lldb::LanguageType AsLanguageType() const;
113114
llvm::StringRef GetDescription() const;
114115
bool IsC() const;
115116
bool IsObjC() const;
116117
bool IsCPlusPlus() const;
117-
uint16_t name = 0;
118+
std::optional<lldb::SourceLanguageName> name;
118119
uint32_t version = 0;
119120
};
120121

lldb/scripts/generate-sbapi-dwarf-enum.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,21 @@
55
import os
66

77
HEADER = """\
8-
//===-- SBLanguages.h -----------------------------------------*- C++ -*-===//
8+
//===-- SourceLanguageNames.h -----------------------------------*- C++ -*-===//
99
//
1010
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
1111
// See https://llvm.org/LICENSE.txt for license information.
1212
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
1313
//
1414
//===----------------------------------------------------------------------===//
1515
16-
#ifndef LLDB_API_SBLANGUAGE_H
17-
#define LLDB_API_SBLANGUAGE_H
16+
#ifndef LLDB_SOURCELANGUAGENAMES_H
17+
#define LLDB_SOURCELANGUAGENAMES_H
1818
1919
namespace lldb {
20-
/// Used by \\ref SBExpressionOptions.
2120
/// These enumerations use the same language enumerations as the DWARF
2221
/// specification for ease of use and consistency.
23-
enum SBSourceLanguageName : uint16_t {
22+
enum SourceLanguageName {
2423
"""
2524

2625
FOOTER = """\

0 commit comments

Comments
 (0)