3 This notebook is running `llvm-tblgen`.
8 // This is some tablegen
12 ------------- Classes -----------------
15 ------------- Defs -----------------
18 Errors printed to stderr are shown.
26 <stdin>:1:1: error: Unexpected token at top level
31 Add some classes to get some output.
40 ------------- Classes -----------------
43 ------------- Defs -----------------
48 By default cells are connected. Meaning that we cache the code and magic directives from the previously run cells.
50 This means that the next cell still sees the `Stuff` class.
54 def other_thing : Stuff {}
57 ------------- Classes -----------------
60 ------------- Defs -----------------
61 def other_thing { // Stuff
67 You can use the magic `%reset` to clear this cache and start fresh.
72 def other_thing : Stuff {}
75 <stdin>:1:19: error: Couldn't find class 'Stuff'
76 def other_thing : Stuff {}
80 You can also configure the default reset behaviour using the `%config` magic.
88 ------------- Classes -----------------
91 ------------- Defs -----------------
96 // The cache is reset here so this is an error.
100 <stdin>:2:13: error: Couldn't find class 'Thing'
105 The default value is `off`, meaning cells are connected. If you want to override the default for one cell only, use the `%reset` or `%noreset` magic. These always override the default.
112 ------------- Classes -----------------
115 ------------- Defs -----------------
121 // This works because of the noreset above.
125 ------------- Classes -----------------
128 ------------- Defs -----------------
129 def AThing { // Thing
135 // This does not because we're not changing the default.
136 def AnotherThing: Thing {}
139 <stdin>:2:19: error: Couldn't find class 'Thing'
140 def AnotherThing: Thing {}
146 %config cellreset off
148 // Here we have an empty cache and default reset behaviour.
151 ------------- Classes -----------------
152 ------------- Defs -----------------
155 It is not valid to have `%reset` and `%noreset` in the same cell.
163 %reset and %noreset in the same cell is not allowed. Use only one, or neither.
165 Consider setting `cellreset` to the majority usecase for your notebook. For example a tutorial building a large example across many cells will likely want it `off`. One with many standalone examples, `on`.
167 There is a "magic" directive `%args` that you can use to send command line arguments to `llvm-tblgen`.
169 For example, here we have some code that shows a warning.
174 class Thing <int A, int B> {
179 <stdin>:1:25: warning: unused template argument: Thing:B
180 class Thing <int A, int B> {
184 We can pass an argument to ignore that warning.
188 %args --no-warn-on-unused-template-args
191 ------------- Classes -----------------
192 class Thing<int Thing:A = ?, int Thing:B = ?> {
195 ------------- Defs -----------------
198 If you have a run of cells without a `%reset`, the most recent `%args` is used.
202 // This passes --no-warn-on-unused-template-args
205 ------------- Classes -----------------
206 class Thing<int Thing:A = ?, int Thing:B = ?> {
209 ------------- Defs -----------------
215 // Now we're not passing the argument so the warning comes back.
218 <stdin>:1:25: warning: unused template argument: Thing:B
219 class Thing <int A, int B> {
223 If there are many `%args` in a cell, the last one is used.
228 %args --no-warn-on-unused-template-args
230 class Thing <int A, int B> {}
233 <stdin>:1:18: warning: unused template argument: Thing:A
234 class Thing <int A, int B> {}
236 <stdin>:1:25: warning: unused template argument: Thing:B
237 class Thing <int A, int B> {}