From a64f07a8d0642c1f7acf486378e5892590500b0c Mon Sep 17 00:00:00 2001 From: Chase Geigle Date: Tue, 2 Jun 2015 20:33:32 -0500 Subject: [PATCH] YCM: guess at compile flags for new cpp files not yet in database. --- contrib/YouCompleteMe/ycm_extra_conf.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/contrib/YouCompleteMe/ycm_extra_conf.py b/contrib/YouCompleteMe/ycm_extra_conf.py index 662e24e09..eaa0d260d 100644 --- a/contrib/YouCompleteMe/ycm_extra_conf.py +++ b/contrib/YouCompleteMe/ycm_extra_conf.py @@ -77,8 +77,16 @@ def GetCompilationInfoForFile(filename): if not os.path.exists(filename): return None - return database.GetCompilationInfoForFile(filename) + compilation_info = database.GetCompilationInfoForFile(filename) + if not compilation_info or len(compilation_info.compiler_flags_) == 0: + # if we couldn't find this in the compilation database, it's probably a + # new cpp file, so fall back to the flags for profile.cpp + cpp_name = os.path.join(DirectoryOfThisScript(), 'src', 'tools', + 'profile.cpp') + compilation_info = database.GetCompilationInfoForFile(cpp_name) + + return compilation_info def FlagsForFile( filename ): compilation_info = GetCompilationInfoForFile(filename)