Skip to content

Commit a0dd2dd

Browse files
authored
merge main into amd-staging (llvm#2108)
2 parents 539ce7c + 4e6f55e commit a0dd2dd

40 files changed

+2180
-125
lines changed

clang/lib/CodeGen/CGBlocks.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ CGBlockInfo::CGBlockInfo(const BlockDecl *block, StringRef name)
4040

4141
// Skip asm prefix, if any. 'name' is usually taken directly from
4242
// the mangled name of the enclosing function.
43-
if (!name.empty() && name[0] == '\01')
44-
name = name.substr(1);
43+
name.consume_front("\01");
4544
}
4645

4746
// Anchor the vtable to this translation unit.

clang/lib/CodeGen/CGDebugInfo.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4554,8 +4554,7 @@ void CGDebugInfo::emitFunctionStart(GlobalDecl GD, SourceLocation Loc,
45544554

45554555
Flags |= llvm::DINode::FlagPrototyped;
45564556
}
4557-
if (Name.starts_with("\01"))
4558-
Name = Name.substr(1);
4557+
Name.consume_front("\01");
45594558

45604559
assert((!D || !isa<VarDecl>(D) ||
45614560
GD.getDynamicInitKind() != DynamicInitKind::NoStub) &&
@@ -4644,8 +4643,7 @@ void CGDebugInfo::EmitFunctionDecl(GlobalDecl GD, SourceLocation Loc,
46444643
} else {
46454644
llvm_unreachable("not a function or ObjC method");
46464645
}
4647-
if (!Name.empty() && Name[0] == '\01')
4648-
Name = Name.substr(1);
4646+
Name.consume_front("\01");
46494647

46504648
if (D->isImplicit()) {
46514649
Flags |= llvm::DINode::FlagArtificial;

clang/lib/CodeGen/CGExpr.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3388,8 +3388,7 @@ LValue CodeGenFunction::EmitPredefinedLValue(const PredefinedExpr *E) {
33883388
auto SL = E->getFunctionName();
33893389
assert(SL != nullptr && "No StringLiteral name in PredefinedExpr");
33903390
StringRef FnName = CurFn->getName();
3391-
if (FnName.starts_with("\01"))
3392-
FnName = FnName.substr(1);
3391+
FnName.consume_front("\01");
33933392
StringRef NameItems[] = {
33943393
PredefinedExpr::getIdentKindName(E->getIdentKind()), FnName};
33953394
std::string GVName = llvm::join(NameItems, NameItems + 2, ".");

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4068,11 +4068,7 @@ namespace {
40684068
return false;
40694069
std::string BuiltinNameStr = BI.getName(BuiltinID);
40704070
StringRef BuiltinName = BuiltinNameStr;
4071-
if (BuiltinName.starts_with("__builtin_") &&
4072-
Name == BuiltinName.slice(strlen("__builtin_"), StringRef::npos)) {
4073-
return true;
4074-
}
4075-
return false;
4071+
return BuiltinName.consume_front("__builtin_") && Name == BuiltinName;
40764072
}
40774073

40784074
bool VisitStmt(const Stmt *S) {

clang/lib/Driver/ToolChains/Darwin.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1411,8 +1411,8 @@ StringRef Darwin::getSDKName(StringRef isysroot) {
14111411
auto EndSDK = llvm::sys::path::rend(isysroot);
14121412
for (auto IT = BeginSDK; IT != EndSDK; ++IT) {
14131413
StringRef SDK = *IT;
1414-
if (SDK.ends_with(".sdk"))
1415-
return SDK.slice(0, SDK.size() - 4);
1414+
if (SDK.consume_back(".sdk"))
1415+
return SDK;
14161416
}
14171417
return "";
14181418
}

clang/utils/TableGen/ClangDiagnosticsEmitter.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,7 +1089,7 @@ Piece *DiagnosticTextBuilder::DiagText::parseDiagText(StringRef &Text,
10891089

10901090
if (End) {
10911091
Parsed.push_back(New<TextPiece>(Text.slice(0, End), "diagtext"));
1092-
Text = Text.slice(End, StringRef::npos);
1092+
Text = Text.substr(End);
10931093
if (Text.empty())
10941094
break;
10951095
}
@@ -1103,7 +1103,7 @@ Piece *DiagnosticTextBuilder::DiagText::parseDiagText(StringRef &Text,
11031103
// Extract the (optional) modifier.
11041104
size_t ModLength = Text.find_first_of("0123456789<{");
11051105
StringRef Modifier = Text.slice(0, ModLength);
1106-
Text = Text.slice(ModLength, StringRef::npos);
1106+
Text = Text.substr(ModLength);
11071107
ModifierType ModType = StringSwitch<ModifierType>{Modifier}
11081108
.Case("select", MT_Select)
11091109
.Case("enum_select", MT_EnumSelect)
@@ -1154,7 +1154,7 @@ Piece *DiagnosticTextBuilder::DiagText::parseDiagText(StringRef &Text,
11541154
Text = Text.drop_front(); // Drop '<'
11551155
size_t EnumNameLen = Text.find_first_of('>');
11561156
EnumSelect->EnumName = Text.slice(0, EnumNameLen);
1157-
Text = Text.slice(EnumNameLen, StringRef::npos);
1157+
Text = Text.substr(EnumNameLen);
11581158
ExpectAndConsume(">");
11591159

11601160
if (Text[0] != '{')
@@ -1169,7 +1169,7 @@ Piece *DiagnosticTextBuilder::DiagText::parseDiagText(StringRef &Text,
11691169
Text = Text.drop_front(); // '%'
11701170
size_t OptionNameLen = Text.find_first_of("{");
11711171
EnumSelect->OptionEnumNames.push_back(Text.slice(0, OptionNameLen));
1172-
Text = Text.slice(OptionNameLen, StringRef::npos);
1172+
Text = Text.substr(OptionNameLen);
11731173
} else {
11741174
EnumSelect->OptionEnumNames.push_back({});
11751175
}
@@ -1206,7 +1206,7 @@ Piece *DiagnosticTextBuilder::DiagText::parseDiagText(StringRef &Text,
12061206
assert(!Text.empty());
12071207
Plural->OptionPrefixes.push_back(
12081208
New<TextPiece>(Text.slice(0, End), "diagtext"));
1209-
Text = Text.slice(End, StringRef::npos);
1209+
Text = Text.substr(End);
12101210
Plural->Options.push_back(
12111211
parseDiagText(Text, StopAt::PipeOrCloseBrace));
12121212
assert(!Text.empty() && "malformed %plural");

lldb/test/API/functionalities/completion/TestCompletion.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -334,22 +334,22 @@ def test_settings_replace_target_ru(self):
334334
"settings replace target.ru", "settings replace target.run-args"
335335
)
336336

337-
def test_settings_show_term(self):
337+
def test_settings_show_term_width(self):
338338
self.complete_from_to("settings show term-w", "settings show term-width")
339339

340-
def test_settings_list_term(self):
340+
def test_settings_list_term_width(self):
341341
self.complete_from_to("settings list term-w", "settings list term-width")
342342

343-
def test_settings_show_term(self):
343+
def test_settings_show_term_height(self):
344344
self.complete_from_to("settings show term-h", "settings show term-height")
345345

346-
def test_settings_list_term(self):
346+
def test_settings_list_term_height(self):
347347
self.complete_from_to("settings list term-h", "settings list term-height")
348348

349-
def test_settings_remove_term(self):
349+
def test_settings_remove_term_width(self):
350350
self.complete_from_to("settings remove term-w", "settings remove term-width")
351351

352-
def test_settings_remove_term(self):
352+
def test_settings_remove_term_height(self):
353353
self.complete_from_to("settings remove term-h", "settings remove term-height")
354354

355355
def test_settings_s(self):

lldb/tools/lldb-dap/CMakeLists.txt

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,11 @@
1-
if(APPLE)
2-
configure_file(
3-
${CMAKE_CURRENT_SOURCE_DIR}/lldb-dap-Info.plist.in
4-
${CMAKE_CURRENT_BINARY_DIR}/lldb-dap-Info.plist
5-
)
6-
# Inline info plist in binary (use target_link_options for this as soon as CMake 3.13 is available)
7-
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-sectcreate,__TEXT,__info_plist,${CMAKE_CURRENT_BINARY_DIR}/lldb-dap-Info.plist")
8-
endif()
9-
101
# We need to include the llvm components we depend on manually, as liblldb does
112
# not re-export those.
123
set(LLVM_LINK_COMPONENTS Support)
134
set(LLVM_TARGET_DEFINITIONS Options.td)
145
tablegen(LLVM Options.inc -gen-opt-parser-defs)
156
add_public_tablegen_target(LLDBDAPOptionsTableGen)
16-
add_lldb_tool(lldb-dap
17-
lldb-dap.cpp
7+
8+
add_lldb_library(lldbDAP
189
Breakpoint.cpp
1910
BreakpointBase.cpp
2011
DAP.cpp
@@ -85,10 +76,11 @@ add_lldb_tool(lldb-dap
8576
Support
8677
)
8778

88-
target_include_directories(lldb-dap PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
79+
target_include_directories(lldbDAP
80+
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
8981

9082
if(LLDB_DAP_WELCOME_MESSAGE)
91-
target_compile_definitions(lldb-dap
83+
target_compile_definitions(lldbDAP
9284
PRIVATE
9385
-DLLDB_DAP_WELCOME_MESSAGE=\"${LLDB_DAP_WELCOME_MESSAGE}\")
9486
endif()
@@ -105,3 +97,5 @@ if(LLDB_BUILD_FRAMEWORK)
10597
"@loader_path/../../Library/PrivateFrameworks"
10698
)
10799
endif()
100+
101+
add_subdirectory(tool)

lldb/tools/lldb-dap/JSONUtils.cpp

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -99,19 +99,6 @@ std::optional<bool> GetBoolean(const llvm::json::Object *obj,
9999
return std::nullopt;
100100
}
101101

102-
std::optional<int64_t> GetSigned(const llvm::json::Object &obj,
103-
llvm::StringRef key) {
104-
return obj.getInteger(key);
105-
}
106-
107-
std::optional<int64_t> GetSigned(const llvm::json::Object *obj,
108-
llvm::StringRef key) {
109-
if (obj == nullptr)
110-
return std::nullopt;
111-
112-
return GetSigned(*obj, key);
113-
}
114-
115102
bool ObjectContainsKey(const llvm::json::Object &obj, llvm::StringRef key) {
116103
return obj.find(key) != obj.end();
117104
}
@@ -263,7 +250,7 @@ void FillResponse(const llvm::json::Object &request,
263250
response.try_emplace("seq", (int64_t)0);
264251
EmplaceSafeString(response, "command",
265252
GetString(request, "command").value_or(""));
266-
const int64_t seq = GetSigned(request, "seq").value_or(0);
253+
const uint64_t seq = GetInteger<uint64_t>(request, "seq").value_or(0);
267254
response.try_emplace("request_seq", seq);
268255
response.try_emplace("success", true);
269256
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
add_lldb_tool(lldb-dap
2+
lldb-dap.cpp
3+
4+
LINK_LIBS
5+
lldbDAP
6+
)
7+
8+
if(APPLE)
9+
configure_file(
10+
${CMAKE_CURRENT_SOURCE_DIR}/lldb-dap-Info.plist.in
11+
${CMAKE_CURRENT_BINARY_DIR}/lldb-dap-Info.plist
12+
)
13+
target_link_options(lldb-dap
14+
PRIVATE LINKER:-sectcreate,__TEXT,__info_plist,${CMAKE_CURRENT_BINARY_DIR}/lldb-dap-Info.plist)
15+
endif()
16+
17+
if(LLDB_BUILD_FRAMEWORK)
18+
# In the build-tree, we know the exact path to the framework directory.
19+
# The installed framework can be in different locations.
20+
lldb_setup_rpaths(lldb-dap
21+
BUILD_RPATH
22+
"${LLDB_FRAMEWORK_ABSOLUTE_BUILD_DIR}"
23+
INSTALL_RPATH
24+
"@loader_path/../../../SharedFrameworks"
25+
"@loader_path/../../System/Library/PrivateFrameworks"
26+
"@loader_path/../../Library/PrivateFrameworks"
27+
)
28+
endif()

lldb/unittests/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@ endfunction()
4848

4949
add_subdirectory(TestingSupport)
5050
if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
51-
# FIXME: APITests.exe is not a valid googletest binary.
51+
# FIXME: Tests linking against libLLDB don't work on Windows.
5252
add_subdirectory(API)
53+
add_subdirectory(DAP)
5354
endif()
5455
add_subdirectory(Breakpoint)
5556
add_subdirectory(Callback)

lldb/unittests/DAP/CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
add_lldb_unittest(DAPTests
2+
JSONUtilsTest.cpp
3+
LLDBUtilsTest.cpp
4+
5+
LINK_LIBS
6+
lldbDAP
7+
LINK_COMPONENTS
8+
Support
9+
)

0 commit comments

Comments
 (0)