Allow repeated includes, particularly for min_prelude (#5741)

Make min_prelude parts include what they use, and remove the inclusions
which were for indirect uses from the main min_prelude files.
This commit is contained in:
Jon Ross-Perkins
2025-06-26 21:59:55 +00:00
committed by GitHub
parent c3b0c2e425
commit 49212feac6
11 changed files with 36 additions and 18 deletions
+7
View File
@@ -13,6 +13,7 @@
#include "common/error.h"
#include "common/find.h"
#include "common/raw_string_ostream.h"
#include "common/set.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/JSON.h"
#include "testing/base/file_helpers.h"
@@ -835,8 +836,14 @@ auto ProcessTestFile(llvm::StringRef test_name, bool running_autoupdate)
}
// Process includes. This can add entries to `include_files`.
Set<std::string> processed_includes;
for (size_t i = 0; i < include_files.size(); ++i) {
const auto& filename = include_files[i];
if (!processed_includes.Insert(filename).is_inserted()) {
// Ignore repeated includes, mainly so that included files can include the
// same file (i.e., repeated indirectly).
continue;
}
CARBON_ASSIGN_OR_RETURN(std::string content, ReadFile(filename));
// Note autoupdate never touches included files.
CARBON_RETURN_IF_ERROR(ProcessFileContent(