@@ -100,11 +100,9 @@ TEST(ParseCommandLineTest, HashInsideDoubleQuotes) {
100100} // namespace frontend_internal
101101
102102namespace {
103- typedef void (*TExtraSourceTreeAction)(const std::filesystem::path&);
104-
105103std::unique_ptr<InMemoryIndex> GetSnippetIndex (
106104 std::string code, const std::vector<std::string>& extra_args = {},
107- bool fail_on_error = false , TExtraSourceTreeAction extra_action = nullptr ) {
105+ bool fail_on_error = false ) {
108106 auto source_dir = std::filesystem::path (::testing::TempDir ()) / " src" ;
109107 std::filesystem::remove_all (source_dir);
110108 CHECK (std::filesystem::create_directory (source_dir));
@@ -116,16 +114,14 @@ std::unique_ptr<InMemoryIndex> GetSnippetIndex(
116114 std::string source_file_path = (source_dir / " snippet.cc" ).string ();
117115 std::string source_dir_path = source_dir.string ();
118116
119- if (extra_action != nullptr ) {
120- extra_action (source_dir);
121- }
122-
123117 auto index_dir = std::filesystem::path (::testing::TempDir ()) / " idx" ;
124118 std::filesystem::remove_all (index_dir);
125119 CHECK (std::filesystem::create_directory (index_dir));
126120 std::string index_dir_path = index_dir.string ();
127121 std::string sysroot_path = " /" ;
122+
128123 FileCopier file_copier (source_dir_path, index_dir_path, {sysroot_path});
124+
129125 std::unique_ptr<MergeQueue> merge_queue = MergeQueue::Create (1 );
130126 auto index_action = std::make_unique<IndexAction>(file_copier, *merge_queue);
131127 const bool result = clang::tooling::runToolOnCodeWithArgs (
@@ -3867,40 +3863,5 @@ TEST(FrontendTest, AliasedSymbol) {
38673863 EXPECT_HAS_ENTITY (index, Entity::Kind::kFunction , " " , " bar" , " ()" ,
38683864 " snippet.cc" , 2 , 2 );
38693865}
3870-
3871- TEST (FrontendTest, GhostFileLocations) {
3872- FlatIndex index =
3873- std::move (
3874- *GetSnippetIndex (
3875- /* code=*/ " #include \" ghostfile.h\"\n " ,
3876- /* extra_args=*/ {},
3877- /* fail_on_error=*/ true ,
3878- /* extra_action=*/
3879- [](const std::filesystem::path& source_dir) {
3880- std::ofstream ghost_file (source_dir / " ghostfile.h" );
3881- ghost_file
3882- << " // Copyright 2025 Google Inc. All rights reserved." ;
3883- CHECK (ghost_file.good ());
3884- }))
3885- .Export ();
3886-
3887- bool found_self = false ;
3888- bool found_include = false ;
3889- bool found_other = false ;
3890- for (const Location& location : index.locations ) {
3891- if (location.is_whole_file ()) {
3892- if (location.path ().ends_with (" snippet.cc" )) {
3893- found_self = true ;
3894- } else if (location.path ().ends_with (" ghostfile.h" )) {
3895- found_include = true ;
3896- }
3897- } else if (location.is_real ()) {
3898- found_other = true ;
3899- }
3900- }
3901- EXPECT_TRUE (found_self);
3902- EXPECT_TRUE (found_include);
3903- EXPECT_FALSE (found_other);
3904- }
39053866} // namespace indexer
39063867} // namespace oss_fuzz
0 commit comments