diff options
author | Ivan Donchevskii <ivan.donchevskii@qt.io> | 2018-08-01 10:50:43 +0200 |
---|---|---|
committer | Ivan Donchevskii <ivan.donchevskii@qt.io> | 2018-08-01 12:39:47 +0000 |
commit | c6105e0ad35094d0f0cb36e45398864dfbd47074 (patch) | |
tree | 042f451acc8bd733d8c5f52c3f9df942750b8bde | |
parent | 61f9ff7bb83fe0e09b576b30c85ce88ca83e7b77 (diff) |
Index while build. Non-Apple platforms
https://reviews.llvm.org/D49009 adapted for 6.0
Change-Id: If42f023af1e032b49c40b6d94e2c9ad8b91a8461
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
-rw-r--r-- | include/clang/Driver/Options.td | 6 | ||||
-rw-r--r-- | include/clang/Index/IndexDataStore.h | 2 | ||||
-rw-r--r-- | include/indexstore/IndexStoreCXX.h | 98 | ||||
-rw-r--r-- | include/indexstore/indexstore.h | 53 | ||||
-rw-r--r-- | lib/Index/IndexUnitReader.cpp | 4 | ||||
-rw-r--r-- | tools/IndexStore/CMakeLists.txt | 8 | ||||
-rw-r--r-- | tools/IndexStore/IndexStore.cpp | 58 | ||||
-rw-r--r-- | tools/c-index-test/CMakeLists.txt | 4 | ||||
-rw-r--r-- | tools/c-index-test/JSONAggregation.cpp | 9 | ||||
-rw-r--r-- | tools/c-index-test/core_main.cpp | 27 |
10 files changed, 162 insertions, 107 deletions
diff --git a/include/clang/Driver/Options.td b/include/clang/Driver/Options.td index 504bb0ddf7..5481563474 100644 --- a/include/clang/Driver/Options.td +++ b/include/clang/Driver/Options.td @@ -324,11 +324,11 @@ def objcmt_whitelist_dir_path: Joined<["-"], "objcmt-whitelist-dir-path=">, Flag def : Joined<["-"], "objcmt-white-list-dir-path=">, Flags<[CC1Option]>, Alias<objcmt_whitelist_dir_path>; -def index_store_path : Separate<["-"], "index-store-path">, Flags<[CC1Option]>, +def index_store_path : Separate<["-"], "index-store-path">, Flags<[CoreOption,CC1Option]>, HelpText<"Enable indexing with the specified data store path">; -def index_ignore_system_symbols : Flag<["-"], "index-ignore-system-symbols">, Flags<[CC1Option]>, +def index_ignore_system_symbols : Flag<["-"], "index-ignore-system-symbols">, Flags<[CoreOption,CC1Option]>, HelpText<"Ignore symbols from system headers">; -def index_record_codegen_name : Flag<["-"], "index-record-codegen-name">, Flags<[CC1Option]>, +def index_record_codegen_name : Flag<["-"], "index-record-codegen-name">, Flags<[CoreOption,CC1Option]>, HelpText<"Record the codegen name for symbols">; // Make sure all other -ccc- options are rejected. diff --git a/include/clang/Index/IndexDataStore.h b/include/clang/Index/IndexDataStore.h index b95bf4e0b0..eb49c2d95a 100644 --- a/include/clang/Index/IndexDataStore.h +++ b/include/clang/Index/IndexDataStore.h @@ -14,6 +14,8 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringRef.h" + +#include <ctime> #include <functional> #include <memory> #include <string> diff --git a/include/indexstore/IndexStoreCXX.h b/include/indexstore/IndexStoreCXX.h index 7971d02233..96c677c9af 100644 --- a/include/indexstore/IndexStoreCXX.h +++ b/include/indexstore/IndexStoreCXX.h @@ -86,14 +86,15 @@ public: uint64_t getRoles() { return indexstore_occurrence_get_roles(obj); } bool foreachRelation(llvm::function_ref<bool(IndexSymbolRelation)> receiver) { -#if INDEXSTORE_HAS_BLOCKS return indexstore_occurrence_relations_apply( - obj, ^bool(indexstore_symbol_relation_t sym_rel) { - return receiver(sym_rel); - }); + obj, +#if INDEXSTORE_HAS_BLOCKS + ^bool(indexstore_symbol_relation_t sym_rel) { #else - return false; + [receiver](indexstore_symbol_relation_t sym_rel) { #endif + return receiver(sym_rel); + }); } std::pair<unsigned, unsigned> getLineCol() { @@ -141,14 +142,15 @@ public: bool foreachUnit(bool sorted, llvm::function_ref<bool(StringRef unitName)> receiver) { -#if INDEXSTORE_HAS_BLOCKS return indexstore_store_units_apply( - obj, sorted, ^bool(indexstore_string_ref_t unit_name) { - return receiver(stringFromIndexStoreStringRef(unit_name)); - }); + obj, sorted, +#if INDEXSTORE_HAS_BLOCKS + ^bool(indexstore_string_ref_t unit_name) { #else - return false; + [receiver](indexstore_string_ref_t unit_name) { #endif + return receiver(stringFromIndexStoreStringRef(unit_name)); + }); } class UnitEvent { @@ -215,17 +217,21 @@ public: typedef std::function<void(UnitEventNotification)> UnitEventHandler; void setUnitEventHandler(UnitEventHandler handler) { -#if INDEXSTORE_HAS_BLOCKS if (!handler) { - indexstore_store_set_unit_event_handler(obj, nullptr); + indexstore_store_set_unit_event_handler(obj, + [](indexstore_unit_event_notification_t evt_note){}); return; } indexstore_store_set_unit_event_handler( - obj, ^(indexstore_unit_event_notification_t evt_note) { + obj, +#if INDEXSTORE_HAS_BLOCKS + ^(indexstore_unit_event_notification_t evt_note) { +#else + [handler](indexstore_unit_event_notification_t evt_note) { +#endif handler(UnitEventNotification(evt_note)); }); -#endif } bool startEventListening(bool waitInitialSync, std::string &error) { @@ -332,20 +338,26 @@ public: receiver(symbol); }); #else - return false; + return indexstore_record_reader_search_symbols( + obj, + [filter](indexstore_symbol_t symbol, bool *stop) { + return filter(symbol, *stop); + }, + [receiver](indexstore_symbol_t symbol) { receiver(symbol); }); #endif } bool foreachSymbol(bool noCache, llvm::function_ref<bool(IndexRecordSymbol)> receiver) { -#if INDEXSTORE_HAS_BLOCKS return indexstore_record_reader_symbols_apply( - obj, noCache, ^bool(indexstore_symbol_t sym) { - return receiver(sym); - }); + obj, noCache, +#if INDEXSTORE_HAS_BLOCKS + ^bool(indexstore_symbol_t sym) { #else - return false; + [receiver](indexstore_symbol_t sym) { #endif + return receiver(sym); + }); } /// \param DeclsFilter if non-empty indicates the list of decls that we want @@ -356,7 +368,6 @@ public: foreachOccurrence(ArrayRef<IndexRecordSymbol> symbolsFilter, ArrayRef<IndexRecordSymbol> relatedSymbolsFilter, llvm::function_ref<bool(IndexRecordOccurrence)> receiver) { -#if INDEXSTORE_HAS_BLOCKS llvm::SmallVector<indexstore_symbol_t, 16> c_symbolsFilter; c_symbolsFilter.reserve(symbolsFilter.size()); for (IndexRecordSymbol sym : symbolsFilter) { @@ -367,27 +378,30 @@ public: for (IndexRecordSymbol sym : relatedSymbolsFilter) { c_relatedSymbolsFilter.push_back(sym.obj); } + return indexstore_record_reader_occurrences_of_symbols_apply( obj, c_symbolsFilter.data(), c_symbolsFilter.size(), c_relatedSymbolsFilter.data(), c_relatedSymbolsFilter.size(), +#if INDEXSTORE_HAS_BLOCKS ^bool(indexstore_occurrence_t occur) { - return receiver(occur); - }); #else - return false; + [receiver](indexstore_occurrence_t occur) { #endif + return receiver(occur); + }); } bool foreachOccurrence(llvm::function_ref<bool(IndexRecordOccurrence)> receiver) { -#if INDEXSTORE_HAS_BLOCKS return indexstore_record_reader_occurrences_apply( - obj, ^bool(indexstore_occurrence_t occur) { - return receiver(occur); - }); + obj, +#if INDEXSTORE_HAS_BLOCKS + ^bool(indexstore_occurrence_t occur) { #else - return false; + [receiver](indexstore_occurrence_t occur) { #endif + return receiver(occur); + }); } bool foreachOccurrenceInLineRange( @@ -399,7 +413,9 @@ public: return receiver(occur); }); #else - return false; + return indexstore_record_reader_occurrences_in_line_range_apply( + obj, lineStart, lineEnd, + [receiver](indexstore_occurrence_t occur) { return receiver(occur); }); #endif } }; @@ -541,25 +557,27 @@ public: bool foreachDependency(llvm::function_ref<bool(IndexUnitDependency)> receiver) { -#if INDEXSTORE_HAS_BLOCKS return indexstore_unit_reader_dependencies_apply( - obj, ^bool(indexstore_unit_dependency_t dep) { - return receiver(dep); - }); + obj, +#if INDEXSTORE_HAS_BLOCKS + ^bool(indexstore_unit_dependency_t dep) { #else - return false; + [receiver](indexstore_unit_dependency_t dep) { #endif + return receiver(dep); + }); } bool foreachInclude(llvm::function_ref<bool(IndexUnitInclude)> receiver) { -#if INDEXSTORE_HAS_BLOCKS return indexstore_unit_reader_includes_apply( - obj, ^bool(indexstore_unit_include_t inc) { - return receiver(inc); - }); + obj, +#if INDEXSTORE_HAS_BLOCKS + ^bool(indexstore_unit_include_t inc) { #else - return false; + [receiver](indexstore_unit_include_t inc) { #endif + return receiver(inc); + }); } }; diff --git a/include/indexstore/indexstore.h b/include/indexstore/indexstore.h index 61e3dc3be2..8682d1b299 100644 --- a/include/indexstore/indexstore.h +++ b/include/indexstore/indexstore.h @@ -14,6 +14,8 @@ #ifndef LLVM_CLANG_C_INDEXSTORE_INDEXSTORE_H #define LLVM_CLANG_C_INDEXSTORE_INDEXSTORE_H +#include "llvm/ADT/STLExtras.h" + #include <ctime> #include <stddef.h> #include <stdint.h> @@ -49,7 +51,11 @@ #ifndef INDEXSTORE_PUBLIC #if defined(_MSC_VER) -#define INDEXSTORE_PUBLIC __declspec(dllimport) +#ifdef _INDEXSTORE_LIB_ + #define INDEXSTORE_PUBLIC __declspec(dllexport) +#else + #define INDEXSTORE_PUBLIC __declspec(dllimport) +#endif #else #define INDEXSTORE_PUBLIC #endif @@ -88,10 +94,12 @@ indexstore_store_create(const char *store_path, indexstore_error_t *error); INDEXSTORE_PUBLIC void indexstore_store_dispose(indexstore_t store); -#if INDEXSTORE_HAS_BLOCKS INDEXSTORE_PUBLIC bool indexstore_store_units_apply( indexstore_t, unsigned sorted, +#if INDEXSTORE_HAS_BLOCKS bool (^applier)(indexstore_string_ref_t unit_name)); +#else + llvm::function_ref<bool(indexstore_string_ref_t)> applier); #endif typedef void *indexstore_unit_event_notification_t; @@ -129,6 +137,13 @@ typedef void (^indexstore_unit_event_handler_t)( INDEXSTORE_PUBLIC void indexstore_store_set_unit_event_handler( indexstore_t store, indexstore_unit_event_handler_t handler); +#else +typedef std::function<void(indexstore_unit_event_notification_t)> +indexstore_unit_event_handler_t; + +INDEXSTORE_PUBLIC void indexstore_store_set_unit_event_handler( + indexstore_t store, + llvm::function_ref<void(indexstore_unit_event_notification_t)> handler); #endif typedef struct { @@ -294,10 +309,12 @@ typedef void *indexstore_occurrence_t; INDEXSTORE_PUBLIC indexstore_symbol_t indexstore_occurrence_get_symbol(indexstore_occurrence_t occur); -#if INDEXSTORE_HAS_BLOCKS INDEXSTORE_PUBLIC bool indexstore_occurrence_relations_apply( indexstore_occurrence_t occur, +#if INDEXSTORE_HAS_BLOCKS bool (^applier)(indexstore_symbol_relation_t relation)); +#else + llvm::function_ref<bool(indexstore_symbol_relation_t)> applier); #endif INDEXSTORE_PUBLIC uint64_t @@ -315,7 +332,6 @@ INDEXSTORE_PUBLIC indexstore_record_reader_t indexstore_record_reader_create( INDEXSTORE_PUBLIC void indexstore_record_reader_dispose(indexstore_record_reader_t reader); -#if INDEXSTORE_HAS_BLOCKS /// Goes through the symbol data and passes symbols to \c receiver, for the /// symbol data that \c filter returns true on. /// @@ -323,23 +339,40 @@ indexstore_record_reader_dispose(indexstore_record_reader_t reader); /// interested in. INDEXSTORE_PUBLIC bool indexstore_record_reader_search_symbols( indexstore_record_reader_t reader, +#if INDEXSTORE_HAS_BLOCKS bool (^filter)(indexstore_symbol_t symbol, bool *stop), void (^receiver)(indexstore_symbol_t symbol)); +#else + llvm::function_ref<bool(indexstore_symbol_t, bool *)> filter, + llvm::function_ref<void(indexstore_symbol_t)> receiver); +#endif /// \param nocache if true, avoids allocating memory for the symbols. /// Useful when the caller does not intend to keep \c indexstore_record_reader_t /// for more queries. INDEXSTORE_PUBLIC bool indexstore_record_reader_symbols_apply( indexstore_record_reader_t reader, bool nocache, +#if INDEXSTORE_HAS_BLOCKS bool (^applier)(indexstore_symbol_t symbol)); +#else + llvm::function_ref<bool(indexstore_symbol_t)> applier); +#endif INDEXSTORE_PUBLIC bool indexstore_record_reader_occurrences_apply( indexstore_record_reader_t reader, +#if INDEXSTORE_HAS_BLOCKS bool (^applier)(indexstore_occurrence_t occur)); +#else + llvm::function_ref<bool(indexstore_occurrence_t)> applier); +#endif INDEXSTORE_PUBLIC bool indexstore_record_reader_occurrences_in_line_range_apply( indexstore_record_reader_t reader, unsigned line_start, unsigned line_count, +#if INDEXSTORE_HAS_BLOCKS bool (^applier)(indexstore_occurrence_t occur)); +#else + llvm::function_ref<bool(indexstore_occurrence_t)> applier); +#endif /// \param symbols if non-zero \c symbols_count, indicates the list of symbols /// that we want to get occurrences for. An empty array indicates that we want @@ -349,7 +382,10 @@ INDEXSTORE_PUBLIC bool indexstore_record_reader_occurrences_of_symbols_apply( indexstore_record_reader_t reader, indexstore_symbol_t *symbols, size_t symbols_count, indexstore_symbol_t *related_symbols, size_t related_symbols_count, +#if INDEXSTORE_HAS_BLOCKS bool (^applier)(indexstore_occurrence_t occur)); +#else + llvm::function_ref<bool(indexstore_occurrence_t)> applier); #endif typedef void *indexstore_unit_reader_t; @@ -438,15 +474,20 @@ indexstore_unit_include_get_target_path(indexstore_unit_include_t dep); INDEXSTORE_PUBLIC unsigned indexstore_unit_include_get_source_line(indexstore_unit_include_t dep); -#if INDEXSTORE_HAS_BLOCKS INDEXSTORE_PUBLIC bool indexstore_unit_reader_dependencies_apply( indexstore_unit_reader_t reader, +#if INDEXSTORE_HAS_BLOCKS bool (^applier)(indexstore_unit_dependency_t dep)); +#else + llvm::function_ref<bool(indexstore_unit_dependency_t)> applier); +#endif INDEXSTORE_PUBLIC bool indexstore_unit_reader_includes_apply( indexstore_unit_reader_t reader, +#if INDEXSTORE_HAS_BLOCKS bool (^applier)(indexstore_unit_include_t include)); - +#else + llvm::function_ref<bool(indexstore_unit_include_t)> applier); #endif INDEXSTORE_END_DECLS diff --git a/lib/Index/IndexUnitReader.cpp b/lib/Index/IndexUnitReader.cpp index 9a3e9ca092..017e0a9959 100644 --- a/lib/Index/IndexUnitReader.cpp +++ b/lib/Index/IndexUnitReader.cpp @@ -21,7 +21,11 @@ #include "llvm/Support/Path.h" #include "llvm/Support/raw_ostream.h" +#if !defined(_MSC_VER) && !defined(__MINGW32__) #include <unistd.h> +#else +#include <io.h> +#endif using namespace clang; using namespace clang::index; diff --git a/tools/IndexStore/CMakeLists.txt b/tools/IndexStore/CMakeLists.txt index 8ad6499117..1d4c246be0 100644 --- a/tools/IndexStore/CMakeLists.txt +++ b/tools/IndexStore/CMakeLists.txt @@ -23,9 +23,6 @@ else() set(output_name "IndexStore") endif() -# FIXME: needs to be ported to non-Apple platforms. -if(APPLE) - add_clang_library(IndexStore ${ENABLE_SHARED} ${ENABLE_STATIC} OUTPUT_NAME ${output_name} ${SOURCES} @@ -46,7 +43,7 @@ if(ENABLE_SHARED) set_target_properties(IndexStore PROPERTIES VERSION ${INDEXSTORE_LIBRARY_VERSION} - DEFINE_SYMBOL _CINDEX_LIB_) + DEFINE_SYMBOL _INDEXSTORE_LIB_) elseif(APPLE) set(INDEXSTORE_LINK_FLAGS " -Wl,-compatibility_version -Wl,1") set(INDEXSTORE_LINK_FLAGS "${INDEXSTORE_LINK_FLAGS} -Wl,-current_version -Wl,${INDEXSTORE_LIBRARY_VERSION}") @@ -62,7 +59,7 @@ if(ENABLE_SHARED) set_target_properties(IndexStore PROPERTIES VERSION ${INDEXSTORE_LIBRARY_VERSION} - DEFINE_SYMBOL _CINDEX_LIB_) + DEFINE_SYMBOL _INDEXSTORE_LIB_) endif() endif() @@ -91,4 +88,3 @@ install(DIRECTORY ../../include/indexstore PATTERN "*.h" PATTERN ".svn" EXCLUDE ) -endif() diff --git a/tools/IndexStore/IndexStore.cpp b/tools/IndexStore/IndexStore.cpp index c73b9a9aa7..6431b63e17 100644 --- a/tools/IndexStore/IndexStore.cpp +++ b/tools/IndexStore/IndexStore.cpp @@ -22,7 +22,10 @@ #include "llvm/ADT/Optional.h" #include "llvm/ADT/SmallString.h" #include "llvm/Support/Chrono.h" + +#if INDEXSTORE_HAS_BLOCKS #include <Block.h> +#endif using namespace clang; using namespace clang::index; @@ -81,10 +84,13 @@ void indexstore_store_dispose(indexstore_t store) { delete static_cast<IndexDataStore *>(store); } -#if INDEXSTORE_HAS_BLOCKS bool indexstore_store_units_apply( indexstore_t c_store, unsigned sorted, +#if INDEXSTORE_HAS_BLOCKS bool (^applier)(indexstore_string_ref_t unit_name)) { +#else + llvm::function_ref<bool(indexstore_string_ref_t)> applier) { +#endif IndexDataStore *store = static_cast<IndexDataStore *>(c_store); return store->foreachUnitName(sorted, [&](StringRef unitName) -> bool { return applier(toIndexStoreString(unitName)); @@ -158,12 +164,11 @@ void indexstore_store_set_unit_event_handler( public: BlockWrapper(indexstore_unit_event_handler_t handler) { - blk_handler = Block_copy(handler); + blk_handler = handler; } BlockWrapper(const BlockWrapper &other) { - blk_handler = Block_copy(other.blk_handler); + blk_handler = other.blk_handler; } - ~BlockWrapper() { Block_release(blk_handler); } void operator()(indexstore_unit_event_notification_t evt_note) const { blk_handler(evt_note); @@ -177,7 +182,6 @@ void indexstore_store_set_unit_event_handler( handler(&evtNote); }); } -#endif bool indexstore_store_start_unit_event_listening( indexstore_t c_store, indexstore_unit_event_listen_options_t *client_opts, @@ -286,10 +290,13 @@ indexstore_occurrence_get_symbol(indexstore_occurrence_t occur) { return (indexstore_symbol_t) static_cast<IndexRecordOccurrence *>(occur)->Dcl; } -#if INDEXSTORE_HAS_BLOCKS bool indexstore_occurrence_relations_apply( indexstore_occurrence_t occur, +#if INDEXSTORE_HAS_BLOCKS bool (^applier)(indexstore_symbol_relation_t symbol_rel)) { +#else + llvm::function_ref<bool(indexstore_symbol_relation_t)> applier) { +#endif auto *recOccur = static_cast<IndexRecordOccurrence *>(occur); for (auto &rel : recOccur->Relations) { if (!applier(&rel)) @@ -297,7 +304,6 @@ bool indexstore_occurrence_relations_apply( } return true; } -#endif uint64_t indexstore_occurrence_get_roles(indexstore_occurrence_t occur) { return static_cast<IndexRecordOccurrence *>(occur)->Roles; @@ -335,7 +341,6 @@ void indexstore_record_reader_dispose(indexstore_record_reader_t rdr) { delete reader; } -#if INDEXSTORE_HAS_BLOCKS /// Goes through the symbol data and passes symbols to \c receiver, for the /// symbol data that \c filter returns true on. /// @@ -343,8 +348,13 @@ void indexstore_record_reader_dispose(indexstore_record_reader_t rdr) { /// interested in. bool indexstore_record_reader_search_symbols( indexstore_record_reader_t rdr, +#if INDEXSTORE_HAS_BLOCKS bool (^filter)(indexstore_symbol_t symbol, bool *stop), void (^receiver)(indexstore_symbol_t symbol)) { +#else + llvm::function_ref<bool(indexstore_symbol_t, bool *)> filter, + llvm::function_ref<void(indexstore_symbol_t)> receiver) { +#endif auto *reader = static_cast<IndexRecordReader *>(rdr); auto filterFn = @@ -362,7 +372,11 @@ bool indexstore_record_reader_search_symbols( bool indexstore_record_reader_symbols_apply( indexstore_record_reader_t rdr, bool nocache, +#if INDEXSTORE_HAS_BLOCKS bool (^applier)(indexstore_symbol_t symbol)) { +#else + llvm::function_ref<bool(indexstore_symbol_t)> applier) { +#endif auto *reader = static_cast<IndexRecordReader *>(rdr); auto receiverFn = [&](const IndexRecordDecl *D) -> bool { return applier((indexstore_symbol_t)D); @@ -372,7 +386,11 @@ bool indexstore_record_reader_symbols_apply( bool indexstore_record_reader_occurrences_apply( indexstore_record_reader_t rdr, +#if INDEXSTORE_HAS_BLOCKS bool (^applier)(indexstore_occurrence_t occur)) { +#else + llvm::function_ref<bool(indexstore_occurrence_t)> applier) { +#endif auto *reader = static_cast<IndexRecordReader *>(rdr); auto receiverFn = [&](const IndexRecordOccurrence &RO) -> bool { return applier((indexstore_occurrence_t)&RO); @@ -382,7 +400,11 @@ bool indexstore_record_reader_occurrences_apply( bool indexstore_record_reader_occurrences_in_line_range_apply( indexstore_record_reader_t rdr, unsigned line_start, unsigned line_count, +#if INDEXSTORE_HAS_BLOCKS bool (^applier)(indexstore_occurrence_t occur)) { +#else + llvm::function_ref<bool(indexstore_occurrence_t)> applier) { +#endif auto *reader = static_cast<IndexRecordReader *>(rdr); auto receiverFn = [&](const IndexRecordOccurrence &RO) -> bool { return applier((indexstore_occurrence_t)&RO); @@ -399,7 +421,11 @@ bool indexstore_record_reader_occurrences_of_symbols_apply( indexstore_record_reader_t rdr, indexstore_symbol_t *symbols, size_t symbols_count, indexstore_symbol_t *related_symbols, size_t related_symbols_count, +#if INDEXSTORE_HAS_BLOCKS bool (^applier)(indexstore_occurrence_t occur)) { +#else + llvm::function_ref<bool(indexstore_occurrence_t)> applier) { +#endif auto *reader = static_cast<IndexRecordReader *>(rdr); auto receiverFn = [&](const IndexRecordOccurrence &RO) -> bool { return applier((indexstore_occurrence_t)&RO); @@ -408,7 +434,6 @@ bool indexstore_record_reader_occurrences_of_symbols_apply( {(IndexRecordDecl **)symbols, symbols_count}, {(IndexRecordDecl **)related_symbols, related_symbols_count}, receiverFn); } -#endif size_t indexstore_store_get_unit_name_from_output_path(indexstore_t store, const char *output_path, @@ -417,7 +442,7 @@ size_t indexstore_store_get_unit_name_from_output_path(indexstore_t store, SmallString<256> unitName; IndexUnitWriter::getUnitNameForAbsoluteOutputFile(output_path, unitName); size_t nameLen = unitName.size(); - strlcpy(name_buf, unitName.c_str(), buf_size); + strncpy(name_buf, unitName.c_str(), buf_size); return nameLen; } @@ -614,10 +639,13 @@ indexstore_unit_include_get_source_line(indexstore_unit_include_t c_inc) { return inc->SourceLine; } -#if INDEXSTORE_HAS_BLOCKS bool indexstore_unit_reader_dependencies_apply( indexstore_unit_reader_t rdr, +#if INDEXSTORE_HAS_BLOCKS bool (^applier)(indexstore_unit_dependency_t)) { +#else + llvm::function_ref<bool(indexstore_unit_dependency_t)> applier) { +#endif auto reader = static_cast<IndexUnitReader *>(rdr); return reader->foreachDependency( [&](const IndexUnitReader::DependencyInfo &depInfo) -> bool { @@ -626,11 +654,15 @@ bool indexstore_unit_reader_dependencies_apply( } bool indexstore_unit_reader_includes_apply( - indexstore_unit_reader_t rdr, bool (^applier)(indexstore_unit_include_t)) { + indexstore_unit_reader_t rdr, +#if INDEXSTORE_HAS_BLOCKS + bool (^applier)(indexstore_unit_include_t)) { +#else + llvm::function_ref<bool(indexstore_unit_include_t)> applier) { +#endif auto reader = static_cast<IndexUnitReader *>(rdr); return reader->foreachInclude( [&](const IndexUnitReader::IncludeInfo &incInfo) -> bool { return applier((void *)&incInfo); }); } -#endif diff --git a/tools/c-index-test/CMakeLists.txt b/tools/c-index-test/CMakeLists.txt index 82245dc08a..cf1bb9b174 100644 --- a/tools/c-index-test/CMakeLists.txt +++ b/tools/c-index-test/CMakeLists.txt @@ -12,9 +12,7 @@ add_clang_executable(c-index-test set(INDEXSTORE_LIB) set(CINDEXTEST_LIBS) -if(APPLE) - set(INDEXSTORE_LIB IndexStore) -endif() +set(INDEXSTORE_LIB IndexStore) if(NOT MSVC) set_property( diff --git a/tools/c-index-test/JSONAggregation.cpp b/tools/c-index-test/JSONAggregation.cpp index 4c761b6f8f..f5a8d4b428 100644 --- a/tools/c-index-test/JSONAggregation.cpp +++ b/tools/c-index-test/JSONAggregation.cpp @@ -20,8 +20,6 @@ using namespace clang::index; using namespace indexstore; using namespace llvm; -#if INDEXSTORE_HAS_BLOCKS - namespace { typedef size_t FilePathIndex; @@ -412,10 +410,3 @@ bool index::aggregateDataAsJSON(StringRef StorePath, raw_ostream &OS) { aggregator->dumpJSON(OS); return false; } - -#else - -bool index::aggregateDataAsJSON(StringRef StorePath, raw_ostream &OS) { - return true; -} -#endif diff --git a/tools/c-index-test/core_main.cpp b/tools/c-index-test/core_main.cpp index d89b2116d5..4692a06d91 100644 --- a/tools/c-index-test/core_main.cpp +++ b/tools/c-index-test/core_main.cpp @@ -442,8 +442,6 @@ static bool printSourceUnit(ArrayRef<const char *> Args, bool IndexLocals, return !Unit; } -#if INDEXSTORE_HAS_BLOCKS - //===----------------------------------------------------------------------===// // Print Record //===----------------------------------------------------------------------===// @@ -746,20 +744,6 @@ static int printStoreUnits(StringRef StorePath, raw_ostream &OS) { return !Success; } -#else - -static int printUnit(StringRef Filename, raw_ostream &OS) { return 1; } - -static int printStoreUnits(StringRef StorePath, raw_ostream &OS) { return 1; } - -static int printStoreFileRecord(StringRef storePath, StringRef filePath, - Optional<unsigned> lineStart, - unsigned lineCount, raw_ostream &OS) { - return 1; -} - -#endif - //===----------------------------------------------------------------------===// // Helper Utils //===----------------------------------------------------------------------===// @@ -791,8 +775,6 @@ static void printSymbolNameAndUSR(const Decl *D, ASTContext &Ctx, } } -#if INDEXSTORE_HAS_BLOCKS - static void printSymbol(const IndexRecordDecl &Rec, raw_ostream &OS) { printSymbolInfo(Rec.SymInfo, OS); OS << " | "; @@ -921,13 +903,6 @@ static void printSymbol(indexstore::IndexRecordOccurrence Occur, }); } -#else - -static int printRecord(StringRef Filename, raw_ostream &OS) { return 1; } -static int printStoreRecords(StringRef StorePath, raw_ostream &OS) { return 1; } - -#endif - static int watchDirectory(StringRef dirPath) { raw_ostream &OS = outs(); auto receiver = [&](ArrayRef<DirectoryWatcher::Event> Events, @@ -1080,11 +1055,9 @@ int indextest_core_main(int argc, const char **argv) { return printUnit(options::InputFiles[0], outs()); } -#if INDEXSTORE_HAS_BLOCKS if (options::Action == ActionType::PrintStoreFormatVersion) { outs() << indexstore::IndexStore::formatVersion() << '\n'; } -#endif if (options::Action == ActionType::AggregateAsJSON) { if (options::InputFiles.empty()) { |