Clang and XML output

Hi,

I’m developing a small C / C++ / ObjC IDE and I plan to use Clang “behind the wall” for all the highlighting, completion and semantic stuff about the code .

I know Clang has an -as-xml-output option, but the generated XML is far too complicated to be used as is, and I was wondering if there is some function I’m not aware about, producing XML (or any markup language) more like this tool ( http://42ndart.org/scalpel/demonstration.html ).

int
main(int argc, char** argv)
{
	std::cout << "Hello, World!" << std::endl;
	return 0;
}
<namespace>
 <function name="main">
  <return_type>
   <built_in_type type="int"/>
  </return_type>
  <parameters>
   <parameter name="argc">
    <type>
     <built_in_type type="int"/>
    </type>
   </parameter>
   <parameter name="argv">
    <type>
     <pointer>
      <pointer>
       <built_in_type type="char"/>
      </pointer>
     </pointer>
    </type>
   </parameter>
  </parameters>
 </function>
</namespace>

Sorry for my poor english, and thanks for this amazing compiler .

Matthieu.

That is not the purpose of the XML, and would actually make things
*vastly* more difficult if it was compared to the current support in
Clang of what you want to do.

For "highlighting, completion and semantic stuff', Clang has libraries
specifically for that, contain just about any information that you
could want, and at a great deal faster and more detailed then the XML
could provide (source code locations, macro expansions (bit-by-bit
even), links to what uses what and where they are used and where
something is instanced and so on and so forth, information that if
dumped into XML form would probably fill the process memory.

Hi,

I’m developing a small C / C++ / ObjC IDE and I plan to use Clang “behind the wall” for all the highlighting, completion and semantic stuff about the code .

I suggest looking at libclang: http://clang.llvm.org/doxygen/group__CINDEX.html

I know Clang has an -as-xml-output option, but the generated XML is far too complicated to be used as is, and I was wondering if there is some function I’m not aware about, producing XML (or any markup language) more like this tool ( http://42ndart.org/scalpel/demonstration.html ).

XML is the wrong tool for the job. Just formatting and then re-parsing all of the data you would need for these tasks would take more time than you have within the UI.

  • Doug