[Mlir-commits] [mlir] daa350c - [mlir] Work around MSVC bug

Benjamin Kramer llvmlistbot at llvm.org
Sun Mar 17 06:07:16 PDT 2024


Author: Benjamin Kramer
Date: 2024-03-17T14:05:41+01:00
New Revision: daa350c1995015daac552548c34b87220f21156d

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

LOG: [mlir] Work around MSVC bug

MSVC fails to parse this construct, leading to
MlirTranslateMain.cpp(70): error C2065: 'inputSplitMarker': undeclared identifier

Just switching to brace init works around the issue

Added: 
    

Modified: 
    mlir/lib/Tools/mlir-opt/MlirOptMain.cpp
    mlir/lib/Tools/mlir-translate/MlirTranslateMain.cpp
    mlir/tools/mlir-pdll/mlir-pdll.cpp

Removed: 
    


################################################################################
diff  --git a/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp b/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp
index 51504ad58282e1..44c5e9826f3b79 100644
--- a/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp
+++ b/mlir/lib/Tools/mlir-opt/MlirOptMain.cpp
@@ -128,7 +128,7 @@ struct MlirOptMainConfigCLOptions : public MlirOptMainConfig {
         cl::desc("Print the list of registered dialects and exit"),
         cl::location(showDialectsFlag), cl::init(false));
 
-    static cl::opt<std::string, /*ExternalStorage=*/true> splitInputFile(
+    static cl::opt<std::string, /*ExternalStorage=*/true> splitInputFile{
         "split-input-file", llvm::cl::ValueOptional,
         cl::callback([&](const std::string &str) {
           // Implicit value: use default marker if flag was used without value.
@@ -137,7 +137,7 @@ struct MlirOptMainConfigCLOptions : public MlirOptMainConfig {
         }),
         cl::desc("Split the input file into chunks using the given or "
                  "default marker and process each chunk independently"),
-        cl::location(splitInputFileFlag), cl::init(""));
+        cl::location(splitInputFileFlag), cl::init("")};
 
     static cl::opt<std::string, /*ExternalStorage=*/true> outputSplitMarker(
         "output-split-marker",

diff  --git a/mlir/lib/Tools/mlir-translate/MlirTranslateMain.cpp b/mlir/lib/Tools/mlir-translate/MlirTranslateMain.cpp
index 1aaf8adb50a7a5..bd9928950ecc76 100644
--- a/mlir/lib/Tools/mlir-translate/MlirTranslateMain.cpp
+++ b/mlir/lib/Tools/mlir-translate/MlirTranslateMain.cpp
@@ -62,7 +62,7 @@ LogicalResult mlir::mlirTranslateMain(int argc, char **argv,
       llvm::cl::desc("Allow operation with no registered dialects (discouraged: testing only!)"),
       llvm::cl::init(false));
 
-  static llvm::cl::opt<std::string> inputSplitMarker(
+  static llvm::cl::opt<std::string> inputSplitMarker{
       "split-input-file", llvm::cl::ValueOptional,
       llvm::cl::callback([&](const std::string &str) {
         // Implicit value: use default marker if flag was used without value.
@@ -71,7 +71,7 @@ LogicalResult mlir::mlirTranslateMain(int argc, char **argv,
       }),
       llvm::cl::desc("Split the input file into chunks using the given or "
                      "default marker and process each chunk independently"),
-      llvm::cl::init(""));
+      llvm::cl::init("")};
 
   static llvm::cl::opt<bool> verifyDiagnostics(
       "verify-diagnostics",

diff  --git a/mlir/tools/mlir-pdll/mlir-pdll.cpp b/mlir/tools/mlir-pdll/mlir-pdll.cpp
index d312765e40b029..c6ad6c361e9946 100644
--- a/mlir/tools/mlir-pdll/mlir-pdll.cpp
+++ b/mlir/tools/mlir-pdll/mlir-pdll.cpp
@@ -136,7 +136,7 @@ int main(int argc, char **argv) {
       llvm::cl::desc(
           "Print out the parsed ODS information from the input file"),
       llvm::cl::init(false));
-  llvm::cl::opt<std::string> inputSplitMarker(
+  llvm::cl::opt<std::string> inputSplitMarker{
       "split-input-file", llvm::cl::ValueOptional,
       llvm::cl::callback([&](const std::string &str) {
         // Implicit value: use default marker if flag was used without value.
@@ -145,7 +145,7 @@ int main(int argc, char **argv) {
       }),
       llvm::cl::desc("Split the input file into chunks using the given or "
                      "default marker and process each chunk independently"),
-      llvm::cl::init(""));
+      llvm::cl::init("")};
   llvm::cl::opt<std::string> outputSplitMarker(
       "output-split-marker",
       llvm::cl::desc("Split marker to use for merging the ouput"),


        


More information about the Mlir-commits mailing list