[llvm] r235541 - [Kaleidoscope] Remove RTTI use from chapters 7 and 8.
David Blaikie
dblaikie at gmail.com
Wed Apr 22 13:49:41 PDT 2015
On Wed, Apr 22, 2015 at 1:41 PM, Lang Hames <lhames at gmail.com> wrote:
> Author: lhames
> Date: Wed Apr 22 15:41:34 2015
> New Revision: 235541
>
> URL: http://llvm.org/viewvc/llvm-project?rev=235541&view=rev
> Log:
> [Kaleidoscope] Remove RTTI use from chapters 7 and 8.
>
> Modified:
> llvm/trunk/examples/Kaleidoscope/Chapter7/CMakeLists.txt
> llvm/trunk/examples/Kaleidoscope/Chapter7/Makefile
> llvm/trunk/examples/Kaleidoscope/Chapter7/toy.cpp
> llvm/trunk/examples/Kaleidoscope/Chapter8/CMakeLists.txt
> llvm/trunk/examples/Kaleidoscope/Chapter8/Makefile
> llvm/trunk/examples/Kaleidoscope/Chapter8/toy.cpp
>
> Modified: llvm/trunk/examples/Kaleidoscope/Chapter7/CMakeLists.txt
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/Kaleidoscope/Chapter7/CMakeLists.txt?rev=235541&r1=235540&r2=235541&view=diff
> ==============================================================================
> --- llvm/trunk/examples/Kaleidoscope/Chapter7/CMakeLists.txt (original)
> +++ llvm/trunk/examples/Kaleidoscope/Chapter7/CMakeLists.txt Wed Apr 22 15:41:34 2015
> @@ -11,10 +11,6 @@ set(LLVM_LINK_COMPONENTS
> native
> )
>
> -set(LLVM_REQUIRES_RTTI 1)
> -
> -set(LLVM_BUILD_EXAMPLES OFF)
> -
> add_kaleidoscope_chapter(Kaleidoscope-Ch7
> toy.cpp
> )
>
> Modified: llvm/trunk/examples/Kaleidoscope/Chapter7/Makefile
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/Kaleidoscope/Chapter7/Makefile?rev=235541&r1=235540&r2=235541&view=diff
> ==============================================================================
> --- llvm/trunk/examples/Kaleidoscope/Chapter7/Makefile (original)
> +++ llvm/trunk/examples/Kaleidoscope/Chapter7/Makefile Wed Apr 22 15:41:34 2015
> @@ -9,7 +9,6 @@
> LEVEL = ../../..
> TOOLNAME = Kaleidoscope-Ch7
> EXAMPLE_TOOL = 1
> -REQUIRES_RTTI := 1
>
> LINK_COMPONENTS := core mcjit native
>
>
> Modified: llvm/trunk/examples/Kaleidoscope/Chapter7/toy.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/Kaleidoscope/Chapter7/toy.cpp?rev=235541&r1=235540&r2=235541&view=diff
> ==============================================================================
> --- llvm/trunk/examples/Kaleidoscope/Chapter7/toy.cpp (original)
> +++ llvm/trunk/examples/Kaleidoscope/Chapter7/toy.cpp Wed Apr 22 15:41:34 2015
> @@ -713,7 +713,10 @@ Value *BinaryExprAST::Codegen() {
> // 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);
This should probably be static_cast - reinterpret_cast won't account
for base pointer adjustments, etc (eg: if the base object isn't the
first subobject of the derived class (because it derives from more
than one class, for example) - static_cast will adjust the pointer
appropriately, reintepret_cast won't)
> if (!LHSE)
> return ErrorV("destination of '=' must be a variable");
> // Codegen the RHS.
>
> Modified: llvm/trunk/examples/Kaleidoscope/Chapter8/CMakeLists.txt
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/Kaleidoscope/Chapter8/CMakeLists.txt?rev=235541&r1=235540&r2=235541&view=diff
> ==============================================================================
> --- llvm/trunk/examples/Kaleidoscope/Chapter8/CMakeLists.txt (original)
> +++ llvm/trunk/examples/Kaleidoscope/Chapter8/CMakeLists.txt Wed Apr 22 15:41:34 2015
> @@ -7,10 +7,6 @@ set(LLVM_LINK_COMPONENTS
> native
> )
>
> -set(LLVM_REQUIRES_RTTI 1)
> -
> -set(LLVM_BUILD_EXAMPLES OFF)
> -
> add_kaleidoscope_chapter(Kaleidoscope-Ch8
> toy.cpp
> )
>
> Modified: llvm/trunk/examples/Kaleidoscope/Chapter8/Makefile
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/Kaleidoscope/Chapter8/Makefile?rev=235541&r1=235540&r2=235541&view=diff
> ==============================================================================
> --- llvm/trunk/examples/Kaleidoscope/Chapter8/Makefile (original)
> +++ llvm/trunk/examples/Kaleidoscope/Chapter8/Makefile Wed Apr 22 15:41:34 2015
> @@ -9,7 +9,6 @@
> LEVEL = ../../..
> TOOLNAME = Kaleidoscope-Ch8
> EXAMPLE_TOOL = 1
> -REQUIRES_RTTI := 1
>
> LINK_COMPONENTS := core mcjit native
>
>
> Modified: llvm/trunk/examples/Kaleidoscope/Chapter8/toy.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/examples/Kaleidoscope/Chapter8/toy.cpp?rev=235541&r1=235540&r2=235541&view=diff
> ==============================================================================
> --- llvm/trunk/examples/Kaleidoscope/Chapter8/toy.cpp (original)
> +++ llvm/trunk/examples/Kaleidoscope/Chapter8/toy.cpp Wed Apr 22 15:41:34 2015
> @@ -908,7 +908,10 @@ Value *BinaryExprAST::Codegen() {
> // 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);
Same here
> if (!LHSE)
> return ErrorV("destination of '=' must be a variable");
> // Codegen the RHS.
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list