From d9f45d576f610f3037eead64e81cea0d9a1005f5 Mon Sep 17 00:00:00 2001 From: Strahinja Val Markovic Date: Fri, 24 May 2013 14:29:33 -0700 Subject: [PATCH] Fix breakage of some compile_commands.json users Depending on the user, the PrepareClangFlags rewrite of a few commits ago could break users with an extra "clang: 'linker' input not used" (or similar) error message because the compiler executable string was not removed from flags upstream if the user prepended some flags to the output of PrepareClangFlags before returning it to the caller of FlagsForFile. Since the rewrite was supposed to be backwards compatible, this needs to be handled. --- python/ycm/completers/cpp/clang_helpers.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/python/ycm/completers/cpp/clang_helpers.py b/python/ycm/completers/cpp/clang_helpers.py index fa5724ca..ae8374af 100644 --- a/python/ycm/completers/cpp/clang_helpers.py +++ b/python/ycm/completers/cpp/clang_helpers.py @@ -18,8 +18,10 @@ # along with YouCompleteMe. If not, see . -# This function doesn't do anything; it used to do something useful, but not -# anymore. It MUST NOT be removed because of backwards compatibility with old -# ycm_extra_conf.py files. def PrepareClangFlags( flags, filename ): + # When flags come from the compile_commands.json file, the first flag is + # usually the path to the compiler that should be invoked. We want to strip + # that. + if not flags[ 0 ].startswith( '-' ): + return flags[ 1: ] return flags