<div dir="ltr">Sorry for hijacking this thread. I was looking into this issue few months ago and Reid suggested allowing tools to recover from partial AST in this case. I wanted to add a flag -fskip-inline-asm or something along those lines that would enable tools not to choke on code like this (some x86 windows system header files have inline asm). What do others think?</div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jul 13, 2015 at 10:38 PM, Han Wang <span dir="ltr"><<a href="mailto:wanghan02@gmail.com" target="_blank">wanghan02@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Thanks Ben, <div><br></div><div>The initialisations do work! Thank you very much. </div><div><br></div><div>I still have 1 question. What are the differences between these 2 forms? </div><div><br></div><div>1. use clang to compile a file: <span style="background-color:rgb(255,242,204)">clang++ -c test.cpp</span></div><div>2. use clang tooling to parse a file ./foo.out test.cpp -- <span style="background-color:rgb(255,242,204)">clang++ -c test.cpp</span></div><div><span style="background-color:rgb(255,242,204)"><br></span></div>Best regards,<br>Han</div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jul 13, 2015 at 2:02 PM, Benjamin Kramer <span dir="ltr"><<a href="mailto:benny.kra@gmail.com" target="_blank">benny.kra@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>On Mon, Jul 13, 2015 at 12:20 PM, Han Wang <<a href="mailto:wanghan02@gmail.com" target="_blank">wanghan02@gmail.com</a>> wrote:<br>
> Hi,<br>
><br>
> I have a simple file containing some Microsoft style inline asm. I can<br>
> compile this file with -fms-extensions.<br>
><br>
> clang++ -fms-extensions -c test.cpp<br>
><br>
> No problem for this.<br>
><br>
> But when I write a simple AST Matcher tool (foo.out) to parse this file, I<br>
> got errors.<br>
><br>
> ./foo.out test.cpp -- clang++ -fms-extensions -c test.cpp<br>
> test.cpp:19:3: error: MS-style inline assembly is not available: Unable to<br>
> find target for this triple (no targets are registered)<br>
>   __asm {<br>
>   ^<br>
> test.cpp:28:3: error: MS-style inline assembly is not available: Unable to<br>
> find target for this triple (no targets are registered)<br>
>   __asm mov a1, 2<br>
>   ^<br>
> 2 errors generated.<br>
> Error while processing test.cpp.<br>
<br>
</span>This is most likely due to missing target initialization in your tool.<br>
MS-style asm is special as it has to be parsed by clang, requiring<br>
target support. GCC-style asm is parsed much later.<br>
<br>
Solving it should be as simple as putting<br>
<br>
llvm::InitializeAllTargets();<br>
llvm::InitializeAllTargetMCs();<br>
llvm::InitializeAllAsmPrinters();<br>
llvm::InitializeAllAsmParsers();<br>
<br>
in your main() function (or wherever the rest of clang is initialized).<br>
<span><br>
> There are also some other problems when parsing test.cpp. For example if I<br>
> #include <string>, I have to use -- clang++ -I<path-to-string> to identify<br>
> the system header file path. I'm not sure what makes it different then the<br>
> normal clang compile.<br>
<br>
</span>Mainline clang doesn't use headers from xcode.app. The easiest way<br>
around that is just checking out libc++ into your LLVM tree.<br>
<br>
- Ben<br>
</blockquote></div><br></div>
</div></div><br>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br></div>