<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix"><br>
      On 11/5/12 6:18 AM, Erik Verbruggen wrote:<br>
    </div>
    <blockquote cite="mid:7FE48FD9-447A-4728-9F0C-CF03EE65F841@me.com"
      type="cite">
      <pre wrap="">When using libclang for syntax highlighting, I noticed that no AST nodes get built for e.g. invalid expressions. For example, in the following C++ code:

int func(int i) {
    int j = undefinedFunction(i) + i;
    return j;
}

the whole initialisation for int j gets dropped, including the (somewhat) valid references to i. I understand that this is done to keep the AST valid after parsing, but an IDE or refactoring tools cannot help out with fixing the problem in that snippet. My question: is there some way to keep the invalid AST nodes, or is somebody already working on this?</pre>
    </blockquote>
    Have you considered flagging the broken (invalid) nodes as
    dependent? There is a hook in clang::ExternalSemaSource::
    <meta http-equiv="content-type" content="text/html;
      charset=ISO-8859-1">
    <a class="el"
href="http://clang.llvm.org/doxygen/classclang_1_1ExternalSemaSource.html#a971a425e22c9ebbfb3a2c8deb032fc7f">LookupUnqualified</a>,
    which gets called by clang just before complaining about an error
    and dropping the node. At that point I believe you can declare the
    name as dependent (which will lead to creating a broken AST) and
    continue compilation. <br>
    <br>
    Does that make sense to you?<br>
    <br>
    Vassil<br>
    <blockquote cite="mid:7FE48FD9-447A-4728-9F0C-CF03EE65F841@me.com"
      type="cite">
      <pre wrap="">

Regards,
Erik.

_______________________________________________
cfe-dev mailing list
<a class="moz-txt-link-abbreviated" href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a>
<a class="moz-txt-link-freetext" href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>