[Mlir-commits] [mlir] 021b254 - [mlir:PDLL] Fix build on windows related to different file paths

River Riddle llvmlistbot at llvm.org
Tue Apr 26 19:42:31 PDT 2022


Author: River Riddle
Date: 2022-04-26T19:40:41-07:00
New Revision: 021b2545476d01f6996c13b6892fbf0f47761f41

URL: https://github.com/llvm/llvm-project/commit/021b2545476d01f6996c13b6892fbf0f47761f41
DIFF: https://github.com/llvm/llvm-project/commit/021b2545476d01f6996c13b6892fbf0f47761f41.diff

LOG: [mlir:PDLL] Fix build on windows related to different file paths

This fixes issues with the compilation database when the file path
isn't in the correct form.

Added: 
    

Modified: 
    mlir/lib/Tools/mlir-pdll-lsp-server/CompilationDatabase.cpp
    mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.cpp
    mlir/test/mlir-pdll-lsp-server/completion.test

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Tools/mlir-pdll-lsp-server/CompilationDatabase.cpp b/mlir/lib/Tools/mlir-pdll-lsp-server/CompilationDatabase.cpp
index ceb5e1a592ab7..678d7dcf458e2 100644
--- a/mlir/lib/Tools/mlir-pdll-lsp-server/CompilationDatabase.cpp
+++ b/mlir/lib/Tools/mlir-pdll-lsp-server/CompilationDatabase.cpp
@@ -8,6 +8,7 @@
 
 #include "CompilationDatabase.h"
 #include "../lsp-server-support/Logging.h"
+#include "../lsp-server-support/Protocol.h"
 #include "mlir/Support/FileUtilities.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/YAMLTraits.h"
@@ -26,8 +27,15 @@ namespace yaml {
 template <>
 struct MappingTraits<CompilationDatabase::FileInfo> {
   static void mapping(IO &io, CompilationDatabase::FileInfo &info) {
+    // Parse the filename and normalize it to the form we will expect from
+    // incoming URIs.
     io.mapRequired("filepath", info.filename);
 
+    // Normalize the filename to avoid incompatability with incoming URIs.
+    if (Expected<lsp::URIForFile> uri =
+            lsp::URIForFile::fromFile(info.filename))
+      info.filename = uri->file().str();
+
     // Parse the includes from the yaml stream. These are in the form of a
     // semi-colon delimited list.
     std::string combinedIncludes;

diff  --git a/mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.cpp b/mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.cpp
index 1fd00f7db4c8b..454484ac08d07 100644
--- a/mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.cpp
+++ b/mlir/lib/Tools/mlir-pdll-lsp-server/PDLLServer.cpp
@@ -959,7 +959,14 @@ class LSPCodeCompleteContext : public CodeCompleteContext {
           break;
         }
       }
-    };
+    }
+
+    // Sort the completion results to make sure the output is deterministic in
+    // the face of 
diff erent iteration schemes for 
diff erent platforms.
+    llvm::sort(completionList.items, [](const lsp::CompletionItem &lhs,
+                                        const lsp::CompletionItem &rhs) {
+      return lhs.label < rhs.label;
+    });
   }
 
 private:

diff  --git a/mlir/test/mlir-pdll-lsp-server/completion.test b/mlir/test/mlir-pdll-lsp-server/completion.test
index b682fa5d15f5b..76c062e474081 100644
--- a/mlir/test/mlir-pdll-lsp-server/completion.test
+++ b/mlir/test/mlir-pdll-lsp-server/completion.test
@@ -211,11 +211,11 @@
 // CHECK-NEXT:    "items": [
 // CHECK-NEXT:      {
 // CHECK-NEXT:        "kind": 17,
-// CHECK-NEXT:        "label": "included.td"
+// CHECK-NEXT:        "label": "included.pdll"
 // CHECK-NEXT:      },
 // CHECK-NEXT:      {
 // CHECK-NEXT:        "kind": 17,
-// CHECK-NEXT:        "label": "included.pdll"
+// CHECK-NEXT:        "label": "included.td"
 // CHECK-NEXT:      }
 // CHECK-NEXT:    ]
 // CHECK-NEXT:  }


        


More information about the Mlir-commits mailing list