clang_parseTranslationUnit

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

clang_parseTranslationUnit

Hubert Tong via cfe-dev
Hello,

I maintain ffi-clang for Ruby.

We recently started reworking the gem to support llvm 10.0 - the last
supported release was llvm 4.0 which was a while ago.

So, most things seem to be working fine - we have several hundred
tests. However, I had some trouble with `clang_parseTranslationUnit`.

It seems like it's not picking up the system include directories.

We have the following code to parse a translation unit:

let(:filename) { fixture_path("completion.cpp") }
let(:translation_unit) { Index.new.parse_translation_unit(filename) }

`parse_translation_unit` basically calls clang_parseTranslationUnit

But, in llvm 4.0, it seems this automatically detected file type and
exposed stdc++ headers. But with llvm 10.0 - it seems I need to
manually add header search paths. Doing something like the following
worked:

let(:includes) {[
  "-I/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../include/c++/10.2.0",
  "-I/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../include/c++/10.2.0/x86_64-pc-linux-gnu",
  "-I/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/../../../../include/c++/10.2.0/backward",
  "-I/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/include",
  "-I/usr/local/include",
  "-I/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/include-fixed",
"-I/usr/include",
]}
let(:translation_unit) { Index.new.parse_translation_unit(filename,
[*includes]) }

I don't know if there is a better set of arguments to pass to
`clang_parseTranslationUnit` that behaves the same was as before i.e.
implicitly figures out what include paths to use.

By the way, I figured out what include paths to use by running:

echo "" | clang++ -v -x c++ -E -

So, it's definitely the case that at least `clang++` knows where those
headers are.

Thanks!
Samuel
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev