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 76fce6761164f7f6aa976c93899f4ca1aeb6e049..091a5ac5503368ed08a5e33e2df9b2d52c025e64 100644 |
--- a/tools/vim/chromium.ycm_extra_conf.py |
+++ b/tools/vim/chromium.ycm_extra_conf.py |
@@ -44,17 +44,23 @@ import subprocess |
import sys |
-def SystemIncludeDirectoryFlags(): |
+def SystemIncludeDirectoryFlags(clang_binary, clang_flags): |
"""Determines compile flags to include the system include directories. |
Use as a workaround for https://github.com/Valloric/YouCompleteMe/issues/303 |
+ Args: |
+ clang_binary: (String) Path to clang binary. |
+ clang_flags: (List of Strings) List of additional flags to clang. It may |
+ affect the choice of system include directories if -stdlib= is specified. |
+ |
Returns: |
(List of Strings) Compile flags to append. |
""" |
+ all_flags = ['-v', '-E', '-x', 'c++'] + clang_flags + ['-'] |
try: |
with open(os.devnull, 'rb') as DEVNULL: |
- output = subprocess.check_output(['clang', '-v', '-E', '-x', 'c++', '-'], |
+ output = subprocess.check_output([clang_binary] + all_flags, |
stdin=DEVNULL, stderr=subprocess.STDOUT) |
except: |
return [] |
@@ -69,18 +75,14 @@ def SystemIncludeDirectoryFlags(): |
flags.append(path) |
return flags |
- |
-_system_include_flags = SystemIncludeDirectoryFlags() |
- |
# Flags from YCM's default config. |
-flags = [ |
-'-DUSE_CLANG_COMPLETER', |
-'-std=c++11', |
-'-x', |
-'c++', |
+_default_flags = [ |
+ '-DUSE_CLANG_COMPLETER', |
+ '-std=c++11', |
+ '-x', |
+ 'c++', |
] |
- |
def PathExists(*args): |
return os.path.exists(os.path.join(*args)) |
@@ -208,6 +210,10 @@ def GetClangCommandFromNinjaForFilename(chrome_root, filename): |
continue |
chrome_flags.append(flag) |
+ clang_path = clang_line.split(' ')[0] |
eroman
2015/05/18 17:56:42
This is too simplistic, the "path" may contain spa
asanka
2015/05/18 19:36:48
That's also a no-go due to the gomacc wrapper not
|
+ if clang_path.endswith('clang++'): |
+ chrome_flags += SystemIncludeDirectoryFlags(clang_path, chrome_flags) |
+ |
return chrome_flags |
@@ -225,7 +231,7 @@ def FlagsForFile(filename): |
chrome_root = FindChromeSrcFromFilename(filename) |
chrome_flags = GetClangCommandFromNinjaForFilename(chrome_root, |
filename) |
- final_flags = flags + chrome_flags + _system_include_flags |
+ final_flags = _default_flags + chrome_flags |
return { |
'flags': final_flags, |