diff --git a/src/clang_indexer.cc b/src/clang_indexer.cc index f8950eac..489eed31 100644 --- a/src/clang_indexer.cc +++ b/src/clang_indexer.cc @@ -2153,7 +2153,7 @@ void OnIndexReference(CXClientData client_data, const CXIdxEntityRefInfo* ref) { } } -std::optional>> Parse( +std::vector> Parse( Config* config, FileConsumerSharedState* file_consumer_shared, std::string file, @@ -2163,7 +2163,7 @@ std::optional>> Parse( ClangIndex* index, bool dump_ast) { if (!config->index.enabled) - return std::nullopt; + return {}; file = NormalizePath(file); @@ -2183,7 +2183,7 @@ std::optional>> Parse( CXTranslationUnit_KeepGoing | CXTranslationUnit_DetailedPreprocessingRecord); if (!tu) - return std::nullopt; + return {}; perf->index_parse = timer.ElapsedMicrosecondsAndReset(); @@ -2194,7 +2194,7 @@ std::optional>> Parse( args, unsaved_files); } -std::optional>> ParseWithTu( +std::vector> ParseWithTu( Config* config, FileConsumerSharedState* file_consumer_shared, PerformanceImportFile* perf, @@ -2239,7 +2239,7 @@ std::optional>> ParseWithTu( if (index_result != CXError_Success) { LOG_S(ERROR) << "Indexing " << file << " failed with errno=" << index_result; - return std::nullopt; + return {}; } clang_IndexAction_dispose(index_action); @@ -2301,7 +2301,7 @@ std::optional>> ParseWithTu( entry->dependencies.end()); } - return std::move(result); + return result; } void ConcatTypeAndName(std::string& type, const std::string& name) { diff --git a/src/iindexer.cc b/src/iindexer.cc index 16085bc3..1c77005d 100644 --- a/src/iindexer.cc +++ b/src/iindexer.cc @@ -6,7 +6,7 @@ namespace { struct ClangIndexer : IIndexer { ~ClangIndexer() override = default; - std::optional>> Index( + std::vector> Index( Config* config, FileConsumerSharedState* file_consumer_shared, std::string file, @@ -50,7 +50,7 @@ struct TestIndexer : IIndexer { ~TestIndexer() override = default; - std::optional>> Index( + std::vector> Index( Config* config, FileConsumerSharedState* file_consumer_shared, std::string file, @@ -61,14 +61,14 @@ struct TestIndexer : IIndexer { if (it == indexes.end()) { // Don't return any indexes for unexpected data. assert(false && "no indexes"); - return std::nullopt; + return {}; } // FIXME: allow user to control how many times we return the index for a // specific file (atm it is always 1) auto result = std::move(it->second); indexes.erase(it); - return std::move(result); + return result; } std::unordered_map>> diff --git a/src/iindexer.h b/src/iindexer.h index d6648990..df0e2d8b 100644 --- a/src/iindexer.h +++ b/src/iindexer.h @@ -34,7 +34,7 @@ struct IIndexer { std::initializer_list entries); virtual ~IIndexer() = default; - virtual std::optional>> Index( + virtual std::vector> Index( Config* config, FileConsumerSharedState* file_consumer_shared, std::string file, diff --git a/src/import_pipeline.cc b/src/import_pipeline.cc index 8f53c8c0..9e0eb346 100644 --- a/src/import_pipeline.cc +++ b/src/import_pipeline.cc @@ -393,7 +393,7 @@ void ParseFile(Config* config, auto indexes = indexer->Index(config, file_consumer_shared, path_to_index, entry.args, file_contents, &perf); - if (!indexes) { + if (indexes.empty()) { if (config->index.enabled && !std::holds_alternative(request.id)) { Out_Error out; @@ -405,7 +405,7 @@ void ParseFile(Config* config, return; } - for (std::unique_ptr& new_index : *indexes) { + for (std::unique_ptr& new_index : indexes) { Timer time; // Only emit diagnostics for non-interactive sessions, which makes it easier @@ -556,11 +556,11 @@ void IndexWithTuFromCodeCompletion( ClangIndex index; auto indexes = ParseWithTu(config, file_consumer_shared, &perf, tu, &index, path, args, file_contents); - if (!indexes) - return; + if (indexes.empty()) + return; std::vector result; - for (std::unique_ptr& new_index : *indexes) { + for (std::unique_ptr& new_index : indexes) { Timer time; std::shared_ptr cache_manager; diff --git a/src/indexer.h b/src/indexer.h index e52ddb3d..8857c2bd 100644 --- a/src/indexer.h +++ b/src/indexer.h @@ -517,7 +517,7 @@ struct NamespaceHelper { // |desired_index_file| is the (h or cc) file which has actually changed. // |dependencies| are the existing dependencies of |import_file| if this is a // reparse. -std::optional>> Parse( +std::vector> Parse( Config* config, FileConsumerSharedState* file_consumer_shared, std::string file, @@ -526,7 +526,7 @@ std::optional>> Parse( PerformanceImportFile* perf, ClangIndex* index, bool dump_ast = false); -std::optional>> ParseWithTu( +std::vector> ParseWithTu( Config* config, FileConsumerSharedState* file_consumer_shared, PerformanceImportFile* perf, diff --git a/src/test.cc b/src/test.cc index 266ab030..07d083bc 100644 --- a/src/test.cc +++ b/src/test.cc @@ -267,7 +267,6 @@ bool RunIndexTests(const std::string& filter_path, bool enable_update) { PerformanceImportFile perf; auto dbs = Parse(&config, &file_consumer_shared, path, flags, {}, &perf, &index, false /*dump_ast*/); - assert(dbs); for (const auto& entry : all_expected_output) { const std::string& expected_path = entry.first; @@ -298,7 +297,7 @@ bool RunIndexTests(const std::string& filter_path, bool enable_update) { }; // Get output from index operation. - IndexFile* db = FindDbForPathEnding(expected_path, *dbs); + IndexFile* db = FindDbForPathEnding(expected_path, dbs); assert(db); if (!db->diagnostics_.empty()) { std::cout << "For " << path << std::endl;