diff options
| author | Yitzhak Mandelbaum <yitzhakm@google.com> | 2019-11-13 09:04:13 -0500 |
|---|---|---|
| committer | Yitzhak Mandelbaum <yitzhakm@google.com> | 2019-11-19 12:18:36 -0500 |
| commit | dd471dbe99a7e017357809151df56f2d4c3e7a31 (patch) | |
| tree | 2568cb2200ab90a0a65d5f21050824ff630b0e91 /clang/lib/Tooling | |
| parent | 6e418decd936a3e22dec5cebc77ecb86dc7f37c3 (diff) | |
| download | bcm5719-llvm-dd471dbe99a7e017357809151df56f2d4c3e7a31.tar.gz bcm5719-llvm-dd471dbe99a7e017357809151df56f2d4c3e7a31.zip | |
[libTooling] Extend `buildASTFromCodeWithArgs` to take files argument.
Summary:
Adds an optional parameter to `buildASTFromCodeWithArgs` that allows the user to
pass additional files that the main code needs to compile. This change makes
`buildASTFromCodeWithArgs` consistent with `runToolOnCodeWithArgs`.
Patch by Alexey Eremin.
Reviewers: gribozavr
Subscribers: cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D70175
Diffstat (limited to 'clang/lib/Tooling')
| -rw-r--r-- | clang/lib/Tooling/Tooling.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/clang/lib/Tooling/Tooling.cpp b/clang/lib/Tooling/Tooling.cpp index 1d6a968331b..4a0618c50e4 100644 --- a/clang/lib/Tooling/Tooling.cpp +++ b/clang/lib/Tooling/Tooling.cpp @@ -619,7 +619,7 @@ buildASTFromCode(StringRef Code, StringRef FileName, 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 @@ std::unique_ptr<ASTUnit> buildASTFromCodeWithArgs( 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; |

