<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Feb 18, 2010, at 3:10 AM, Tomohiro Matsuyama wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div>Hi all,<br><br>I'm working on C++ code completion in Emacs by using -code-completion-at option.<br>I know C++ is not fully supported yet, but It seems work well (I'm<br>looking forward it).<br>However, I have also found that incremental compiler is not seen, which is the<br>most important part for code-completion.<br><br>So, where can I find incremental compiler? And how can I use it to<br>make code-completion<br>faster? </div></blockquote><div><br></div><div>Clang does not support incremental compilation, although that's certainly a long-term goal.</div><div><br></div><div>First, obvious question: are you using a Release build of Clang, rather than a Debug build? There's more than an order of magnitude of difference between the two, and I've found a Release build to be reasonably responsive.</div><div><br></div><blockquote type="cite"><div>If you don't implement it yet, how can I start to implement it?<br></div></blockquote><div><br></div><div>Here are three ideas:</div><div><br></div><div>  - First, start with precompiled headers. You can build a precompiled header for the file you're code-completing in (which consists of, say, all of the #includes at the top). Then, Clang doesn't have to parse that code each time you run code-completion. Precompiled headers aren't yet implemented for C++, so that would be the right place to start.</div><div><br></div><div>  - Second, teach Clang how to skip parsing function bodies when performing code completion, caching or throwing away the tokens if the code-completion token isn't within that function definition. Here, you'd hook into Clang's Parse module where it parses a function definition. That should eliminate a lot of work that won't affect how code-completion behaves.</div><div><br></div><div>  - Finally, consider real incremental parsing. It's going to be tricky, because you  would need to teach both Parse and Sema how to pretend that they're in a particular compilation context to re-parse the code you're in (e.g., if you're inside a function definition). I recommend trying this only if the other two, combined, don't make code-completion fast enough for you.</div><div><br></div><blockquote type="cite"><div>Actually, all what I need is just incremental parser, not incremental compiler.<font class="Apple-style-span" color="#000000"><font class="Apple-style-span" color="#144FAE"><br></font></font></div></blockquote><br></div><div>Parsing and semantic analysis will need to be incremental for code completion to work. You won't need incremental code generation.</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">   </span>- Doug</div></body></html>