Add Support for #include in cpp files imported from Carbon (#4809)

Propagate `FileSystem` to `buildASTFromCodeWithArgs`().
Part of #4666
This commit is contained in:
Boaz Brickner
2025-01-15 21:27:58 +00:00
committed by GitHub
parent aa23e9e2d8
commit 28d6aedbbb
4 changed files with 38 additions and 6 deletions
+4 -3
View File
@@ -19,8 +19,9 @@
namespace Carbon::Check {
auto ImportCppFile(Context& context, SemIRLoc loc, llvm::StringRef file_path,
llvm::StringRef code) -> void {
auto ImportCppFile(Context& context, SemIRLoc loc,
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> fs,
llvm::StringRef file_path, llvm::StringRef code) -> void {
std::string diagnostics_str;
llvm::raw_string_ostream diagnostics_stream(diagnostics_str);
@@ -33,7 +34,7 @@ auto ImportCppFile(Context& context, SemIRLoc loc, llvm::StringRef file_path,
code, {}, file_path, "clang-tool",
std::make_shared<clang::PCHContainerOperations>(),
clang::tooling::getClangStripDependencyFileAdjuster(),
clang::tooling::FileContentMappings(), &diagnostics_consumer);
clang::tooling::FileContentMappings(), &diagnostics_consumer, fs);
// TODO: Implement and use a DynamicRecursiveASTVisitor to traverse the AST.
int num_errors = diagnostics_consumer.getNumErrors();
int num_warnings = diagnostics_consumer.getNumWarnings();