Add a failing test for Clang modules support. (#7233)

Rearrange the file_test infrastructure so that we can customize the
mapping of file names to command line arguments. Map `module.modulemap`
files to corresponding Clang driver flags. In passing, also clean up the
interface for specifying custom argument replacements so that we don't
build a string map for each file we process, and stop using
`SmallVector::insert`.

Assisted-by: Gemini via Antigravity
This commit is contained in:
Richard Smith
2026-05-20 20:26:36 +00:00
committed by GitHub
parent be70c092fa
commit f31c553e65
7 changed files with 154 additions and 43 deletions
+15 -4
View File
@@ -31,14 +31,25 @@ class FileTestBaseTest : public FileTestBase {
llvm::raw_pwrite_stream& error_stream) const
-> ErrorOr<RunResult> override;
auto GetArgReplacements() const -> llvm::StringMap<std::string> override {
return {{"replacement", "replaced"}};
}
auto GetDefaultArgs() const -> llvm::SmallVector<std::string> override {
return {"default_args", "%s"};
}
auto AddArgsForFilename(llvm::SmallVectorImpl<std::string>& args,
llvm::StringRef filename) const -> void override {
if (!filename.ends_with(".exclude")) {
args.emplace_back(filename);
}
}
auto GetArgReplacement(llvm::StringRef key) const
-> std::optional<std::string> override {
if (key == "replacement") {
return "replaced";
}
return std::nullopt;
}
auto GetDefaultFileRE(llvm::ArrayRef<llvm::StringRef> filenames) const
-> std::optional<RE2> override {
return std::make_optional<RE2>(