[Mlir-commits] [mlir] Include <cstdlib> in Toy Lexer examples. (PR #110449)

Alexey Samsonov llvmlistbot at llvm.org
Sun Sep 29 22:04:41 PDT 2024


https://github.com/vonosmas created https://github.com/llvm/llvm-project/pull/110449

These files all use `strtod` - make sure to include a proper header for this function. Otherwise, building MLIR fails on some systems after the recent commit 1b5f6916199ce09244cdb52c6911f2028e6ca95a which removed inclusion of `<cmath>` and thus broke transitive inclusion of `<stdlib.h>` in these headers.

>From 4324cdce580a4116f4ee8eb81bf1732b3bb349d6 Mon Sep 17 00:00:00 2001
From: Alexey Samsonov <vonosmas at gmail.com>
Date: Sun, 29 Sep 2024 21:50:28 -0700
Subject: [PATCH] Include <cstdlib> in Toy Lexer examples.

These files all use strtod() - make sure to include a proper
header for this function. Otherwise, building MLIR fails on
some systems after the recent commit 1b5f6916199ce09244cdb52c6911f2028e6ca95a
which removed <cmath> and thus broke transitive inclusion
of <stdlib.h> in these headers.
---
 mlir/examples/toy/Ch1/include/toy/Lexer.h | 1 +
 mlir/examples/toy/Ch2/include/toy/Lexer.h | 1 +
 mlir/examples/toy/Ch3/include/toy/Lexer.h | 1 +
 mlir/examples/toy/Ch4/include/toy/Lexer.h | 1 +
 mlir/examples/toy/Ch5/include/toy/Lexer.h | 1 +
 mlir/examples/toy/Ch6/include/toy/Lexer.h | 1 +
 mlir/examples/toy/Ch7/include/toy/Lexer.h | 1 +
 7 files changed, 7 insertions(+)

diff --git a/mlir/examples/toy/Ch1/include/toy/Lexer.h b/mlir/examples/toy/Ch1/include/toy/Lexer.h
index ecbb3b4e0e5835..d420a7ebbf3b68 100644
--- a/mlir/examples/toy/Ch1/include/toy/Lexer.h
+++ b/mlir/examples/toy/Ch1/include/toy/Lexer.h
@@ -15,6 +15,7 @@
 
 #include "llvm/ADT/StringRef.h"
 
+#include <cstdlib>
 #include <memory>
 #include <string>
 
diff --git a/mlir/examples/toy/Ch2/include/toy/Lexer.h b/mlir/examples/toy/Ch2/include/toy/Lexer.h
index 3c59cd9805fef6..22822cc1059578 100644
--- a/mlir/examples/toy/Ch2/include/toy/Lexer.h
+++ b/mlir/examples/toy/Ch2/include/toy/Lexer.h
@@ -15,6 +15,7 @@
 
 #include "llvm/ADT/StringRef.h"
 
+#include <cstdlib>
 #include <memory>
 #include <string>
 
diff --git a/mlir/examples/toy/Ch3/include/toy/Lexer.h b/mlir/examples/toy/Ch3/include/toy/Lexer.h
index 3c59cd9805fef6..22822cc1059578 100644
--- a/mlir/examples/toy/Ch3/include/toy/Lexer.h
+++ b/mlir/examples/toy/Ch3/include/toy/Lexer.h
@@ -15,6 +15,7 @@
 
 #include "llvm/ADT/StringRef.h"
 
+#include <cstdlib>
 #include <memory>
 #include <string>
 
diff --git a/mlir/examples/toy/Ch4/include/toy/Lexer.h b/mlir/examples/toy/Ch4/include/toy/Lexer.h
index 3c59cd9805fef6..22822cc1059578 100644
--- a/mlir/examples/toy/Ch4/include/toy/Lexer.h
+++ b/mlir/examples/toy/Ch4/include/toy/Lexer.h
@@ -15,6 +15,7 @@
 
 #include "llvm/ADT/StringRef.h"
 
+#include <cstdlib>
 #include <memory>
 #include <string>
 
diff --git a/mlir/examples/toy/Ch5/include/toy/Lexer.h b/mlir/examples/toy/Ch5/include/toy/Lexer.h
index 3c59cd9805fef6..22822cc1059578 100644
--- a/mlir/examples/toy/Ch5/include/toy/Lexer.h
+++ b/mlir/examples/toy/Ch5/include/toy/Lexer.h
@@ -15,6 +15,7 @@
 
 #include "llvm/ADT/StringRef.h"
 
+#include <cstdlib>
 #include <memory>
 #include <string>
 
diff --git a/mlir/examples/toy/Ch6/include/toy/Lexer.h b/mlir/examples/toy/Ch6/include/toy/Lexer.h
index 3c59cd9805fef6..22822cc1059578 100644
--- a/mlir/examples/toy/Ch6/include/toy/Lexer.h
+++ b/mlir/examples/toy/Ch6/include/toy/Lexer.h
@@ -15,6 +15,7 @@
 
 #include "llvm/ADT/StringRef.h"
 
+#include <cstdlib>
 #include <memory>
 #include <string>
 
diff --git a/mlir/examples/toy/Ch7/include/toy/Lexer.h b/mlir/examples/toy/Ch7/include/toy/Lexer.h
index a3fde91a357a3f..f022c2f48ac8e8 100644
--- a/mlir/examples/toy/Ch7/include/toy/Lexer.h
+++ b/mlir/examples/toy/Ch7/include/toy/Lexer.h
@@ -15,6 +15,7 @@
 
 #include "llvm/ADT/StringRef.h"
 
+#include <cstdlib>
 #include <memory>
 #include <string>
 



More information about the Mlir-commits mailing list