From 7aeb56ff386b9ca81681aab7a7ce4c3cefe003d6 Mon Sep 17 00:00:00 2001 From: Boris Staletic Date: Fri, 1 Sep 2017 10:33:45 +0200 Subject: [PATCH] Hide C++ symbols in the ycm_core.so by default --- cpp/CMakeLists.txt | 23 +++++++++++++ cpp/ycm/.ycm_extra_conf.py | 5 +-- cpp/ycm/Candidate.h | 9 +++--- cpp/ycm/CandidateRepository.h | 8 ++--- cpp/ycm/ClangCompleter/ClangCompleter.h | 21 ++++++------ cpp/ycm/ClangCompleter/TranslationUnit.h | 21 ++++++------ cpp/ycm/ClangCompleter/TranslationUnitStore.h | 6 ++-- cpp/ycm/DLLDefines.h | 29 ----------------- cpp/ycm/IdentifierCompleter.h | 13 ++++---- cpp/ycm/IdentifierUtils.h | 3 +- cpp/ycm/LetterNode.h | 3 +- cpp/ycm/LetterNodeListMap.h | 5 ++- cpp/ycm/PythonSupport.h | 4 +-- cpp/ycm/Utils.h | 32 +++++++++---------- cpp/ycm/exceptions.h | 7 +--- 15 files changed, 83 insertions(+), 106 deletions(-) delete mode 100644 cpp/ycm/DLLDefines.h diff --git a/cpp/CMakeLists.txt b/cpp/CMakeLists.txt index edd3a17244..d2063b4473 100644 --- a/cpp/CMakeLists.txt +++ b/cpp/CMakeLists.txt @@ -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 ) diff --git a/cpp/ycm/.ycm_extra_conf.py b/cpp/ycm/.ycm_extra_conf.py index 3d35ef97dd..97725b58a5 100644 --- a/cpp/ycm/.ycm_extra_conf.py +++ b/cpp/ycm/.ycm_extra_conf.py @@ -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. diff --git a/cpp/ycm/Candidate.h b/cpp/ycm/Candidate.h index 1f2e311798..2c8ce54b3b 100644 --- a/cpp/ycm/Candidate.h +++ b/cpp/ycm/Candidate.h @@ -18,7 +18,6 @@ #ifndef CANDIDATE_H_R5LZH6AC #define CANDIDATE_H_R5LZH6AC -#include "DLLDefines.h" #include "LetterNode.h" #include @@ -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; @@ -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: diff --git a/cpp/ycm/CandidateRepository.h b/cpp/ycm/CandidateRepository.h index 46172f948a..7386bc425f 100644 --- a/cpp/ycm/CandidateRepository.h +++ b/cpp/ycm/CandidateRepository.h @@ -18,8 +18,6 @@ #ifndef CANDIDATEREPOSITORY_H_K9OVCMHG #define CANDIDATEREPOSITORY_H_K9OVCMHG -#include "DLLDefines.h" - #include #include #include @@ -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() {}; diff --git a/cpp/ycm/ClangCompleter/ClangCompleter.h b/cpp/ycm/ClangCompleter/ClangCompleter.h index 47a88f37b2..a0b0417349 100644 --- a/cpp/ycm/ClangCompleter/ClangCompleter.h +++ b/cpp/ycm/ClangCompleter/ClangCompleter.h @@ -18,7 +18,6 @@ #ifndef CLANGCOMPLETE_H_WLKDU0ZV #define CLANGCOMPLETE_H_WLKDU0ZV -#include "../DLLDefines.h" #include "UnsavedFile.h" #include "Diagnostic.h" #include "TranslationUnitStore.h" @@ -40,26 +39,26 @@ 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, @@ -67,7 +66,7 @@ class ClangCompleter { 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, @@ -75,7 +74,7 @@ class ClangCompleter { 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, @@ -83,7 +82,7 @@ class ClangCompleter { 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, @@ -91,7 +90,7 @@ class ClangCompleter { 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, @@ -99,7 +98,7 @@ class ClangCompleter { 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, diff --git a/cpp/ycm/ClangCompleter/TranslationUnit.h b/cpp/ycm/ClangCompleter/TranslationUnit.h index f0c741ca81..5a8b2b694b 100644 --- a/cpp/ycm/ClangCompleter/TranslationUnit.h +++ b/cpp/ycm/ClangCompleter/TranslationUnit.h @@ -18,7 +18,6 @@ #ifndef TRANSLATIONUNIT_H_XQ7I6SVA #define TRANSLATIONUNIT_H_XQ7I6SVA -#include "../DLLDefines.h" #include "UnsavedFile.h" #include "Diagnostic.h" #include "Location.h" @@ -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, @@ -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, diff --git a/cpp/ycm/ClangCompleter/TranslationUnitStore.h b/cpp/ycm/ClangCompleter/TranslationUnitStore.h index c52a1a55c3..cda471ac61 100644 --- a/cpp/ycm/ClangCompleter/TranslationUnitStore.h +++ b/cpp/ycm/ClangCompleter/TranslationUnitStore.h @@ -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 ); diff --git a/cpp/ycm/DLLDefines.h b/cpp/ycm/DLLDefines.h deleted file mode 100644 index 7a328d2561..0000000000 --- a/cpp/ycm/DLLDefines.h +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (C) 2015 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 . - -#ifndef DLLDEFINES_H_0IYA3AQ3 -#define DLLDEFINES_H_0IYA3AQ3 - -// We need to export symbols for gmock tests on Windows. The preprocessor -// symbol ycm_core_EXPORTS is defined by CMake when building a shared library. -#if defined( _WIN32 ) && defined( ycm_core_EXPORTS ) -#define YCM_DLL_EXPORT __declspec( dllexport ) -#else -#define YCM_DLL_EXPORT -#endif - -#endif /* end of include guard: DLLDEFINES_H_0IYA3AQ3 */ diff --git a/cpp/ycm/IdentifierCompleter.h b/cpp/ycm/IdentifierCompleter.h index 6ca0f86ea4..f48c2e64cc 100644 --- a/cpp/ycm/IdentifierCompleter.h +++ b/cpp/ycm/IdentifierCompleter.h @@ -18,7 +18,6 @@ #ifndef COMPLETER_H_7AR4UGXE #define COMPLETER_H_7AR4UGXE -#include "DLLDefines.h" #include "IdentifierDatabase.h" #include @@ -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 ); @@ -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( @@ -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; diff --git a/cpp/ycm/IdentifierUtils.h b/cpp/ycm/IdentifierUtils.h index ef8f1c60b6..79a8218eac 100644 --- a/cpp/ycm/IdentifierUtils.h +++ b/cpp/ycm/IdentifierUtils.h @@ -18,7 +18,6 @@ #ifndef IDENTIFIERUTILS_CPP_WFFUZNET #define IDENTIFIERUTILS_CPP_WFFUZNET -#include "DLLDefines.h" #include "IdentifierDatabase.h" #include @@ -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 diff --git a/cpp/ycm/LetterNode.h b/cpp/ycm/LetterNode.h index 07b89ecf86..e5f68a7b18 100644 --- a/cpp/ycm/LetterNode.h +++ b/cpp/ycm/LetterNode.h @@ -18,7 +18,6 @@ #ifndef LETTERNODE_H_EIZ6JVWC #define LETTERNODE_H_EIZ6JVWC -#include "DLLDefines.h" #include "LetterNodeListMap.h" #include @@ -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_; diff --git a/cpp/ycm/LetterNodeListMap.h b/cpp/ycm/LetterNodeListMap.h index bf8f13e1d1..2ba7e3eb95 100644 --- a/cpp/ycm/LetterNodeListMap.h +++ b/cpp/ycm/LetterNodeListMap.h @@ -18,7 +18,6 @@ #ifndef LETTERNODELISTMAP_H_BRK2UMC1 #define LETTERNODELISTMAP_H_BRK2UMC1 -#include "DLLDefines.h" #include "Utils.h" #include @@ -31,7 +30,7 @@ namespace YouCompleteMe { class LetterNode; -YCM_DLL_EXPORT int IndexForLetter( char letter ); +YCM_EXPORT int IndexForLetter( char letter ); /* * This struct is used as part of the LetterNodeListMap structure. @@ -67,7 +66,7 @@ class LetterNodeListMap { NearestLetterNodeIndices &operator[] ( char letter ); - YCM_DLL_EXPORT NearestLetterNodeIndices *ListPointerAt( char letter ); + YCM_EXPORT NearestLetterNodeIndices *ListPointerAt( char letter ); private: typedef std::array diff --git a/cpp/ycm/PythonSupport.h b/cpp/ycm/PythonSupport.h index 986c107fb8..8779aed30b 100644 --- a/cpp/ycm/PythonSupport.h +++ b/cpp/ycm/PythonSupport.h @@ -18,8 +18,6 @@ #ifndef PYTHONSUPPORT_H_KWGFEX0V #define PYTHONSUPPORT_H_KWGFEX0V -#include "DLLDefines.h" - #include namespace YouCompleteMe { @@ -30,7 +28,7 @@ namespace YouCompleteMe { /// original objects that survived the filtering. This list contains at most /// |max_candidates|. If |max_candidates| is omitted or 0, all candidates are /// sorted. -YCM_DLL_EXPORT boost::python::list FilterAndSortCandidates( +YCM_EXPORT boost::python::list FilterAndSortCandidates( const boost::python::list &candidates, const std::string &candidate_property, const std::string &query, diff --git a/cpp/ycm/Utils.h b/cpp/ycm/Utils.h index fbd5b2f02b..873961e570 100644 --- a/cpp/ycm/Utils.h +++ b/cpp/ycm/Utils.h @@ -18,8 +18,6 @@ #ifndef UTILS_H_KEPMRPBH #define UTILS_H_KEPMRPBH -#include "DLLDefines.h" - #include #include #include @@ -37,34 +35,34 @@ inline bool AlmostEqual( double a, double b ) { } -YCM_DLL_EXPORT inline bool IsLowercase( char letter ) { +YCM_EXPORT inline bool IsLowercase( char letter ) { return 'a' <= letter && letter <= 'z'; } -YCM_DLL_EXPORT inline bool IsUppercase( char letter ) { +YCM_EXPORT inline bool IsUppercase( char letter ) { return 'A' <= letter && letter <= 'Z'; } // A character is ASCII if it's in the range 0-127 i.e. its most significant bit // is 0. -YCM_DLL_EXPORT inline bool IsAscii( char letter ) { +YCM_EXPORT inline bool IsAscii( char letter ) { return !( letter & 0x80 ); } -YCM_DLL_EXPORT inline bool IsAlpha( char letter ) { +YCM_EXPORT inline bool IsAlpha( char letter ) { return IsLowercase( letter ) || IsUppercase( letter ); } -YCM_DLL_EXPORT inline bool IsPrintable( char letter ) { +YCM_EXPORT inline bool IsPrintable( char letter ) { return ' ' <= letter && letter <= '~'; } -YCM_DLL_EXPORT inline bool IsPrintable( const std::string &text ) { +YCM_EXPORT inline bool IsPrintable( const std::string &text ) { for ( char letter : text ) { if ( !IsPrintable( letter ) ) return false; @@ -73,7 +71,7 @@ YCM_DLL_EXPORT inline bool IsPrintable( const std::string &text ) { } -YCM_DLL_EXPORT inline bool IsPunctuation( char letter ) { +YCM_EXPORT inline bool IsPunctuation( char letter ) { return ( '!' <= letter && letter <= '/' ) || ( ':' <= letter && letter <= '@' ) || ( '[' <= letter && letter <= '`' ) || @@ -83,7 +81,7 @@ YCM_DLL_EXPORT inline bool IsPunctuation( char letter ) { // A string is assumed to be in lowercase if none of its characters are // uppercase. -YCM_DLL_EXPORT inline bool IsLowercase( const std::string &text ) { +YCM_EXPORT inline bool IsLowercase( const std::string &text ) { for ( char letter : text ) { if ( IsUppercase( letter ) ) return false; @@ -94,14 +92,14 @@ YCM_DLL_EXPORT inline bool IsLowercase( const std::string &text ) { // An uppercase character can be converted to lowercase and vice versa by // flipping its third most significant bit. -YCM_DLL_EXPORT inline char Lowercase( char letter ) { +YCM_EXPORT inline char Lowercase( char letter ) { if ( IsUppercase( letter ) ) return letter ^ 0x20; return letter; } -YCM_DLL_EXPORT inline std::string Lowercase( const std::string &text ) { +YCM_EXPORT inline std::string Lowercase( const std::string &text ) { std::string result; for ( char letter : text ) result.push_back( Lowercase( letter ) ); @@ -109,14 +107,14 @@ YCM_DLL_EXPORT inline std::string Lowercase( const std::string &text ) { } -YCM_DLL_EXPORT inline char Uppercase( char letter ) { +YCM_EXPORT inline char Uppercase( char letter ) { if ( IsLowercase( letter ) ) return letter ^ 0x20; return letter; } -YCM_DLL_EXPORT inline bool HasUppercase( const std::string &text ) { +YCM_EXPORT inline bool HasUppercase( const std::string &text ) { for ( char letter : text ) { if ( IsUppercase( letter ) ) return true; @@ -125,14 +123,14 @@ YCM_DLL_EXPORT inline bool HasUppercase( const std::string &text ) { } -YCM_DLL_EXPORT inline char SwapCase( char letter ) { +YCM_EXPORT inline char SwapCase( char letter ) { if ( IsAlpha( letter ) ) return letter ^ 0x20; return letter; } -YCM_DLL_EXPORT inline std::string SwapCase( const std::string &text ) { +YCM_EXPORT inline std::string SwapCase( const std::string &text ) { std::string result; for ( char letter : text ) result.push_back( SwapCase( letter ) ); @@ -145,7 +143,7 @@ std::string ReadUtf8File( const fs::path &filepath ); // Writes the entire contents of the specified file. If the file does not exist, // an exception is thrown. -YCM_DLL_EXPORT void WriteUtf8File( const fs::path &filepath, +YCM_EXPORT void WriteUtf8File( const fs::path &filepath, const std::string &contents ); template diff --git a/cpp/ycm/exceptions.h b/cpp/ycm/exceptions.h index 4d65deed94..38081bf288 100644 --- a/cpp/ycm/exceptions.h +++ b/cpp/ycm/exceptions.h @@ -24,15 +24,10 @@ namespace YouCompleteMe { // For more information, see this link: // http://www.boost.org/doc/libs/1_50_0/libs/exception/doc/exception_types_as_simple_semantic_tags.html -/** - * The common base for all exceptions. - */ -struct ExceptionBase: virtual std::exception {}; - /** * Thrown when a file does not exist. */ -struct ClangParseError : virtual ExceptionBase {}; +struct YCM_EXPORT ClangParseError : virtual std::exception {}; } // namespace YouCompleteMe