Permalink
Browse files

Do not provide the clang/gcc autoloader any more

The clang and gcc autoloaders are not necessary any more to optain the
system include paths. Due to the previous commit, the include paths are
now correctly added by the clang driver. libclang always used internally
the clang driver and never had problems finding the system include paths.

We remove these options as incorrectly derived include paths can cause
all kind of spurious problems.

We now print the following message, if someone manually adds 'clang' or
'gcc' to the auto_user_options:

  'gcc' in clang_auto_user_options is deprecated.
  • Loading branch information...
tobig committed Jan 12, 2013
1 parent 954410d commit 8ecd3a0419948c31d1354ad51d12e9aeb5f4ddb8
Showing with 6 additions and 126 deletions.
  1. +0 −92 autoload/getopts/cache.vim
  2. +0 −15 autoload/getopts/clang.vim
  3. +0 −9 autoload/getopts/gcc.vim
  4. +1 −9 doc/clang_complete.txt
  5. +5 −1 plugin/clang_complete.vim
View
@@ -1,92 +0,0 @@
-" clang_complete include paths caching helper
-" Author: xaizek, leszekswirski
-
-let s:scr = expand('<sfile>')
-let s:cache_path = fnamemodify(s:scr, ':p:h')
-
-function! getopts#cache#getcachedopts(ext, optfunc)
- let s:cache = s:cache_path . '/' . &filetype . '.' . a:ext . '.cache'
- if !s:CacheExists()
- call s:CreateCache(a:optfunc)
- endif
- call s:ReadCache()
- call s:AppendOptions()
-endfunction
-
-function! ClearIncludeCaches()
- let l:cache_files = split(globpath(s:cache_path, '*.cache', 1), "\n")
- for l:cache_file in l:cache_files
- call delete(l:cache_file)
- endfor
- unlet! s:opts
-endfunction
-
-function! getopts#cache#getlangname()
- if &filetype == 'c'
- let l:lang_name = 'c'
- elseif &filetype == 'cpp'
- let l:lang_name = 'c++'
- elseif &filetype == 'objc'
- let l:lang_name = 'objective-c'
- elseif &filetype == 'objcpp'
- let l:lang_name = 'objective-c++'
- elseif
- let l:lang_name = 'none'
- endif
- return l:lang_name
-endfunction
-
-function! s:CacheExists()
- if !filereadable(s:cache)
- return 0
- endif
-
- let l:lines = readfile(s:cache)
-
- for l:line in l:lines
- let l:line = substitute(l:line, '^\s\+', '', '')
- if l:line =~ '^-I' && !isdirectory(l:line[2:])
- return 0
- endif
- endfor
-
- return len(l:lines) > 0
-endfunction
-
-function! s:CreateCache(optfunc)
- let s:opts = s:GetOptions(a:optfunc)
- call writefile(s:opts, s:cache)
-endfunction
-
-function! s:GetOptions(optfunc)
- let l:out = split(system(a:optfunc), "\n")
-
- while !empty(l:out) && l:out[0] !~ '^#include <...>'
- let l:out = l:out[1:]
- endwhile
- if !empty(l:out)
- let l:out = l:out[1:]
- endif
-
- let l:result = []
- while !empty(l:out) && l:out[0] !~ '^End of search list.$'
- let l:inc_path = substitute(l:out[0], '^\s*', '', '')
- let l:inc_path = fnamemodify(l:inc_path, ':p')
- let l:inc_path = substitute(l:inc_path, '\', '/', 'g')
-
- if isdirectory(l:inc_path)
- call add(l:result, '-I' . l:inc_path)
- endif
-
- let l:out = l:out[1:]
- endwhile
- return l:result
-endfunction
-
-function! s:ReadCache()
- let s:opts = readfile(s:cache)
-endfunction
-
-function! s:AppendOptions()
- let b:clang_user_options .= ' ' . join(s:opts, ' ')
-endfunction
View
@@ -1,15 +0,0 @@
-" clang_complete clang's include paths finder
-" Author: leszekswirski
-
-function! getopts#clang#getopts()
- 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
@@ -1,9 +0,0 @@
-" clang_complete gcc's include paths finder
-" Author: leszekswirski
-
-function! getopts#gcc#getopts()
- let l:optfunc = 'echo | gcc -v -E -x ' . getopts#cache#getlangname() . ' -'
- call getopts#cache#getcachedopts('gcc', l:optfunc)
-endfunction
-
-" vim: set ts=2 sts=2 sw=2 expandtab :
View
@@ -192,15 +192,7 @@ Set sources for user options passed to clang. Available sources are:
This option is processed and all sources are used on buffer loading, not each
time before doing completion.
-Two examples of custom option sources is bundled with clang_complete and are
-called "clang" and "gcc". These sources run clang and gcc, respectively, to
-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"
+Default: "path, .clang_complete"
*clang_complete-compilation_database*
*g:clang_compilation_database*
@@ -97,7 +97,7 @@ function! s:ClangCompleteInit()
endif
if !exists('g:clang_auto_user_options')
- let g:clang_auto_user_options = 'path, .clang_complete, clang'
+ let g:clang_auto_user_options = 'path, .clang_complete'
endif
call LoadUserOptions()
@@ -182,6 +182,10 @@ function! LoadUserOptions()
let l:option_sources = map(l:option_sources, l:remove_spaces_cmd)
for l:source in l:option_sources
+ if l:source == 'gcc' || l:source == 'clang'
+ echo "'" . l:source . "' in clang_auto_user_options is deprecated."
+ continue
+ endif
if l:source == 'path'
call s:parsePathOption()
elseif l:source == 'compile_commands.json' && g:clang_use_library == 1

0 comments on commit 8ecd3a0

Please sign in to comment.