Add namespace alias clang::vfs = llvm::vfs to adapt D52783

This commit is contained in:
Fangrui Song 2018-10-10 09:52:41 -07:00
parent e29056b2db
commit e8317bd538
5 changed files with 16 additions and 9 deletions

View File

@ -114,11 +114,11 @@ struct PreambleStatCache {
return new VFS(std::move(FS), *this);
}
IntrusiveRefCntPtr<vfs::FileSystem>
Consumer(IntrusiveRefCntPtr<vfs::FileSystem> FS) {
struct VFS : vfs::ProxyFileSystem {
IntrusiveRefCntPtr<llvm::vfs::FileSystem>
Consumer(IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS) {
struct VFS : llvm::vfs::ProxyFileSystem {
const PreambleStatCache &Cache;
VFS(IntrusiveRefCntPtr<vfs::FileSystem> FS,
VFS(IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS,
const PreambleStatCache &Cache)
: ProxyFileSystem(std::move(FS)), Cache(Cache) {}
llvm::ErrorOr<vfs::Status> status(const Twine &Path) override {

View File

@ -63,8 +63,8 @@ struct CompletionSession
bool inferred = false;
// TODO share
llvm::IntrusiveRefCntPtr<clang::vfs::FileSystem> FS =
clang::vfs::getRealFileSystem();
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS =
llvm::vfs::getRealFileSystem();
std::shared_ptr<clang::PCHContainerOperations> PCH;
CompletionSession(const Project::Entry &file, WorkingFiles *wfiles,

View File

@ -83,7 +83,7 @@ Range FromTokenRange(const SourceManager &SM, const LangOptions &LangOpts,
std::unique_ptr<CompilerInvocation>
BuildCompilerInvocation(std::vector<const char *> args,
IntrusiveRefCntPtr<vfs::FileSystem> VFS) {
IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS) {
std::string save = "-resource-dir=" + g_config->clang.resourceDir;
args.push_back(save.c_str());
IntrusiveRefCntPtr<DiagnosticsEngine> Diags(

View File

@ -22,6 +22,13 @@ limitations under the License.
#include <clang/Basic/SourceManager.h>
#include <clang/Frontend/CompilerInstance.h>
#if LLVM_VERSION_MAJOR < 8
// D52783 Lift VFS from clang to llvm
namespace llvm {
namespace vfs = clang::vfs;
}
#endif
std::string PathFromFileEntry(const clang::FileEntry &file);
Range FromCharSourceRange(const clang::SourceManager &SM,
@ -39,6 +46,6 @@ Range FromTokenRange(const clang::SourceManager &SM,
std::unique_ptr<clang::CompilerInvocation>
BuildCompilerInvocation(std::vector<const char *> args,
llvm::IntrusiveRefCntPtr<clang::vfs::FileSystem> VFS);
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS);
const char *ClangBuiltinTypeName(int);

View File

@ -1225,7 +1225,7 @@ Index(CompletionManager *completion, WorkingFiles *wfiles, VFS *vfs,
const std::vector<std::pair<std::string, std::string>> &remapped, bool &ok) {
ok = true;
auto PCH = std::make_shared<PCHContainerOperations>();
llvm::IntrusiveRefCntPtr<vfs::FileSystem> FS = vfs::getRealFileSystem();
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS = llvm::vfs::getRealFileSystem();
std::shared_ptr<CompilerInvocation> CI = BuildCompilerInvocation(args, FS);
// e.g. .s
if (!CI)