[llvm] fix Kaleidoscope tutorial chapter 3 code snippet and full listing discrepancies (PR #111289)

via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 6 04:57:34 PDT 2024


https://github.com/aidint created https://github.com/llvm/llvm-project/pull/111289

Kaleidoscope tutorial [chapter 3](https://llvm.org/docs/tutorial/MyFirstLanguageFrontend/LangImpl03.html) contains two discrepancies between snippets and full listing.

This is a fix for the following discrepancies:

1. 
https://github.com/llvm/llvm-project/blob/fb0ef6b66e3c7e91481568c15ed67c047dab84e1/llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl03.rst?plain=1#L77
https://github.com/llvm/llvm-project/blob/fb0ef6b66e3c7e91481568c15ed67c047dab84e1/llvm/examples/Kaleidoscope/Chapter3/toy.cpp#L404

2.
https://github.com/llvm/llvm-project/blob/fb0ef6b66e3c7e91481568c15ed67c047dab84e1/llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl03.rst?plain=1#L174
https://github.com/llvm/llvm-project/blob/fb0ef6b66e3c7e91481568c15ed67c047dab84e1/llvm/examples/Kaleidoscope/Chapter3/toy.cpp#L440

>From 63c007dc3f163cd9b0b5c99108fed562aa7714fb Mon Sep 17 00:00:00 2001
From: aidint <3762928+aidint at users.noreply.github.com>
Date: Sun, 6 Oct 2024 13:14:28 +0200
Subject: [PATCH] fix discrepancies between code and documentation

---
 llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl03.rst | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl03.rst b/llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl03.rst
index 2f3f688406212a..f41c5ed0ad0cdb 100644
--- a/llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl03.rst
+++ b/llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl03.rst
@@ -74,7 +74,7 @@ parser, which will be used to report errors found during code generation
 .. code-block:: c++
 
     static std::unique_ptr<LLVMContext> TheContext;
-    static std::unique_ptr<IRBuilder<>> Builder(TheContext);
+    static std::unique_ptr<IRBuilder<>> Builder;
     static std::unique_ptr<Module> TheModule;
     static std::map<std::string, Value *> NamedValues;
 
@@ -171,7 +171,7 @@ variables <LangImpl07.html#user-defined-local-variables>`_.
       case '<':
         L = Builder->CreateFCmpULT(L, R, "cmptmp");
         // Convert bool 0/1 to double 0.0 or 1.0
-        return Builder->CreateUIToFP(L, Type::getDoubleTy(TheContext),
+        return Builder->CreateUIToFP(L, Type::getDoubleTy(*TheContext),
                                      "booltmp");
       default:
         return LogErrorV("invalid binary operator");



More information about the llvm-commits mailing list