Skip to content

Commit 01ad97d

Browse files
authored
Merge pull request #9442 from JDevlieghere/jdevlieghere/rdar/112040718
🍒 Cherrypicks to stop compiling LLDB with `-Wno-deprecated-declarations`
2 parents 9c753b7 + b9c560e commit 01ad97d

File tree

8 files changed

+52
-79
lines changed

8 files changed

+52
-79
lines changed

lldb/include/lldb/Host/Editline.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,23 @@
5757

5858
#include "llvm/ADT/FunctionExtras.h"
5959

60+
#if defined(__clang__) && defined(__has_warning)
61+
#if __has_warning("-Wdeprecated-declarations")
62+
#define LLDB_DEPRECATED_WARNING_DISABLE \
63+
_Pragma("clang diagnostic push") \
64+
_Pragma("clang diagnostic ignored \"-Wdeprecated-declarations\"")
65+
#define LLDB_DEPRECATED_WARNING_RESTORE _Pragma("clang diagnostic pop")
66+
#endif
67+
#elif defined(__GNUC__) && __GNUC__ > 6
68+
#define LLDB_DEPRECATED_WARNING_DISABLE \
69+
_Pragma("GCC diagnostic push") \
70+
_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
71+
#define LLDB_DEPRECATED_WARNING_RESTORE _Pragma("GCC diagnostic pop")
72+
#else
73+
#define LLDB_DEPRECATED_WARNING_DISABLE
74+
#define LLDB_DEPRECATED_WARNING_RESTORE
75+
#endif
76+
6077
namespace lldb_private {
6178
namespace line_editor {
6279

@@ -367,7 +384,9 @@ class Editline {
367384
void SetGetCharacterFunction(EditlineGetCharCallbackType callbackFn);
368385

369386
#if LLDB_EDITLINE_USE_WCHAR
387+
LLDB_DEPRECATED_WARNING_DISABLE
370388
std::wstring_convert<std::codecvt_utf8<wchar_t>> m_utf8conv;
389+
LLDB_DEPRECATED_WARNING_RESTORE
371390
#endif
372391
::EditLine *m_editline = nullptr;
373392
EditlineHistorySP m_history_sp;

lldb/source/Host/common/Editline.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1574,7 +1574,9 @@ bool Editline::CompleteCharacter(char ch, EditLineGetCharType &out) {
15741574
out = (unsigned char)ch;
15751575
return true;
15761576
#else
1577+
LLDB_DEPRECATED_WARNING_DISABLE
15771578
std::codecvt_utf8<wchar_t> cvt;
1579+
LLDB_DEPRECATED_WARNING_RESTORE
15781580
llvm::SmallString<4> input;
15791581
for (;;) {
15801582
const char *from_next;

lldb/source/Plugins/ExpressionParser/Clang/IRDynamicChecks.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,8 @@ class ValidPointerChecker : public Instrumenter {
331331
return false;
332332

333333
// Insert an instruction to call the helper with the result
334-
CallInst::Create(m_valid_pointer_check_func, dereferenced_ptr, "", inst);
334+
CallInst::Create(m_valid_pointer_check_func, dereferenced_ptr, "",
335+
inst->getIterator());
335336

336337
return true;
337338
}
@@ -418,7 +419,7 @@ class ObjcObjectChecker : public Instrumenter {
418419

419420
ArrayRef<llvm::Value *> args(arg_array, 2);
420421

421-
CallInst::Create(m_objc_object_check_func, args, "", inst);
422+
CallInst::Create(m_objc_object_check_func, args, "", inst->getIterator());
422423

423424
return true;
424425
}

lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -381,8 +381,8 @@ bool IRForTarget::CreateResultVariable(llvm::Function &llvm_function) {
381381

382382
Constant *initializer = result_global->getInitializer();
383383

384-
StoreInst *synthesized_store =
385-
new StoreInst(initializer, new_result_global, first_entry_instruction);
384+
StoreInst *synthesized_store = new StoreInst(
385+
initializer, new_result_global, first_entry_instruction->getIterator());
386386

387387
LLDB_LOG(log, "Synthesized result store \"{0}\"\n",
388388
PrintValue(synthesized_store));
@@ -416,9 +416,8 @@ bool IRForTarget::RewriteObjCConstString(llvm::GlobalVariable *ns_str,
416416
"CFStringCreateWithBytes");
417417

418418
bool missing_weak = false;
419-
CFStringCreateWithBytes_addr =
420-
m_execution_unit.FindSymbol(g_CFStringCreateWithBytes_str,
421-
missing_weak);
419+
CFStringCreateWithBytes_addr = m_execution_unit.FindSymbol(
420+
g_CFStringCreateWithBytes_str, missing_weak);
422421
if (CFStringCreateWithBytes_addr == LLDB_INVALID_ADDRESS || missing_weak) {
423422
LLDB_LOG(log, "Couldn't find CFStringCreateWithBytes in the target");
424423

@@ -517,7 +516,8 @@ bool IRForTarget::RewriteObjCConstString(llvm::GlobalVariable *ns_str,
517516
m_CFStringCreateWithBytes, CFSCWB_arguments,
518517
"CFStringCreateWithBytes",
519518
llvm::cast<Instruction>(
520-
m_entry_instruction_finder.GetValue(function)));
519+
m_entry_instruction_finder.GetValue(function))
520+
->getIterator());
521521
});
522522

523523
if (!UnfoldConstant(ns_str, nullptr, CFSCWB_Caller, m_entry_instruction_finder,
@@ -824,7 +824,7 @@ bool IRForTarget::RewriteObjCSelector(Instruction *selector_load) {
824824

825825
CallInst *srN_call =
826826
CallInst::Create(m_sel_registerName, _objc_meth_var_name_,
827-
"sel_registerName", selector_load);
827+
"sel_registerName", selector_load->getIterator());
828828

829829
// Replace the load with the call in all users
830830

@@ -917,8 +917,9 @@ bool IRForTarget::RewritePersistentAlloc(llvm::Instruction *persistent_alloc) {
917917
// Now, since the variable is a pointer variable, we will drop in a load of
918918
// that pointer variable.
919919

920-
LoadInst *persistent_load = new LoadInst(persistent_global->getValueType(),
921-
persistent_global, "", alloc);
920+
LoadInst *persistent_load =
921+
new LoadInst(persistent_global->getValueType(), persistent_global, "",
922+
alloc->getIterator());
922923

923924
LLDB_LOG(log, "Replacing \"{0}\" with \"{1}\"", PrintValue(alloc),
924925
PrintValue(persistent_load));
@@ -1344,8 +1345,10 @@ bool IRForTarget::UnfoldConstant(Constant *old_constant,
13441345

13451346
return new BitCastInst(
13461347
value_maker.GetValue(function), constant_expr->getType(),
1347-
"", llvm::cast<Instruction>(
1348-
entry_instruction_finder.GetValue(function)));
1348+
"",
1349+
llvm::cast<Instruction>(
1350+
entry_instruction_finder.GetValue(function))
1351+
->getIterator());
13491352
});
13501353

13511354
if (!UnfoldConstant(constant_expr, llvm_function, bit_cast_maker,
@@ -1379,7 +1382,8 @@ bool IRForTarget::UnfoldConstant(Constant *old_constant,
13791382
return GetElementPtrInst::Create(
13801383
gep->getSourceElementType(), ptr, indices, "",
13811384
llvm::cast<Instruction>(
1382-
entry_instruction_finder.GetValue(function)));
1385+
entry_instruction_finder.GetValue(function))
1386+
->getIterator());
13831387
});
13841388

13851389
if (!UnfoldConstant(constant_expr, llvm_function,
@@ -1559,12 +1563,14 @@ bool IRForTarget::ReplaceVariables(Function &llvm_function) {
15591563
Type *int8Ty = Type::getInt8Ty(function->getContext());
15601564
ConstantInt *offset_int(
15611565
ConstantInt::get(offset_type, offset, true));
1562-
GetElementPtrInst *get_element_ptr = GetElementPtrInst::Create(
1563-
int8Ty, argument, offset_int, "", entry_instruction);
1566+
GetElementPtrInst *get_element_ptr =
1567+
GetElementPtrInst::Create(int8Ty, argument, offset_int, "",
1568+
entry_instruction->getIterator());
15641569

15651570
if (name == m_result_name && !m_result_is_pointer) {
1566-
LoadInst *load = new LoadInst(value->getType(), get_element_ptr,
1567-
"", entry_instruction);
1571+
LoadInst *load =
1572+
new LoadInst(value->getType(), get_element_ptr, "",
1573+
entry_instruction->getIterator());
15681574

15691575
return load;
15701576
} else {

lldb/tools/debugserver/source/RNBRemote.cpp

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,6 @@ void append_hexified_string(std::ostream &ostrm, const std::string &string) {
176176
}
177177
}
178178

179-
extern void ASLLogCallback(void *baton, uint32_t flags, const char *format,
180-
va_list args);
181-
182179
// from System.framework/Versions/B/PrivateHeaders/sys/codesign.h
183180
extern "C" {
184181
#define CS_OPS_STATUS 0 /* return status */
@@ -1773,8 +1770,6 @@ static std::string get_value(std::string &line) {
17731770

17741771
extern void FileLogCallback(void *baton, uint32_t flags, const char *format,
17751772
va_list args);
1776-
extern void ASLLogCallback(void *baton, uint32_t flags, const char *format,
1777-
va_list args);
17781773

17791774
rnb_err_t RNBRemote::HandlePacket_qRcmd(const char *p) {
17801775
const char *c = p + strlen("qRcmd,");
@@ -1809,8 +1804,8 @@ rnb_err_t RNBRemote::HandlePacket_qRcmd(const char *p) {
18091804
static_cast<uint32_t>(strtoul(value.c_str(), &end, 0));
18101805
if (errno == 0 && end && *end == '\0') {
18111806
DNBLogSetLogMask(logmask);
1812-
if (!DNBLogGetLogCallback())
1813-
DNBLogSetLogCallback(ASLLogCallback, NULL);
1807+
if (auto log_callback = OsLogger::GetLogFunction())
1808+
DNBLogSetLogCallback(log_callback, nullptr);
18141809
return SendPacket("OK");
18151810
}
18161811
errno = 0;
@@ -2177,13 +2172,8 @@ rnb_err_t set_logging(const char *p) {
21772172
// Enable DNB logging.
21782173
// Use the existing log callback if one was already configured.
21792174
if (!DNBLogGetLogCallback()) {
2180-
// Use the os_log()-based logger if available; otherwise,
2181-
// fallback to ASL.
2182-
auto log_callback = OsLogger::GetLogFunction();
2183-
if (log_callback)
2175+
if (auto log_callback = OsLogger::GetLogFunction())
21842176
DNBLogSetLogCallback(log_callback, nullptr);
2185-
else
2186-
DNBLogSetLogCallback(ASLLogCallback, nullptr);
21872177
}
21882178

21892179
// Update logging to use the configured log channel bitmask.

lldb/tools/debugserver/source/RNBServices.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,8 @@ int ListApplications(std::string &plist, bool opt_runningApps,
208208
GetProcesses(plistMutableArray.get(), all_users);
209209
#endif
210210

211-
CFReleaser<CFDataRef> plistData(
212-
::CFPropertyListCreateXMLData(alloc, plistMutableArray.get()));
211+
CFReleaser<CFDataRef> plistData(::CFPropertyListCreateData(
212+
alloc, plistMutableArray.get(), kCFPropertyListXMLFormat_v1_0, 0, NULL));
213213

214214
// write plist to service port
215215
if (plistData.get() != NULL) {

lldb/tools/debugserver/source/debugserver.cpp

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -759,35 +759,6 @@ static int ConnectRemote(RNBRemote *remote, const char *host, int port,
759759
return 1;
760760
}
761761

762-
// ASL Logging callback that can be registered with DNBLogSetLogCallback
763-
void ASLLogCallback(void *baton, uint32_t flags, const char *format,
764-
va_list args) {
765-
if (format == NULL)
766-
return;
767-
static aslmsg g_aslmsg = NULL;
768-
if (g_aslmsg == NULL) {
769-
g_aslmsg = ::asl_new(ASL_TYPE_MSG);
770-
char asl_key_sender[PATH_MAX];
771-
snprintf(asl_key_sender, sizeof(asl_key_sender), "com.apple.%s-%s",
772-
DEBUGSERVER_PROGRAM_NAME, DEBUGSERVER_VERSION_STR);
773-
::asl_set(g_aslmsg, ASL_KEY_SENDER, asl_key_sender);
774-
}
775-
776-
int asl_level;
777-
if (flags & DNBLOG_FLAG_FATAL)
778-
asl_level = ASL_LEVEL_CRIT;
779-
else if (flags & DNBLOG_FLAG_ERROR)
780-
asl_level = ASL_LEVEL_ERR;
781-
else if (flags & DNBLOG_FLAG_WARNING)
782-
asl_level = ASL_LEVEL_WARNING;
783-
else if (flags & DNBLOG_FLAG_VERBOSE)
784-
asl_level = ASL_LEVEL_WARNING; // ASL_LEVEL_INFO;
785-
else
786-
asl_level = ASL_LEVEL_WARNING; // ASL_LEVEL_DEBUG;
787-
788-
::asl_vlog(NULL, g_aslmsg, asl_level, format, args);
789-
}
790-
791762
// FILE based Logging callback that can be registered with
792763
// DNBLogSetLogCallback
793764
void FileLogCallback(void *baton, uint32_t flags, const char *format,
@@ -948,16 +919,8 @@ int main(int argc, char *argv[]) {
948919
// Set up DNB logging by default. If the user passes different log flags or a
949920
// log file, these settings will be modified after processing the command line
950921
// arguments.
951-
auto log_callback = OsLogger::GetLogFunction();
952-
if (log_callback) {
953-
// if os_log() support is available, log through that.
922+
if (auto log_callback = OsLogger::GetLogFunction())
954923
DNBLogSetLogCallback(log_callback, nullptr);
955-
DNBLog("debugserver will use os_log for internal logging.");
956-
} else {
957-
// Fall back to ASL support.
958-
DNBLogSetLogCallback(ASLLogCallback, nullptr);
959-
DNBLog("debugserver will use ASL for internal logging.");
960-
}
961924
DNBLogSetLogMask(/*log_flags*/ 0);
962925

963926
g_remoteSP = std::make_shared<RNBRemote>();

lldb/tools/debugserver/source/libdebugserver.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -311,13 +311,6 @@ RNBRunLoopMode RNBRunLoopInferiorExecuting(RNBRemoteSP &remote) {
311311
return mode;
312312
}
313313

314-
void ASLLogCallback(void *baton, uint32_t flags, const char *format,
315-
va_list args) {
316-
#if 0
317-
vprintf(format, args);
318-
#endif
319-
}
320-
321314
extern "C" int debug_server_main(int fd) {
322315
#if 1
323316
g_isatty = 0;
@@ -327,7 +320,6 @@ extern "C" int debug_server_main(int fd) {
327320
DNBLogSetDebug(1);
328321
DNBLogSetVerbose(1);
329322
DNBLogSetLogMask(-1);
330-
DNBLogSetLogCallback(ASLLogCallback, NULL);
331323
#endif
332324

333325
signal(SIGPIPE, signal_handler);

0 commit comments

Comments
 (0)