This revision was automatically updated to reflect the committed changes.
Closed by commit rGdd471dbe99a7: [libTooling] Extend `buildASTFromCodeWithArgs`
to take files argument. (authored by ymandel).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D70175/new/
https://reviews.llvm.org/D70175
Files:
clang/include/clang/Tooling/Tooling.h
clang/lib/Tooling/Tooling.cpp
Index: clang/lib/Tooling/Tooling.cpp
===================================================================
--- clang/lib/Tooling/Tooling.cpp
+++ clang/lib/Tooling/Tooling.cpp
@@ -619,7 +619,7 @@
std::unique_ptr<ASTUnit> buildASTFromCodeWithArgs(
StringRef Code, const std::vector<std::string> &Args, StringRef FileName,
StringRef ToolName, std::shared_ptr<PCHContainerOperations>
PCHContainerOps,
- ArgumentsAdjuster Adjuster) {
+ ArgumentsAdjuster Adjuster, const FileContentMappings &VirtualMappedFiles)
{
std::vector<std::unique_ptr<ASTUnit>> ASTs;
ASTBuilderAction Action(ASTs);
llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> OverlayFileSystem(
@@ -636,6 +636,12 @@
InMemoryFileSystem->addFile(FileName, 0,
llvm::MemoryBuffer::getMemBufferCopy(Code));
+ for (auto &FilenameWithContent : VirtualMappedFiles) {
+ InMemoryFileSystem->addFile(
+ FilenameWithContent.first, 0,
+ llvm::MemoryBuffer::getMemBuffer(FilenameWithContent.second));
+ }
+
if (!Invocation.run())
return nullptr;
Index: clang/include/clang/Tooling/Tooling.h
===================================================================
--- clang/include/clang/Tooling/Tooling.h
+++ clang/include/clang/Tooling/Tooling.h
@@ -224,7 +224,8 @@
StringRef FileName = "input.cc", StringRef ToolName = "clang-tool",
std::shared_ptr<PCHContainerOperations> PCHContainerOps =
std::make_shared<PCHContainerOperations>(),
- ArgumentsAdjuster Adjuster = getClangStripDependencyFileAdjuster());
+ ArgumentsAdjuster Adjuster = getClangStripDependencyFileAdjuster(),
+ const FileContentMappings &VirtualMappedFiles = FileContentMappings());
/// Utility to run a FrontendAction in a single clang invocation.
class ToolInvocation {
Index: clang/lib/Tooling/Tooling.cpp
===================================================================
--- clang/lib/Tooling/Tooling.cpp
+++ clang/lib/Tooling/Tooling.cpp
@@ -619,7 +619,7 @@
std::unique_ptr<ASTUnit> buildASTFromCodeWithArgs(
StringRef Code, const std::vector<std::string> &Args, StringRef FileName,
StringRef ToolName, std::shared_ptr<PCHContainerOperations> PCHContainerOps,
- ArgumentsAdjuster Adjuster) {
+ ArgumentsAdjuster Adjuster, const FileContentMappings &VirtualMappedFiles) {
std::vector<std::unique_ptr<ASTUnit>> ASTs;
ASTBuilderAction Action(ASTs);
llvm::IntrusiveRefCntPtr<llvm::vfs::OverlayFileSystem> OverlayFileSystem(
@@ -636,6 +636,12 @@
InMemoryFileSystem->addFile(FileName, 0,
llvm::MemoryBuffer::getMemBufferCopy(Code));
+ for (auto &FilenameWithContent : VirtualMappedFiles) {
+ InMemoryFileSystem->addFile(
+ FilenameWithContent.first, 0,
+ llvm::MemoryBuffer::getMemBuffer(FilenameWithContent.second));
+ }
+
if (!Invocation.run())
return nullptr;
Index: clang/include/clang/Tooling/Tooling.h
===================================================================
--- clang/include/clang/Tooling/Tooling.h
+++ clang/include/clang/Tooling/Tooling.h
@@ -224,7 +224,8 @@
StringRef FileName = "input.cc", StringRef ToolName = "clang-tool",
std::shared_ptr<PCHContainerOperations> PCHContainerOps =
std::make_shared<PCHContainerOperations>(),
- ArgumentsAdjuster Adjuster = getClangStripDependencyFileAdjuster());
+ ArgumentsAdjuster Adjuster = getClangStripDependencyFileAdjuster(),
+ const FileContentMappings &VirtualMappedFiles = FileContentMappings());
/// Utility to run a FrontendAction in a single clang invocation.
class ToolInvocation {
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits