Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Feb 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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