diff --git a/src/tools/clangrefactoringbackend/source/symbolindexer.cpp b/src/tools/clangrefactoringbackend/source/symbolindexer.cpp index dd1069736ff..9c84c4666a6 100644 --- a/src/tools/clangrefactoringbackend/source/symbolindexer.cpp +++ b/src/tools/clangrefactoringbackend/source/symbolindexer.cpp @@ -102,7 +102,7 @@ void SymbolIndexer::updateProjectPart(ProjectPartContainer &&projectPart) sourcePathId); if (!m_modifiedTimeChecker.isUpToDate(dependentTimeStamps)) { - auto indexing = [projectPart = std::move(projectPart), + auto indexing = [projectPart, sourcePathId, preIncludeSearchPath = m_environment.preIncludeSearchPath(), this](SymbolsCollectorInterface &symbolsCollector) { diff --git a/tests/unit/unittest/symbolindexer-test.cpp b/tests/unit/unittest/symbolindexer-test.cpp index 35943235325..2972e2019e9 100644 --- a/tests/unit/unittest/symbolindexer-test.cpp +++ b/tests/unit/unittest/symbolindexer-test.cpp @@ -1743,4 +1743,68 @@ TEST_F(SymbolIndexer, DISABLED_UpToDateFilesAreNotParsedInUpdateProjectParts) indexer.updateProjectParts({projectPart1}); } +TEST_F(SymbolIndexer, MultipleSourceFiles) +{ + ProjectPartContainer projectPart{0, + {}, + {{"BAR", "1", 1}, {"FOO", "1", 2}}, + Utils::clone(systemIncludeSearchPaths), + Utils::clone(projectIncludeSearchPaths), + {header1PathId, header2PathId}, + {main1PathId, main2PathId}, + Utils::Language::Cxx, + Utils::LanguageVersion::CXX14, + Utils::LanguageExtension::None}; + + EXPECT_CALL(mockCollector, + setFile(main1PathId, + ElementsAre("clang++", + "-w", + "-DNOMINMAX", + "-x", + "c++", + "-std=c++14", + "-nostdinc", + "-nostdinc++", + "-DBAR=1", + "-DFOO=1", + "-isystem", + toNativePath(TESTDATA_DIR "/preincludes"), + "-I", + toNativePath("/project/includes"), + "-I", + toNativePath("/other/project/includes"), + "-isystem", + toNativePath(TESTDATA_DIR), + "-isystem", + toNativePath("/other/includes"), + "-isystem", + toNativePath("/includes")))); + EXPECT_CALL(mockCollector, + setFile(main2PathId, + ElementsAre("clang++", + "-w", + "-DNOMINMAX", + "-x", + "c++", + "-std=c++14", + "-nostdinc", + "-nostdinc++", + "-DBAR=1", + "-DFOO=1", + "-isystem", + toNativePath(TESTDATA_DIR "/preincludes"), + "-I", + toNativePath("/project/includes"), + "-I", + toNativePath("/other/project/includes"), + "-isystem", + toNativePath(TESTDATA_DIR), + "-isystem", + toNativePath("/other/includes"), + "-isystem", + toNativePath("/includes")))); + + indexer.updateProjectParts({projectPart}); } +} // namespace