<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">On Apr 5, 2013, at 4:20 AM, "Siedlarek, Mikołaj" <<a href="mailto:m.siedlarek@nctz.net">m.siedlarek@nctz.net</a>> wrote:<br><div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">On Fri, Apr 5, 2013 at 12:37 PM, Siedlarek, Mikołaj<br><<a href="mailto:m.siedlarek@nctz.net">m.siedlarek@nctz.net</a>> wrote:<br><blockquote type="cite">On Fri, Apr 5, 2013 at 12:22 AM, Argyrios Kyrtzidis <<a href="mailto:akyrtzi@gmail.com">akyrtzi@gmail.com</a>> wrote:<br><blockquote type="cite"><br>On Apr 2, 2013, at 1:33 AM, Mikołaj Siedlarek <<a href="mailto:m.siedlarek@nctz.net">m.siedlarek@nctz.net</a>> wrote:<br><br>Hi,<br><br>I'm writing a simple code dependency analysis tool using libclang and I'm missing some way of distinguishing system headers from user headers. I see clang::DirectoryLookup::getDirCharacteristic() provides such interface, but is there any way I could obtain this information using just libclang? My tool is rather simple and I'd like to keep it that way - libclang seems to be sufficient for the rest of my needs.<br><br><br>There is no way currently, but it should relatively easy, are you interested in providing such a patch ?<br>The clang function you may need to look into using is "SourceManager::isInSystemHeader(SourceLocation Loc)"<br>The libclang function would accept a CXTranslationUnit and a CXSourceLocation.<br></blockquote><br><br>How about this? That's the best and most elastic approach I could think of.<br></blockquote><br>There was unnecessary CINDEX_LINKAGE in the first version of my patch.<br>Here's corrected one.<br></div></blockquote><div><br></div><div><div>+ /**</div><div>+ * \brief System code which is implicitly 'extern "C"' in C++ mode</div><div>+ */</div><div>+ CXCharacteristicKind_ExternCSystem</div><div><br></div><div>This is very "legacy-hacky-compiler-specific"; I can't think of a reason that a libclang client would need to know this.</div><div><br></div><div>I suggest just adding a</div><div>int clang_SourceLocation_isInSystemHeader(CXSourceLocation location)</div><div>function.</div><div><br></div><div><br></div></div><br><blockquote type="cite"><div style="letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br>--<span class="Apple-converted-space"> </span><br>Mikołaj Siedlarek<br><a href="mailto:m.siedlarek@nctz.net">m.siedlarek@nctz.net</a><br><span><file-characteristics-v2.diff></span></div></blockquote></div><br></body></html>