<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Hello,<div><br></div><div>I’m very new to the clang source and I’m trying to understand how AST serialization works. As far as I can tell valid FileIDs can be positive or negative but not 0. Yet I see the following in ASTReader: <a href="https://github.com/llvm-mirror/clang/blob/master/lib/Serialization/ASTReader.cpp#L1036">https://github.com/llvm-mirror/clang/blob/master/lib/Serialization/ASTReader.cpp#L1036</a></div><div><br></div><div>I’m wondering, shouldn’t that line be:</div><div><span class="n" style="box-sizing: border-box; color: rgb(51, 51, 51); font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; line-height: 18px; white-space: pre;">assert</span><span class="p" style="box-sizing: border-box; color: rgb(51, 51, 51); font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; line-height: 18px; white-space: pre;">(</span><span class="n" style="box-sizing: border-box; color: rgb(51, 51, 51); font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; line-height: 18px; white-space: pre;">FID</span><span style="color: rgb(51, 51, 51); font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; line-height: 18px; white-space: pre; background-color: rgb(255, 255, 204);"> </span><span class="o" style="box-sizing: border-box; font-weight: bold; color: rgb(51, 51, 51); font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; line-height: 18px; white-space: pre;">></span><span style="color: rgb(51, 51, 51); font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; line-height: 18px; white-space: pre; background-color: rgb(255, 255, 204);"> </span><span class="mi" style="box-sizing: border-box; color: rgb(0, 153, 153); font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; line-height: 18px; white-space: pre;">0</span><span style="color: rgb(51, 51, 51); font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; line-height: 18px; white-space: pre; background-color: rgb(255, 255, 204);"> </span><span class="o" style="box-sizing: border-box; font-weight: bold; color: rgb(51, 51, 51); font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; line-height: 18px; white-space: pre;">&&</span><span style="color: rgb(51, 51, 51); font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; line-height: 18px; white-space: pre; background-color: rgb(255, 255, 204);"> </span><span class="s" style="box-sizing: border-box; color: rgb(221, 17, 68); font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; line-height: 18px; white-space: pre;">"Serialized line entries for non-local file.”</span><span class="p" style="box-sizing: border-box; color: rgb(51, 51, 51); font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; line-height: 18px; white-space: pre;">);</span></div><div><br></div><div><span style="line-height: 18px; white-space: pre;">It looks like SLocEntryBaseID is always initialized to 0, and I can’t find a place that changes it. if FID was 0, then `</span><span class="n" style="box-sizing: border-box; line-height: 18px; white-space: pre; background-color: rgb(255, 255, 255);">FID</span><span style="line-height: 18px; white-space: pre; background-color: rgb(255, 255, 255);"> </span><span class="o" style="box-sizing: border-box; font-weight: bold; line-height: 18px; white-space: pre; background-color: rgb(255, 255, 255);">+=</span><span style="line-height: 18px; white-space: pre; background-color: rgb(255, 255, 255);"> </span><span class="n" style="box-sizing: border-box; line-height: 18px; white-space: pre; background-color: rgb(255, 255, 255);">F</span><span class="p" style="box-sizing: border-box; line-height: 18px; white-space: pre; background-color: rgb(255, 255, 255);">.</span><span class="n" style="box-sizing: border-box; line-height: 18px; white-space: pre; background-color: rgb(255, 255, 255);">SLocEntryBaseID</span><span style="line-height: 18px; white-space: pre; background-color: rgb(255, 255, 255);"> </span><span class="o" style="box-sizing: border-box; font-weight: bold; line-height: 18px; white-space: pre; background-color: rgb(255, 255, 255);">-</span><span style="line-height: 18px; white-space: pre; background-color: rgb(255, 255, 255);"> </span><span class="mi" style="box-sizing: border-box; line-height: 18px; white-space: pre; background-color: rgb(255, 255, 255);">1</span><span class="p" style="box-sizing: border-box; line-height: 18px; white-space: pre; background-color: rgb(255, 255, 255);">;` would be -1? I see that FileIDs can be negative, but in this case it looks like an error to me.</span></div><div><span class="p" style="box-sizing: border-box; line-height: 18px; white-space: pre; background-color: rgb(255, 255, 255);"><br></span></div><div><span style="line-height: 18px; white-space: pre;">Perhaps I missed something? Does the serialization sometimes write out invalid FileIDs (meaning, 0 values) for some reason?</span></div><div><span style="line-height: 18px; white-space: pre;"><br></span></div><div><span style="line-height: 18px; white-space: pre;">Thanks,</span></div><div><span style="line-height: 18px; white-space: pre;">Jason</span></div><div><span class="p" style="box-sizing: border-box; color: rgb(51, 51, 51); font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; line-height: 18px; white-space: pre; background-color: rgb(255, 255, 255);"><br></span></div><div><span class="p" style="box-sizing: border-box; color: rgb(51, 51, 51); font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; line-height: 18px; white-space: pre; background-color: rgb(255, 255, 255);"><br></span></div></body></html>