<div dir="ltr">Thanks!</div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Apr 17, 2015 at 5:01 PM, Duncan P. N. Exon Smith <span dir="ltr"><<a href="mailto:dexonsmith@apple.com" target="_blank">dexonsmith@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: dexonsmith<br>
Date: Fri Apr 17 19:01:35 2015<br>
New Revision: 235244<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=235244&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=235244&view=rev</a><br>
Log:<br>
docs: Update Kaleidoscope for recent DI changes<br>
<br>
This has been bit-rotting, so fix it up.  I'll have to edit this again<br>
once the MD* classes have been renamed to DI* -- I'll try to remember to<br>
do that with the commit that renames them.<br>
<br>
Modified:<br>
    llvm/trunk/docs/tutorial/LangImpl8.rst<br>
<br>
Modified: llvm/trunk/docs/tutorial/LangImpl8.rst<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/tutorial/LangImpl8.rst?rev=235244&r1=235243&r2=235244&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/docs/tutorial/LangImpl8.rst?rev=235244&r1=235243&r2=235244&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/docs/tutorial/LangImpl8.rst (original)<br>
+++ llvm/trunk/docs/tutorial/LangImpl8.rst Fri Apr 17 19:01:35 2015<br>
@@ -187,13 +187,13 @@ expressions:<br>
   static DIBuilder *DBuilder;<br>
<br>
   struct DebugInfo {<br>
-    DICompileUnit TheCU;<br>
-    DIType DblTy;<br>
+    MDCompileUnit *TheCU;<br>
+    MDType *DblTy;<br>
<br>
-    DIType getDoubleTy();<br>
+    MDType *getDoubleTy();<br>
   } KSDbgInfo;<br>
<br>
-  DIType DebugInfo::getDoubleTy() {<br>
+  MDType *DebugInfo::getDoubleTy() {<br>
     if (DblTy.isValid())<br>
       return DblTy;<br>
<br>
@@ -245,26 +245,26 @@ So the context:<br>
<br>
 .. code-block:: c++<br>
<br>
-  DIFile Unit = DBuilder->createFile(KSDbgInfo.TheCU.getFilename(),<br>
-                                     KSDbgInfo.TheCU.getDirectory());<br>
+  MDFile *Unit = DBuilder->createFile(KSDbgInfo.TheCU.getFilename(),<br>
+                                      KSDbgInfo.TheCU.getDirectory());<br>
<br>
-giving us a DIFile and asking the ``Compile Unit`` we created above for the<br>
+giving us an MDFile and asking the ``Compile Unit`` we created above for the<br>
 directory and filename where we are currently. Then, for now, we use some<br>
 source locations of 0 (since our AST doesn't currently have source location<br>
 information) and construct our function definition:<br>
<br>
 .. code-block:: c++<br>
<br>
-  DIDescriptor FContext(Unit);<br>
+  MDScope *FContext = Unit;<br>
   unsigned LineNo = 0;<br>
   unsigned ScopeLine = 0;<br>
-  DISubprogram SP = DBuilder->createFunction(<br>
+  MDSubprogram *SP = DBuilder->createFunction(<br>
       FContext, Name, StringRef(), Unit, LineNo,<br>
       CreateFunctionType(Args.size(), Unit), false /* internal linkage */,<br>
-      true /* definition */, ScopeLine, DIDescriptor::FlagPrototyped, false, F);<br>
+      true /* definition */, ScopeLine, DebugNode::FlagPrototyped, false, F);<br>
<br>
-and we now have a DISubprogram that contains a reference to all of our metadata<br>
-for the function.<br>
+and we now have an MDSubprogram that contains a reference to all of our<br>
+metadata for the function.<br>
<br>
 Source Locations<br>
 ================<br>
@@ -330,13 +330,13 @@ by constructing another small function:<br>
 .. code-block:: c++<br>
<br>
   void DebugInfo::emitLocation(ExprAST *AST) {<br>
-    DIScope *Scope;<br>
+    MDScope *Scope;<br>
     if (LexicalBlocks.empty())<br>
-      Scope = &TheCU;<br>
+      Scope = TheCU;<br>
     else<br>
       Scope = LexicalBlocks.back();<br>
     Builder.SetCurrentDebugLocation(<br>
-        DebugLoc::get(AST->getLine(), AST->getCol(), DIScope(*Scope)));<br>
+        DebugLoc::get(AST->getLine(), AST->getCol(), Scope));<br>
   }<br>
<br>
 that both tells the main ``IRBuilder`` where we are, but also what scope<br>
@@ -347,11 +347,11 @@ of scopes:<br>
<br>
 .. code-block:: c++<br>
<br>
-   std::vector<DIScope *> LexicalBlocks;<br>
-   std::map<const PrototypeAST *, DIScope> FnScopeMap;<br>
+   std::vector<MDScope *> LexicalBlocks;<br>
+   std::map<const PrototypeAST *, MDScope *> FnScopeMap;<br>
<br>
-and keep a map of each function to the scope that it represents (a DISubprogram<br>
-is also a DIScope).<br>
+and keep a map of each function to the scope that it represents (an<br>
+MDSubprogram is also an MDScope).<br>
<br>
 Then we make sure to:<br>
<br>
@@ -392,16 +392,16 @@ argument allocas in ``PrototypeAST::Crea<br>
<br>
 .. code-block:: c++<br>
<br>
-  DIScope *Scope = KSDbgInfo.LexicalBlocks.back();<br>
-  DIFile Unit = DBuilder->createFile(KSDbgInfo.TheCU.getFilename(),<br>
-                                     KSDbgInfo.TheCU.getDirectory());<br>
-  DIVariable D = DBuilder->createLocalVariable(dwarf::DW_TAG_arg_variable,<br>
-                                               *Scope, Args[Idx], Unit, Line,<br>
-                                               KSDbgInfo.getDoubleTy(), Idx);<br>
+  MDScope *Scope = KSDbgInfo.LexicalBlocks.back();<br>
+  MDFile *Unit = DBuilder->createFile(KSDbgInfo.TheCU.getFilename(),<br>
+                                      KSDbgInfo.TheCU.getDirectory());<br>
+  MDLocalVariable D = DBuilder->createLocalVariable(<br>
+      dwarf::DW_TAG_arg_variable, Scope, Args[Idx], Unit, Line,<br>
+      KSDbgInfo.getDoubleTy(), Idx);<br>
<br>
   Instruction *Call = DBuilder->insertDeclare(<br>
       Alloca, D, DBuilder->createExpression(), Builder.GetInsertBlock());<br>
-  Call->setDebugLoc(DebugLoc::get(Line, 0, *Scope));<br>
+  Call->setDebugLoc(DebugLoc::get(Line, 0, Scope));<br>
<br>
 Here we're doing a few things. First, we're grabbing our current scope<br>
 for the variable so we can say what range of code our variable is valid<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>