<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hello!<br>
<br>
Im working with libclang3.7~svn242178-1~exp1 (with little modified
ClangSharp bindings) and i'd like to save and reload serialized
translation units to improve loading time of C/C++ projects in
MonoDevelop.<br>
I use this code snippet to save header files:<br>
<br>
<meta http-equiv="CONTENT-TYPE" content="text/html; charset=utf-8">
CXTranslationUnit save;<br>
ec = clang.parseTranslationUnit2
(Index,name,null,0,null,0,(uint)CXTranslationUnit_Flags.ForSerialization,out
save);<br>
error |= ec != CXErrorCode.Success;<br>
if (!error) {<br>
se = (CXSaveError)clang.saveTranslationUnit (pch, name +
".save", clang.defaultSaveOptions (pch));<br>
error |= se != CXSaveError.CXSaveError_None;<br>
}<br>
clang.disposeTranslationUnit (save);
<meta name="GENERATOR" content="Mono Text Editor">
<br>
<br>
I checked, the save happens with <em>CXSaveError_None</em>, and to
load them i use this snippet, to show my problem, also reparsing
them just after the load:<br>
<br>
<meta http-equiv="CONTENT-TYPE" content="text/html; charset=utf-8">
<tt>CXTranslationUnit load;<br>
CXErrorCode ec = clang.createTranslationUnit2 (index, fileName +
".pch", out load);<br>
uint numDiag = clang.getNumDiagnostics (load);<br>
for (uint i = 0; i < numDiag; i++) {<br>
CXDiagnostic diag = clang.getDiagnostic (load, i);<br>
Console.WriteLine ("Loaded TU diagnostic: " + diag);<br>
}<br>
Console.WriteLine ("Loading: " + ec);<br>
if (ec != CXErrorCode.Success)<br>
return;<br>
else {<br>
Console.WriteLine ("Reparsing TU: " +
(CXErrorCode)clang.reparseTranslationUnit (load, 0, null,
clang.defaultReparseOptions (load)));</tt><br>
<br>
The output of the code:<br>
<pre wrap="">"Loading: Success
Reparsing TU: Failure"
</pre>
So my questions are:<br>
a., is this normal?<br>
b., if not, what i am doing wrong? I tried to play with parse flags,
but it made no difference.<br>
<br>
c., now i create a new TU just to save it, because saving a TU,
reparsing it, saving it again causes an a crash in libclang, is this
a bug or a feature?<br>
Related stacktrace:<br>
libclang37.so(+0x597335) [0x7f4eb89be335]<br>
libclang37.so(+0x5a1e00) [0x7f4eb89c8e00]<br>
libclang37.so(+0x5c10aa) [0x7f4eb89e80aa]<br>
libclang37.so(+0x5c403e) [0x7f4eb89eb03e]<br>
libclang37.so(+0x24551c) [0x7f4eb866c51c]<br>
libclang37.so(+0x253958) [0x7f4eb867a958]<br>
libclang37.so(+0x256c6e) [0x7f4eb867dc6e]<br>
libclang37.so(+0x1a656f) [0x7f4eb85cd56f]<br>
libclang37.so(clang_saveTranslationUnit+0x1ae) [0x7f4eb85e221e]<br>
[0x4201db2b]<br>
<br>
<br>
Thanks,<br>
Daniel<br>
</body>
</html>