| Index: tools/vim/chromium.ycm_extra_conf.py
|
| diff --git a/tools/vim/chromium.ycm_extra_conf.py b/tools/vim/chromium.ycm_extra_conf.py
|
| index bb988388d4c0c69413d501cdcca320848d0c01e5..2901c545dd08d8623a557fb2830f2b2f89b9c941 100644
|
| --- a/tools/vim/chromium.ycm_extra_conf.py
|
| +++ b/tools/vim/chromium.ycm_extra_conf.py
|
| @@ -39,10 +39,39 @@
|
|
|
| import os
|
| import os.path
|
| +import re
|
| import subprocess
|
| import sys
|
|
|
|
|
| +def SystemIncludeDirectoryFlags():
|
| + """Determines compile flags to include the system include directories.
|
| +
|
| + Use as a workaround for https://github.com/Valloric/YouCompleteMe/issues/303
|
| +
|
| + Returns:
|
| + (List of Strings) Compile flags to append.
|
| + """
|
| + try:
|
| + with open(os.devnull, 'rb') as DEVNULL:
|
| + output = subprocess.check_output(['clang', '-v', '-E', '-x', 'c++', '-'],
|
| + stdin=DEVNULL, stderr=subprocess.STDOUT)
|
| + except (FileNotFoundError, subprocess.CalledProcessError):
|
| + return []
|
| + includes_regex = r'#include <\.\.\.> search starts here:\s*' \
|
| + r'(.*?)End of search list\.'
|
| + includes = re.search(includes_regex, output.decode(), re.DOTALL).group(1)
|
| + flags = []
|
| + for path in includes.splitlines():
|
| + path = path.strip()
|
| + if os.path.isdir(path):
|
| + flags.append('-isystem')
|
| + flags.append(path)
|
| + return flags
|
| +
|
| +
|
| +_system_include_flags = SystemIncludeDirectoryFlags()
|
| +
|
| # Flags from YCM's default config.
|
| flags = [
|
| '-DUSE_CLANG_COMPLETER',
|
| @@ -196,7 +225,7 @@ def FlagsForFile(filename):
|
| chrome_root = FindChromeSrcFromFilename(filename)
|
| chrome_flags = GetClangCommandFromNinjaForFilename(chrome_root,
|
| filename)
|
| - final_flags = flags + chrome_flags
|
| + final_flags = flags + chrome_flags + _system_include_flags
|
|
|
| return {
|
| 'flags': final_flags,
|
|
|