11#include "clang/Basic/Diagnostic.h"
12#include "clang/Basic/DiagnosticIDs.h"
13#include "clang/Basic/DiagnosticOptions.h"
14#include "clang/Basic/FileManager.h"
15#include "clang/Basic/FileSystemOptions.h"
16#include "clang/Basic/LLVM.h"
17#include "clang/Basic/SourceLocation.h"
18#include "clang/Basic/SourceManager.h"
19#include "clang/Tooling/Core/Replacement.h"
20#include "llvm/ADT/IntrusiveRefCntPtr.h"
21#include "llvm/ADT/StringRef.h"
22#include "llvm/Support/Error.h"
23#include "llvm/Support/MemoryBuffer.h"
24#include "llvm/Support/VirtualFileSystem.h"
25#include "llvm/Testing/Support/Error.h"
26#include "gmock/gmock-matchers.h"
27#include "gmock/gmock.h"
28#include "gtest/gtest.h"
39 auto RelPaths = {
"a.h",
"foo.cpp",
"test/test.cpp"};
41 llvm::IntrusiveRefCntPtr<llvm::vfs::InMemoryFileSystem> MemFS(
42 new llvm::vfs::InMemoryFileSystem);
43 MemFS->setCurrentWorkingDirectory(
testRoot());
44 for (
const auto *
Path : RelPaths)
45 MemFS->addFile(
Path, 0, llvm::MemoryBuffer::getMemBuffer(
"",
Path));
46 FileManager FM(FileSystemOptions(), MemFS);
47 DiagnosticsEngine DE(
new DiagnosticIDs,
new DiagnosticOptions);
48 SourceManager SM(DE, FM);
50 for (
const auto *
Path : RelPaths) {
51 auto FID = SM.createFileID(*FM.getOptionalFileRef(
Path), SourceLocation(),
52 clang::SrcMgr::C_User);
54 ASSERT_THAT_EXPECTED(Res, llvm::Succeeded());
std::string Path
A typedef to represent a file path.
llvm::StringMap< Edit > FileEdits
A mapping from absolute file path (the one used for accessing the underlying VFS) to edits.
std::string testPath(PathRef File, llvm::sys::path::Style Style)
TEST(BackgroundQueueTest, Priority)
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
static llvm::Expected< std::pair< Path, Edit > > fileEdit(const SourceManager &SM, FileID FID, tooling::Replacements Replacements)
Path is the absolute, symlink-resolved path for the file pointed by FID in SM.