[llvm] [llvm-lsp] LSP server for LLVM IR (PR #161969)
    via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Sat Oct  4 12:47:29 PDT 2025
    
    
  
Albert =?utf-8?q?Havliček?= <ahavlicek at azul.com>,
Albert =?utf-8?q?Havliček?= <ahavlicek at azul.com>,
Albert =?utf-8?q?Havliček?= <ahavlicek at azul.com>,Bertik23
 <39457484+Bertik23 at users.noreply.github.com>,
Albert =?utf-8?q?Havliček?= <ahavlicek at azul.com>,
Albert =?utf-8?q?Havliček?= <ahavlicek at azul.com>,
Albert =?utf-8?q?Havliček?= <ahavlicek at azul.com>,
Albert =?utf-8?q?Havliček?= <ahavlicek at azul.com>,
Albert =?utf-8?q?Havliček?= <ahavlicek at azul.com>,
Albert =?utf-8?q?Havliček?= <ahavlicek at azul.com>,
Albert =?utf-8?q?Havliček?= <ahavlicek at azul.com>,
Albert =?utf-8?q?Havliček?= <ahavlicek at azul.com>,
Albert =?utf-8?q?Havliček?= <ahavlicek at azul.com>,
Albert =?utf-8?q?Havliček?= <ahavlicek at azul.com>,
Albert =?utf-8?q?Havliček?= <ahavlicek at azul.com>,
Albert =?utf-8?q?Havliček?= <ahavlicek at azul.com>,
Albert =?utf-8?q?Havliček?= <ahavlicek at azul.com>,
Albert =?utf-8?q?Havliček?= <ahavlicek at azul.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/161969 at github.com>
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff origin/main HEAD --extensions h,cpp -- llvm/include/llvm/AsmParser/AsmParserContext.h llvm/include/llvm/AsmParser/FileLoc.h llvm/lib/AsmParser/AsmParserContext.cpp llvm/tools/llvm-lsp/IRDocument.h llvm/tools/llvm-lsp/OptRunner.h llvm/tools/llvm-lsp/Protocol.cpp llvm/tools/llvm-lsp/Protocol.h llvm/tools/llvm-lsp/llvm-lsp-server.cpp llvm/tools/llvm-lsp/llvm-lsp-server.h llvm/include/llvm/Analysis/CFGPrinter.h llvm/include/llvm/AsmParser/LLLexer.h llvm/include/llvm/AsmParser/LLParser.h llvm/include/llvm/AsmParser/Parser.h llvm/include/llvm/IRReader/IRReader.h llvm/include/llvm/Support/LSP/Protocol.h llvm/lib/Analysis/CFGPrinter.cpp llvm/lib/AsmParser/LLLexer.cpp llvm/lib/AsmParser/LLParser.cpp llvm/lib/AsmParser/Parser.cpp llvm/lib/IRReader/IRReader.cpp llvm/lib/Support/LSP/Protocol.cpp llvm/unittests/AsmParser/AsmParserTest.cpp
``````````
:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/include/llvm/Analysis/CFGPrinter.h b/llvm/include/llvm/Analysis/CFGPrinter.h
index c492ab8be..4feccb013 100644
--- a/llvm/include/llvm/Analysis/CFGPrinter.h
+++ b/llvm/include/llvm/Analysis/CFGPrinter.h
@@ -77,8 +77,7 @@ private:
   std::optional<NodeIdFormatterTy> NodeIdFormatter;
 
 public:
-  DOTFuncInfo(const Function *F)
-      : DOTFuncInfo(F, nullptr, nullptr, 0) {}
+  DOTFuncInfo(const Function *F) : DOTFuncInfo(F, nullptr, nullptr, 0) {}
   LLVM_ABI ~DOTFuncInfo();
 
   LLVM_ABI
diff --git a/llvm/tools/llvm-lsp/OptRunner.h b/llvm/tools/llvm-lsp/OptRunner.h
index b4c1da37c..e6d0cb839 100644
--- a/llvm/tools/llvm-lsp/OptRunner.h
+++ b/llvm/tools/llvm-lsp/OptRunner.h
@@ -42,37 +42,37 @@ public:
     unsigned PassNumber = 0;
     // FIXME: Should we only consider passes that modify the IR?
     std::function<void(const StringRef, Any, const PreservedAnalyses)>
-        RecordPassNamesAndDescription = [&PassListAndDescription, &PassNumber](
-                                            const StringRef PassName, Any IR,
-                                            const PreservedAnalyses &PA) {
-          PassNumber++;
-          std::string PassNameStr =
-              (std::to_string(PassNumber) + "-" + PassName.str());
-          std::string PassDescStr = [&IR, &PassName]() -> std::string {
-            if (auto *M = any_cast<const Module *>(&IR))
-              return "Module Pass on \"" + (**M).getName().str() + "\"";
-            if (auto *F = any_cast<const Function *>(&IR))
-              return "Function Pass on \"" + (**F).getName().str() + "\"";
-            if (auto *L = any_cast<const Loop *>(&IR)) {
-              Function *F = (*L)->getHeader()->getParent();
-              std::string Desc = "Loop Pass in Function \"" +
-                                 F->getName().str() +
-                                 "\" on loop with Header \"" +
-                                 (*L)->getHeader()->getName().str() + "\"";
-              return Desc;
-            }
-            if (auto *SCC = any_cast<const LazyCallGraph::SCC *>(&IR)) {
-              Function &F = (**SCC).begin()->getFunction();
-              std::string Desc =
-                  "CGSCC Pass on Function \"" + F.getName().str() + "\"";
-              return Desc;
-            }
-            lsp::Logger::error("Unknown Pass Type \"{}\"!", PassName.str());
-            return "";
-          }();
-
-          PassListAndDescription.push_back({PassNameStr, PassDescStr});
-        };
+        RecordPassNamesAndDescription =
+            [&PassListAndDescription, &PassNumber](
+                const StringRef PassName, Any IR, const PreservedAnalyses &PA) {
+              PassNumber++;
+              std::string PassNameStr =
+                  (std::to_string(PassNumber) + "-" + PassName.str());
+              std::string PassDescStr = [&IR, &PassName]() -> std::string {
+                if (auto *M = any_cast<const Module *>(&IR))
+                  return "Module Pass on \"" + (**M).getName().str() + "\"";
+                if (auto *F = any_cast<const Function *>(&IR))
+                  return "Function Pass on \"" + (**F).getName().str() + "\"";
+                if (auto *L = any_cast<const Loop *>(&IR)) {
+                  Function *F = (*L)->getHeader()->getParent();
+                  std::string Desc = "Loop Pass in Function \"" +
+                                     F->getName().str() +
+                                     "\" on loop with Header \"" +
+                                     (*L)->getHeader()->getName().str() + "\"";
+                  return Desc;
+                }
+                if (auto *SCC = any_cast<const LazyCallGraph::SCC *>(&IR)) {
+                  Function &F = (**SCC).begin()->getFunction();
+                  std::string Desc =
+                      "CGSCC Pass on Function \"" + F.getName().str() + "\"";
+                  return Desc;
+                }
+                lsp::Logger::error("Unknown Pass Type \"{}\"!", PassName.str());
+                return "";
+              }();
+
+              PassListAndDescription.push_back({PassNameStr, PassDescStr});
+            };
 
     auto RunOptResult = runOpt(PipelineText, RecordPassNamesAndDescription);
     if (!RunOptResult) {
diff --git a/llvm/tools/llvm-lsp/Protocol.cpp b/llvm/tools/llvm-lsp/Protocol.cpp
index ff56c063d..f7858ea58 100644
--- a/llvm/tools/llvm-lsp/Protocol.cpp
+++ b/llvm/tools/llvm-lsp/Protocol.cpp
@@ -14,8 +14,7 @@ using namespace llvm::lsp;
 bool llvm::lsp::fromJSON(const llvm::json::Value &Value, GetCfgParams &Result,
                          llvm::json::Path Path) {
   llvm::json::ObjectMapper O(Value, Path);
-  return O && O.map("uri", Result.uri) &&
-         O.map("position", Result.position);
+  return O && O.map("uri", Result.uri) && O.map("position", Result.position);
 }
 
 llvm::json::Value llvm::lsp::toJSON(const CFG &Value) {
``````````
</details>
https://github.com/llvm/llvm-project/pull/161969
    
    
More information about the llvm-commits
mailing list