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

[READY] Hide C++ symbols by default #848

Merged
merged 1 commit into from
Dec 23, 2017
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
23 changes: 23 additions & 0 deletions cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,29 @@ endif()

#############################################################################

# MSVC has symbols hidden by default. On GCC and Clang we need to explicitly
# set the visibility to hidden to achieve the same result and then manually
# expose what we need. This results in smaller ycm_core dynamic library and thus
# a shorter loading time and higher performance.
if( CMAKE_COMPILER_IS_GNUCXX OR COMPILER_IS_CLANG )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fvisibility=hidden" )
endif()

if ( DEFINED ENV{YCM_BENCHMARK} OR DEFINED ENV{YCM_TESTRUN})
if ( MSVC )
add_definitions( -DYCM_EXPORT=__declspec\(\ dllexport\ \) )
elseif( CMAKE_COMPILER_IS_GNUCXX OR COMPILER_IS_CLANG )
add_definitions(
-DYCM_EXPORT=__attribute__\(\(visibility\(\"default\"\)\)\) )
else()
add_definitions( -DYCM_EXPORT= )
endif()
else()
add_definitions( -DYCM_EXPORT= )
endif()

#############################################################################

# Force release build by default, speed is of the essence
if ( NOT CMAKE_BUILD_TYPE )
set( CMAKE_BUILD_TYPE Release )
Expand Down
5 changes: 3 additions & 2 deletions cpp/ycm/.ycm_extra_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,10 @@
'-Wno-variadic-macros',
'-fexceptions',
'-DNDEBUG',
# You 100% do NOT need -DUSE_CLANG_COMPLETER in your flags; only the YCM
# source code needs it.
# You 100% do NOT need -DUSE_CLANG_COMPLETER and/or -DYCM_EXPORT in your flags;
# only the YCM source code needs it.
'-DUSE_CLANG_COMPLETER',
'-DYCM_EXPORT=',
# THIS IS IMPORTANT! Without the '-x' flag, Clang won't know which language to
# use when compiling headers. So it will guess. Badly. So C++ headers will be
# compiled as C headers. You don't want that so ALWAYS specify the '-x' flag.
Expand Down
9 changes: 4 additions & 5 deletions cpp/ycm/Candidate.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#ifndef CANDIDATE_H_R5LZH6AC
#define CANDIDATE_H_R5LZH6AC

#include "DLLDefines.h"
#include "LetterNode.h"

#include <memory>
Expand All @@ -31,15 +30,15 @@ class Result;

typedef std::bitset< NUM_LETTERS > Bitset;

YCM_DLL_EXPORT Bitset LetterBitsetFromString( const std::string &text );
YCM_EXPORT Bitset LetterBitsetFromString( const std::string &text );

// Public for tests
YCM_DLL_EXPORT std::string GetWordBoundaryChars( const std::string &text );
YCM_EXPORT std::string GetWordBoundaryChars( const std::string &text );

class Candidate {
public:

YCM_DLL_EXPORT explicit Candidate( const std::string &text );
YCM_EXPORT explicit Candidate( const std::string &text );
// Make class noncopyable
Candidate( const Candidate& ) = delete;
Candidate& operator=( const Candidate& ) = delete;
Expand All @@ -54,7 +53,7 @@ class Candidate {
return ( letters_present_ & query_bitset ) == query_bitset;
}

YCM_DLL_EXPORT Result QueryMatchResult( const std::string &query,
YCM_EXPORT Result QueryMatchResult( const std::string &query,
bool case_sensitive ) const;

private:
Expand Down
8 changes: 3 additions & 5 deletions cpp/ycm/CandidateRepository.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
#ifndef CANDIDATEREPOSITORY_H_K9OVCMHG
#define CANDIDATEREPOSITORY_H_K9OVCMHG

#include "DLLDefines.h"

#include <vector>
#include <string>
#include <unordered_map>
Expand All @@ -43,18 +41,18 @@ CandidateHolder;
// This class is thread-safe.
class CandidateRepository {
public:
YCM_DLL_EXPORT static CandidateRepository &Instance();
YCM_EXPORT static CandidateRepository &Instance();
// Make class noncopyable
CandidateRepository( const CandidateRepository& ) = delete;
CandidateRepository& operator=( const CandidateRepository& ) = delete;

int NumStoredCandidates();

YCM_DLL_EXPORT std::vector< const Candidate * > GetCandidatesForStrings(
YCM_EXPORT std::vector< const Candidate * > GetCandidatesForStrings(
const std::vector< std::string > &strings );

// This should only be used to isolate tests and benchmarks.
YCM_DLL_EXPORT void ClearCandidates();
YCM_EXPORT void ClearCandidates();

private:
CandidateRepository() {};
Expand Down
21 changes: 10 additions & 11 deletions cpp/ycm/ClangCompleter/ClangCompleter.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#ifndef CLANGCOMPLETE_H_WLKDU0ZV
#define CLANGCOMPLETE_H_WLKDU0ZV

#include "../DLLDefines.h"
#include "UnsavedFile.h"
#include "Diagnostic.h"
#include "TranslationUnitStore.h"
Expand All @@ -40,66 +39,66 @@ typedef std::vector< CompletionData > CompletionDatas;
// All filename parameters must be absolute paths.
class ClangCompleter {
public:
YCM_DLL_EXPORT ClangCompleter();
YCM_DLL_EXPORT ~ClangCompleter();
YCM_EXPORT ClangCompleter();
YCM_EXPORT ~ClangCompleter();
ClangCompleter( const ClangCompleter& ) = delete;
ClangCompleter& operator=( const ClangCompleter& ) = delete;

bool UpdatingTranslationUnit( const std::string &filename );

YCM_DLL_EXPORT std::vector< Diagnostic > UpdateTranslationUnit(
YCM_EXPORT std::vector< Diagnostic > UpdateTranslationUnit(
const std::string &filename,
const std::vector< UnsavedFile > &unsaved_files,
const std::vector< std::string > &flags );

YCM_DLL_EXPORT std::vector< CompletionData > CandidatesForLocationInFile(
YCM_EXPORT std::vector< CompletionData > CandidatesForLocationInFile(
const std::string &filename,
int line,
int column,
const std::vector< UnsavedFile > &unsaved_files,
const std::vector< std::string > &flags );

YCM_DLL_EXPORT Location GetDeclarationLocation(
YCM_EXPORT Location GetDeclarationLocation(
const std::string &filename,
int line,
int column,
const std::vector< UnsavedFile > &unsaved_files,
const std::vector< std::string > &flags,
bool reparse = true );

YCM_DLL_EXPORT Location GetDefinitionLocation(
YCM_EXPORT Location GetDefinitionLocation(
const std::string &filename,
int line,
int column,
const std::vector< UnsavedFile > &unsaved_files,
const std::vector< std::string > &flags,
bool reparse = true );

YCM_DLL_EXPORT std::string GetTypeAtLocation(
YCM_EXPORT std::string GetTypeAtLocation(
const std::string &filename,
int line,
int column,
const std::vector< UnsavedFile > &unsaved_files,
const std::vector< std::string > &flags,
bool reparse = true );

YCM_DLL_EXPORT std::string GetEnclosingFunctionAtLocation(
YCM_EXPORT std::string GetEnclosingFunctionAtLocation(
const std::string &filename,
int line,
int column,
const std::vector< UnsavedFile > &unsaved_files,
const std::vector< std::string > &flags,
bool reparse = true );

YCM_DLL_EXPORT std::vector< FixIt > GetFixItsForLocationInFile(
YCM_EXPORT std::vector< FixIt > GetFixItsForLocationInFile(
const std::string &filename,
int line,
int column,
const std::vector< UnsavedFile > &unsaved_files,
const std::vector< std::string > &flags,
bool reparse = true );

YCM_DLL_EXPORT DocumentationData GetDocsForLocationInFile(
YCM_EXPORT DocumentationData GetDocsForLocationInFile(
const std::string &filename,
int line,
int column,
Expand Down
21 changes: 10 additions & 11 deletions cpp/ycm/ClangCompleter/TranslationUnit.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#ifndef TRANSLATIONUNIT_H_XQ7I6SVA
#define TRANSLATIONUNIT_H_XQ7I6SVA

#include "../DLLDefines.h"
#include "UnsavedFile.h"
#include "Diagnostic.h"
#include "Location.h"
Expand All @@ -40,49 +39,49 @@ class TranslationUnit {
// This constructor creates an invalid, sentinel TU. All of it's methods
// return empty vectors, and IsCurrentlyUpdating always returns true so that
// no callers try to rely on the invalid TU.
YCM_DLL_EXPORT TranslationUnit();
YCM_EXPORT TranslationUnit();
TranslationUnit( const TranslationUnit& ) = delete;
TranslationUnit& operator=( const TranslationUnit& ) = delete;

YCM_DLL_EXPORT TranslationUnit(
YCM_EXPORT TranslationUnit(
const std::string &filename,
const std::vector< UnsavedFile > &unsaved_files,
const std::vector< std::string > &flags,
CXIndex clang_index );

YCM_DLL_EXPORT ~TranslationUnit();
YCM_EXPORT ~TranslationUnit();

void Destroy();

YCM_DLL_EXPORT bool IsCurrentlyUpdating() const;
YCM_EXPORT bool IsCurrentlyUpdating() const;

std::vector< Diagnostic > Reparse(
const std::vector< UnsavedFile > &unsaved_files );

YCM_DLL_EXPORT std::vector< CompletionData > CandidatesForLocation(
YCM_EXPORT std::vector< CompletionData > CandidatesForLocation(
int line,
int column,
const std::vector< UnsavedFile > &unsaved_files );

YCM_DLL_EXPORT Location GetDeclarationLocation(
YCM_EXPORT Location GetDeclarationLocation(
int line,
int column,
const std::vector< UnsavedFile > &unsaved_files,
bool reparse = true );

YCM_DLL_EXPORT Location GetDefinitionLocation(
YCM_EXPORT Location GetDefinitionLocation(
int line,
int column,
const std::vector< UnsavedFile > &unsaved_files,
bool reparse = true );

YCM_DLL_EXPORT std::string GetTypeAtLocation(
YCM_EXPORT std::string GetTypeAtLocation(
int line,
int column,
const std::vector< UnsavedFile > &unsaved_files,
bool reparse = true );

YCM_DLL_EXPORT std::string GetEnclosingFunctionAtLocation(
YCM_EXPORT std::string GetEnclosingFunctionAtLocation(
int line,
int column,
const std::vector< UnsavedFile > &unsaved_files,
Expand All @@ -94,7 +93,7 @@ class TranslationUnit {
const std::vector< UnsavedFile > &unsaved_files,
bool reparse = true );

YCM_DLL_EXPORT DocumentationData GetDocsForLocationInFile(
YCM_EXPORT DocumentationData GetDocsForLocationInFile(
int line,
int column,
const std::vector< UnsavedFile > &unsaved_files,
Expand Down
6 changes: 3 additions & 3 deletions cpp/ycm/ClangCompleter/TranslationUnitStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ namespace YouCompleteMe {

class TranslationUnitStore {
public:
YCM_DLL_EXPORT TranslationUnitStore( CXIndex clang_index );
YCM_DLL_EXPORT ~TranslationUnitStore();
YCM_EXPORT TranslationUnitStore( CXIndex clang_index );
YCM_EXPORT ~TranslationUnitStore();
TranslationUnitStore( const TranslationUnitStore& ) = delete;
TranslationUnitStore& operator=( const TranslationUnitStore& ) = delete;

// You can even call this function for the same filename from multiple
// threads; the TU store will ensure only one TU is created.
YCM_DLL_EXPORT std::shared_ptr< TranslationUnit > GetOrCreate(
YCM_EXPORT std::shared_ptr< TranslationUnit > GetOrCreate(
const std::string &filename,
const std::vector< UnsavedFile > &unsaved_files,
const std::vector< std::string > &flags );
Expand Down
29 changes: 0 additions & 29 deletions cpp/ycm/DLLDefines.h

This file was deleted.

13 changes: 6 additions & 7 deletions cpp/ycm/IdentifierCompleter.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#ifndef COMPLETER_H_7AR4UGXE
#define COMPLETER_H_7AR4UGXE

#include "DLLDefines.h"
#include "IdentifierDatabase.h"

#include <vector>
Expand All @@ -36,10 +35,10 @@ class IdentifierCompleter {
IdentifierCompleter( const IdentifierCompleter& ) = delete;
IdentifierCompleter& operator=( const IdentifierCompleter ) = delete;

YCM_DLL_EXPORT IdentifierCompleter();
YCM_DLL_EXPORT IdentifierCompleter(
YCM_EXPORT IdentifierCompleter();
YCM_EXPORT IdentifierCompleter(
const std::vector< std::string > &candidates );
YCM_DLL_EXPORT IdentifierCompleter(
YCM_EXPORT IdentifierCompleter(
const std::vector< std::string > &candidates,
const std::string &filetype,
const std::string &filepath );
Expand All @@ -56,7 +55,7 @@ class IdentifierCompleter {
const std::string &filetype,
const std::string &filepath );

YCM_DLL_EXPORT void AddIdentifiersToDatabaseFromTagFiles(
YCM_EXPORT void AddIdentifiersToDatabaseFromTagFiles(
const std::vector< std::string > &absolute_paths_to_tag_files );

void AddIdentifiersToDatabaseFromBuffer(
Expand All @@ -66,11 +65,11 @@ class IdentifierCompleter {
bool collect_from_comments_and_strings );

// Only provided for tests!
YCM_DLL_EXPORT std::vector< std::string > CandidatesForQuery(
YCM_EXPORT std::vector< std::string > CandidatesForQuery(
const std::string &query,
const size_t max_candidates = 0 ) const;

YCM_DLL_EXPORT std::vector< std::string > CandidatesForQueryAndType(
YCM_EXPORT std::vector< std::string > CandidatesForQueryAndType(
const std::string &query,
const std::string &filetype,
const size_t max_candidates = 0 ) const;
Expand Down
3 changes: 1 addition & 2 deletions cpp/ycm/IdentifierUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#ifndef IDENTIFIERUTILS_CPP_WFFUZNET
#define IDENTIFIERUTILS_CPP_WFFUZNET

#include "DLLDefines.h"
#include "IdentifierDatabase.h"

#include <vector>
Expand All @@ -28,7 +27,7 @@

namespace YouCompleteMe {

YCM_DLL_EXPORT FiletypeIdentifierMap ExtractIdentifiersFromTagsFile(
YCM_EXPORT FiletypeIdentifierMap ExtractIdentifiersFromTagsFile(
const boost::filesystem::path &path_to_tag_file );

} // namespace YouCompleteMe
Expand Down
3 changes: 1 addition & 2 deletions cpp/ycm/LetterNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
#ifndef LETTERNODE_H_EIZ6JVWC
#define LETTERNODE_H_EIZ6JVWC

#include "DLLDefines.h"
#include "LetterNodeListMap.h"

#include <vector>
Expand All @@ -32,7 +31,7 @@ class LetterNode {
public:
LetterNode( char letter, int index );

YCM_DLL_EXPORT explicit LetterNode( const std::string &text );
YCM_EXPORT explicit LetterNode( const std::string &text );

inline bool LetterIsUppercase() const {
return is_uppercase_;
Expand Down
Loading