Skip to content

Commit

Permalink
YCM: guess at compile flags for new cpp files not yet in database.
Browse files Browse the repository at this point in the history
  • Loading branch information
Chase Geigle committed Jun 3, 2015
1 parent 1052d93 commit a64f07a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion contrib/YouCompleteMe/ycm_extra_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit a64f07a

Please sign in to comment.