Fix ycm config for headers without source

Instead of using hard-coded clang flags (which are missing important
flags and are thus not that useful), use the flags for some unrelated
C++ file.

R=ahaas@chromium.org

No-Try: true
Change-Id: I516df9431e8aad1a63e832aa28450475193fd404
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1955549
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: Andreas Haas <ahaas@chromium.org>
Reviewed-by: Michael Achenbach <machenbach@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65387}
This commit is contained in:
Clemens Backes 2019-12-09 12:32:27 +01:00 committed by Commit Bot
parent c6742529c3
commit d4a4d28552

View File

@ -103,27 +103,16 @@ def GetClangCommandFromNinjaForFilename(v8_root, filename):
# Header files can't be built. Instead, try to match a header file to its
# corresponding source file.
if filename.endswith('.h'):
alternates = ['.cc', '.cpp']
for alt_extension in alternates:
alt_name = filename[:-2] + alt_extension
if os.path.exists(alt_name):
filename = alt_name
base = filename[:-6] if filename.endswith('-inl.h') else filename[:-2]
for alternate in [base + e for e in ['.cc', '.cpp']]:
if os.path.exists(alternate):
filename = alternate
break
else:
if filename.endswith('-inl.h'):
for alt_extension in alternates:
alt_name = filename[:-6] + alt_extension
if os.path.exists(alt_name):
filename = alt_name
break;
else:
# If this is a standalone -inl.h file with no source, the best we can
# do is try to use the default flags.
return v8_flags
else:
# If this is a standalone .h file with no source, the best we can do is
# try to use the default flags.
return v8_flags
# If this is a standalone .h file with no source, we ask ninja for the
# compile flags of some generic cc file ('src/utils/utils.cc'). This
# should contain most/all of the interesting flags for other targets too.
filename = os.path.join(v8_root, 'src', 'utils', 'utils.cc')
sys.path.append(os.path.join(v8_root, 'tools', 'ninja'))
from ninja_output import GetNinjaOutputDirectory