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 /tools | |
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>
Diffstat (limited to 'tools')
-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 |
5 files changed, 48 insertions, 58 deletions
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()) { |