<html><head><meta http-equiv="Content-Type" content="text/html charset=iso-8859-1"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">On Apr 4, 2013, at 12:14 AM, Oliver Giles <<a href="mailto:ogtifs@gmail.com">ogtifs@gmail.com</a>> wrote:<br><div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">I just tried this again with the latest clang from svn. The original snippet works but the next lines in my original code are:<br><br>CXCursor cursor = clang_getTranslationUnitCursor(tu);<br>CXSourceRange sr = clang_getCursorExtent(cursor);<br>CXToken* tokens;<br>unsigned numtokens;<br>clang_tokenize(tu, sr, &tokens, &numtokens);<br>CXCursor* cursors = new CXCursor[numtokens];<br>clang_annotateTokens(tu, tokens, numtokens, cursors);<br><br>Appending even the first line of this (clang_getTranslationUnitCursor) to the example I gave earlier causes a segfault in the clang 3.3 library.<br></div></blockquote><div><br></div><div>Fixed in r178800. FYI, it looks like the CXTranslationUnit object that you get is null, so there was a problem during parsing.</div><br><blockquote type="cite"><div style="letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br>Oliver<br><br>On 2013-01-16 20:14, Argyrios Kyrtzidis wrote:<br><blockquote type="cite">Fixed in r172632, thanks!<br><br>On Jan 15, 2013, at 9:36 PM, Oliver <<a href="mailto:ogtifs@gmail.com">ogtifs@gmail.com</a>> wrote:<br><br><blockquote type="cite">Hi,<br>Some example code for document editing I was using with clang 3.1 now segfaults on clang 3.2:<br><br>#include <clang-c/Index.h><br>#include <string.h><br><br>char DOCUMENT[] = "int main() { return 0; }\n";<br><br>int main(int argc, char** argv) {<br><span class="Apple-tab-span" style="white-space: pre;">       </span>const char* args;<br><span class="Apple-tab-span" style="white-space: pre;">       </span>CXIndex ci = clang_createIndex(0,0);<br><span class="Apple-tab-span" style="white-space: pre;">    </span>CXTranslationUnit tu =<br><span class="Apple-tab-span" style="white-space: pre;">  </span><span class="Apple-tab-span" style="white-space: pre;">  </span><span class="Apple-tab-span" style="white-space: pre;">  </span>clang_parseTranslationUnit(ci, "main.cpp", &args,<br><span class="Apple-tab-span" style="white-space: pre;"> </span><span class="Apple-tab-span" style="white-space: pre;">  </span><span class="Apple-tab-span" style="white-space: pre;">  </span><span class="Apple-converted-space"> </span>0, NULL, 0, clang_defaultEditingTranslationUnitOptions());<br><span class="Apple-tab-span" style="white-space: pre;">       </span>CXUnsavedFile file;<br><span class="Apple-tab-span" style="white-space: pre;">     </span>file.Filename = "main.cpp";<br><span class="Apple-tab-span" style="white-space: pre;">   </span>file.Contents = DOCUMENT;<br><span class="Apple-tab-span" style="white-space: pre;">       </span>file.Length = strlen(DOCUMENT);<br><span class="Apple-tab-span" style="white-space: pre;"> </span>clang_reparseTranslationUnit(tu, 1, &file, clang_defaultEditingTranslationUnitOptions());<br><span class="Apple-tab-span" style="white-space: pre;">   </span>return 0;<br>}<br><br>Output is:<br>libclang: crash detected during reparsing<br>Segmentation fault (core dumped)<br><br>Am I doing something perverted or is this a bug?<br><br>Oliver<br>_______________________________________________<br>cfe-dev mailing list<br><a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</blockquote></blockquote></div></blockquote></div><br></body></html>