-
Notifications
You must be signed in to change notification settings - Fork 769
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add system header directories to user flags
- Loading branch information
Showing
8 changed files
with
359 additions
and
242 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,9 @@ | |
*.la | ||
*.a | ||
|
||
# Executables | ||
ycm_fake_clang* | ||
|
||
# Clang archives | ||
clang_archives | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
39 | ||
40 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Copyright (C) 2018 ycmd contributors | ||
# | ||
# This file is part of ycmd. | ||
# | ||
# ycmd is free software: you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License as published by | ||
# the Free Software Foundation, either version 3 of the License, or | ||
# (at your option) any later version. | ||
# | ||
# ycmd is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
# GNU General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU General Public License | ||
# along with ycmd. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
project( ycm_fake_clang ) | ||
cmake_minimum_required( VERSION 2.8 ) | ||
|
||
include_directories( ${ycm_core_SOURCE_DIR} ) | ||
|
||
add_executable( ${PROJECT_NAME} main.cpp ) | ||
|
||
target_link_libraries( ${PROJECT_NAME} | ||
${LIBCLANG_TARGET} ) | ||
|
||
# Build ycm_fake_clang in ycmd root folder. | ||
if ( MSVC ) | ||
foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} ) | ||
string( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG ) | ||
set_target_properties( ${PROJECT_NAME} PROPERTIES | ||
RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${PROJECT_SOURCE_DIR}/../../.. ) | ||
endforeach() | ||
else() | ||
set_target_properties( ${PROJECT_NAME} PROPERTIES | ||
RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/../../.. ) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright (C) 2018 ycmd contributors | ||
// | ||
// This file is part of ycmd. | ||
// | ||
// ycmd is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// ycmd is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with ycmd. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
#include <clang-c/Index.h> | ||
#include <iostream> | ||
|
||
// This small program simulates the output of the clang executable when ran with | ||
// the -E and -v flags. It takes a list of flags as arguments and creates the | ||
// corresponding translation unit. When retrieving user flags, ycmd executes | ||
// this program as follows | ||
// | ||
// ycm_fake_clang -resource-dir=... [flag ...] -E -v filename | ||
// | ||
// and extract the list of system header paths from the output. These | ||
// directories are then added to the list of flags to provide completion of | ||
// system headers in include statements and allow jumping to these headers. | ||
int main( int argc, char **argv ) { | ||
CXIndex index = clang_createIndex( 0, 0 ); | ||
CXTranslationUnit tu; | ||
CXErrorCode result = clang_parseTranslationUnit2FullArgv( | ||
index, nullptr, argv, argc, nullptr, 0, CXTranslationUnit_None, &tu ); | ||
if ( result != CXError_Success ) { | ||
return EXIT_FAILURE; | ||
} | ||
|
||
clang_disposeTranslationUnit( tu ); | ||
return EXIT_SUCCESS; | ||
} |
Oops, something went wrong.