Skip to content

Commit

Permalink
Auto merge of #1193 - s4y:objcpp-needs-fixed-header-search-paths-too,…
Browse files Browse the repository at this point in the history
… r=micbou

Fix system header search paths on macOS for Objective-C++, too.

I've been running into ycm-core/YouCompleteMe#303, even though ycmd has a workaround for it. It looks like the issue is just that I'm writing ObjC++ and that change only affects C++.

So, this change makes `-x objective-c++` eligible, too.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/ycmd/1193)
<!-- Reviewable:end -->
  • Loading branch information
zzbot authored Feb 23, 2019
2 parents bb58a43 + 832ee83 commit 6d8ddd5
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
8 changes: 5 additions & 3 deletions ycmd/completers/cpp/flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,17 +532,17 @@ def _GetMacSysRoot():


def _ExtractInfoForMacIncludePaths( flags ):
language_is_cpp = True
language = 'c++'
use_libcpp = True
sysroot = _GetMacSysRoot()
isysroot = None

previous_flag = None
for current_flag in flags:
if previous_flag == '-x':
language_is_cpp = current_flag == 'c++'
language = current_flag
if current_flag.startswith( '-x' ):
language_is_cpp = current_flag[ 2: ] == 'c++'
language = current_flag[ 2: ]
if current_flag.startswith( '-stdlib=' ):
use_libcpp = current_flag[ 8: ] == 'libc++'
if previous_flag == '--sysroot':
Expand All @@ -559,6 +559,8 @@ def _ExtractInfoForMacIncludePaths( flags ):
if isysroot:
sysroot = isysroot

language_is_cpp = language in { 'c++', 'objective-c++' }

return language_is_cpp, use_libcpp, sysroot


Expand Down
26 changes: 26 additions & 0 deletions ycmd/tests/clang/flags_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,32 @@ def Settings( **kwargs ):
'-fspell-checking' ) )


@MacOnly
@patch( 'os.path.exists', lambda path: False )
def FlagsForFile_AddMacIncludePaths_ObjCppLanguage_test():
flags_object = flags.Flags()

def Settings( **kwargs ):
return {
'flags': [ '-Wall', '-x', 'c', '-xobjective-c++' ]
}

with MockExtraConfModule( Settings ):
flags_list, _ = flags_object.FlagsForFile( '/foo' )
assert_that( flags_list, contains(
'-Wall',
'-x', 'c',
'-xobjective-c++',
'-resource-dir=' + CLANG_RESOURCE_DIR,
'-isystem', '/usr/include/c++/v1',
'-isystem', '/usr/local/include',
'-isystem', os.path.join( CLANG_RESOURCE_DIR, 'include' ),
'-isystem', '/usr/include',
'-iframework', '/System/Library/Frameworks',
'-iframework', '/Library/Frameworks',
'-fspell-checking' ) )


@MacOnly
@patch( 'os.path.exists', lambda path: False )
def FlagsForFile_AddMacIncludePaths_CppLanguage_test():
Expand Down

0 comments on commit 6d8ddd5

Please sign in to comment.