[Kaleidoscope] Remove RTTI use from chapters 7 and 8.
llvm-svn: 235541
diff --git a/llvm/examples/Kaleidoscope/Chapter7/CMakeLists.txt b/llvm/examples/Kaleidoscope/Chapter7/CMakeLists.txt
index 23aba65..8725e47 100644
--- a/llvm/examples/Kaleidoscope/Chapter7/CMakeLists.txt
+++ b/llvm/examples/Kaleidoscope/Chapter7/CMakeLists.txt
@@ -11,10 +11,6 @@
native
)
-set(LLVM_REQUIRES_RTTI 1)
-
-set(LLVM_BUILD_EXAMPLES OFF)
-
add_kaleidoscope_chapter(Kaleidoscope-Ch7
toy.cpp
)
diff --git a/llvm/examples/Kaleidoscope/Chapter7/Makefile b/llvm/examples/Kaleidoscope/Chapter7/Makefile
index 7abeb3e..c672c0a 100644
--- a/llvm/examples/Kaleidoscope/Chapter7/Makefile
+++ b/llvm/examples/Kaleidoscope/Chapter7/Makefile
@@ -9,7 +9,6 @@
LEVEL = ../../..
TOOLNAME = Kaleidoscope-Ch7
EXAMPLE_TOOL = 1
-REQUIRES_RTTI := 1
LINK_COMPONENTS := core mcjit native
diff --git a/llvm/examples/Kaleidoscope/Chapter7/toy.cpp b/llvm/examples/Kaleidoscope/Chapter7/toy.cpp
index 53ea51c..acf21f89 100644
--- a/llvm/examples/Kaleidoscope/Chapter7/toy.cpp
+++ b/llvm/examples/Kaleidoscope/Chapter7/toy.cpp
@@ -713,7 +713,10 @@
// Special case '=' because we don't want to emit the LHS as an expression.
if (Op == '=') {
// Assignment requires the LHS to be an identifier.
- VariableExprAST *LHSE = dynamic_cast<VariableExprAST *>(LHS);
+ // This assume we're building without RTTI because LLVM builds that way by
+ // default. If you build LLVM with RTTI this can be changed to a
+ // dynamic_cast for automatic error checking.
+ VariableExprAST *LHSE = reinterpret_cast<VariableExprAST *>(LHS);
if (!LHSE)
return ErrorV("destination of '=' must be a variable");
// Codegen the RHS.
diff --git a/llvm/examples/Kaleidoscope/Chapter8/CMakeLists.txt b/llvm/examples/Kaleidoscope/Chapter8/CMakeLists.txt
index 90c79c0..f94ed74 100644
--- a/llvm/examples/Kaleidoscope/Chapter8/CMakeLists.txt
+++ b/llvm/examples/Kaleidoscope/Chapter8/CMakeLists.txt
@@ -7,10 +7,6 @@
native
)
-set(LLVM_REQUIRES_RTTI 1)
-
-set(LLVM_BUILD_EXAMPLES OFF)
-
add_kaleidoscope_chapter(Kaleidoscope-Ch8
toy.cpp
)
diff --git a/llvm/examples/Kaleidoscope/Chapter8/Makefile b/llvm/examples/Kaleidoscope/Chapter8/Makefile
index 8e4d422..25f048c 100644
--- a/llvm/examples/Kaleidoscope/Chapter8/Makefile
+++ b/llvm/examples/Kaleidoscope/Chapter8/Makefile
@@ -9,7 +9,6 @@
LEVEL = ../../..
TOOLNAME = Kaleidoscope-Ch8
EXAMPLE_TOOL = 1
-REQUIRES_RTTI := 1
LINK_COMPONENTS := core mcjit native
diff --git a/llvm/examples/Kaleidoscope/Chapter8/toy.cpp b/llvm/examples/Kaleidoscope/Chapter8/toy.cpp
index eb16516..6ab0eae 100644
--- a/llvm/examples/Kaleidoscope/Chapter8/toy.cpp
+++ b/llvm/examples/Kaleidoscope/Chapter8/toy.cpp
@@ -908,7 +908,10 @@
// Special case '=' because we don't want to emit the LHS as an expression.
if (Op == '=') {
// Assignment requires the LHS to be an identifier.
- VariableExprAST *LHSE = dynamic_cast<VariableExprAST *>(LHS);
+ // This assume we're building without RTTI because LLVM builds that way by
+ // default. If you build LLVM with RTTI this can be changed to a
+ // dynamic_cast for automatic error checking.
+ VariableExprAST *LHSE = reinterpret_cast<VariableExprAST *>(LHS);
if (!LHSE)
return ErrorV("destination of '=' must be a variable");
// Codegen the RHS.