[Lldb-commits] [lldb] [lldb-dap] Gardening in lldb-dap.cpp (NFC) (PR #128949)

Jonas Devlieghere via lldb-commits lldb-commits at lists.llvm.org
Wed Feb 26 17:06:54 PST 2025


https://github.com/JDevlieghere updated https://github.com/llvm/llvm-project/pull/128949

>From 679e038a2322fdf884eb22baafe9167904e27dd7 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere <jonas at devlieghere.com>
Date: Wed, 26 Feb 2025 16:29:26 -0600
Subject: [PATCH 1/2] [lldb-dap] Gardening in lldb-dap.cpp (NFC)

 - Remove more unused includes
 - Limit anonymous namespace to llvm::opt
 - Fix code style
---
 lldb/tools/lldb-dap/lldb-dap.cpp | 22 +++++-----------------
 1 file changed, 5 insertions(+), 17 deletions(-)

diff --git a/lldb/tools/lldb-dap/lldb-dap.cpp b/lldb/tools/lldb-dap/lldb-dap.cpp
index 1c6bd7e903409..d4ebd6430d0aa 100644
--- a/lldb/tools/lldb-dap/lldb-dap.cpp
+++ b/lldb/tools/lldb-dap/lldb-dap.cpp
@@ -1,4 +1,4 @@
-//===-- lldb-dap.cpp -----------------------------------------*- C++ -*-===//
+//===-- lldb-dap.cpp ------------------------------------------------------===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -8,10 +8,7 @@
 
 #include "DAP.h"
 #include "EventHelper.h"
-#include "FifoFiles.h"
 #include "Handler/RequestHandler.h"
-#include "JSONUtils.h"
-#include "LLDBUtils.h"
 #include "RunInTerminal.h"
 #include "lldb/API/SBStream.h"
 #include "lldb/Host/Config.h"
@@ -23,7 +20,6 @@
 #include "lldb/lldb-forward.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/ScopeExit.h"
-#include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Option/Arg.h"
 #include "llvm/Option/ArgList.h"
@@ -37,22 +33,15 @@
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/Threading.h"
 #include "llvm/Support/raw_ostream.h"
-#include <algorithm>
 #include <condition_variable>
-#include <cstdint>
 #include <cstdio>
 #include <cstdlib>
-#include <cstring>
 #include <fcntl.h>
 #include <fstream>
 #include <map>
 #include <memory>
 #include <mutex>
-#include <optional>
-#include <ostream>
 #include <string>
-#include <sys/stat.h>
-#include <sys/types.h>
 #include <thread>
 #include <utility>
 #include <vector>
@@ -113,8 +102,9 @@ class LLDBDAPOptTable : public llvm::opt::GenericOptTable {
       : llvm::opt::GenericOptTable(OptionStrTable, OptionPrefixesTable,
                                    InfoTable, true) {}
 };
+} // anonymous namespace
 
-void RegisterRequestCallbacks(DAP &dap) {
+static void RegisterRequestCallbacks(DAP &dap) {
   dap.RegisterRequest<AttachRequestHandler>();
   dap.RegisterRequest<BreakpointLocationsRequestHandler>();
   dap.RegisterRequest<CompletionsRequestHandler>();
@@ -155,9 +145,7 @@ void RegisterRequestCallbacks(DAP &dap) {
   dap.RegisterRequest<TestGetTargetBreakpointsRequestHandler>();
 }
 
-} // anonymous namespace
-
-static void printHelp(LLDBDAPOptTable &table, llvm::StringRef tool_name) {
+static void PrintHelp(LLDBDAPOptTable &table, llvm::StringRef tool_name) {
   std::string usage_str = tool_name.str() + " options";
   table.printHelp(llvm::outs(), usage_str.c_str(), "LLDB DAP", false);
 
@@ -433,7 +421,7 @@ int main(int argc, char *argv[]) {
   llvm::opt::InputArgList input_args = T.ParseArgs(ArgsArr, MAI, MAC);
 
   if (input_args.hasArg(OPT_help)) {
-    printHelp(T, llvm::sys::path::filename(argv[0]));
+    PrintHelp(T, llvm::sys::path::filename(argv[0]));
     return EXIT_SUCCESS;
   }
 

>From cf1ab243c0231b2825a972025a5cc11c51560dc7 Mon Sep 17 00:00:00 2001
From: Jonas Devlieghere <jonas at devlieghere.com>
Date: Wed, 26 Feb 2025 19:06:40 -0600
Subject: [PATCH 2/2] Don't remove llvm/ADT/StringExtras.h

---
 lldb/tools/lldb-dap/lldb-dap.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/lldb/tools/lldb-dap/lldb-dap.cpp b/lldb/tools/lldb-dap/lldb-dap.cpp
index d4ebd6430d0aa..b692754969757 100644
--- a/lldb/tools/lldb-dap/lldb-dap.cpp
+++ b/lldb/tools/lldb-dap/lldb-dap.cpp
@@ -20,6 +20,7 @@
 #include "lldb/lldb-forward.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/ScopeExit.h"
+#include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Option/Arg.h"
 #include "llvm/Option/ArgList.h"



More information about the lldb-commits mailing list