Permalink
Browse files

Pass -stdlib=... to clang to get list of includes

Otherwise wrong library specific paths can be used (from default
standard library).

Closes #195.
  • Loading branch information...
1 parent 6b8216e commit 2831a5040ee328103b941fcdbc3c8d6ef5593b59 @xaizek xaizek committed Aug 29, 2012
Showing with 11 additions and 3 deletions.
  1. +8 −2 autoload/getopts/clang.vim
  2. +3 −1 doc/clang_complete.txt
View
10 autoload/getopts/clang.vim
@@ -2,8 +2,14 @@
" Author: leszekswirski
function! getopts#clang#getopts()
- let l:optfunc = 'echo | clang -v -E -x ' . getopts#cache#getlangname() . ' -'
- call getopts#cache#getcachedopts('clang', l:optfunc)
+ let l:all_options = g:clang_user_options . ' ' . b:clang_user_options
+ let l:stdlib = matchstr(l:all_options, '\C\M^\(\.\*\s\)\?\zs-stdlib=\S\+')
+
+ let l:lang_name = getopts#cache#getlangname()
+
+ let l:optfunc = 'echo | clang -v -E ' . l:stdlib . ' -x ' . l:lang_name . ' -'
+ let l:prefix = empty(l:stdlib) ? '' : (matchstr(l:stdlib, '\M=\zs\.\*') . '.')
+ call getopts#cache#getcachedopts(l:prefix . 'clang', l:optfunc)
endfunction
" vim: set ts=2 sts=2 sw=2 expandtab :
View
4 doc/clang_complete.txt
@@ -1,4 +1,4 @@
-*clang_complete.txt* For Vim version 7.3. Last change: 2012 Jul 29
+*clang_complete.txt* For Vim version 7.3. Last change: 2012 Aug 29
clang_complete plugin documentation
@@ -192,6 +192,8 @@ get a list of include paths. The list of include paths for each of supported
filetypes (c, cpp, objc and objcpp) is cached on a disk and can be removed by
calling the ClearIncludeCaches() function (for changes to take affect one
needs to reread buffers using the :edit command or something equivalent).
+Since list of included paths can depend on user options "clang" and "gcc"
+should appear at the end of the list of sources.
Default: "path, .clang_complete, clang"
*clang_complete-use_library*

0 comments on commit 2831a50

Please sign in to comment.