[TableGen] Fix validateOperandClass for non Phyical Reg (#118146)
[llvm-project.git] / clang-tools-extra / clangd / unittests / CanonicalIncludesTests.cpp
blob3285306cbc17de7d60dd895a1259be64fe5a2484
1 //===-- CanonicalIncludesTests.cpp - --------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "index/CanonicalIncludes.h"
10 #include "clang/Basic/FileEntry.h"
11 #include "clang/Basic/FileManager.h"
12 #include "clang/Basic/FileSystemOptions.h"
13 #include "clang/Basic/LangOptions.h"
14 #include "llvm/ADT/IntrusiveRefCntPtr.h"
15 #include "llvm/ADT/StringRef.h"
16 #include "llvm/Support/Error.h"
17 #include "llvm/Support/VirtualFileSystem.h"
18 #include "llvm/Testing/Support/Error.h"
19 #include "gtest/gtest.h"
21 namespace clang {
22 namespace clangd {
23 namespace {
25 FileEntryRef addFile(llvm::vfs::InMemoryFileSystem &FS, FileManager &FM,
26 llvm::StringRef Filename) {
27 FS.addFile(Filename, 0, llvm::MemoryBuffer::getMemBuffer(""));
28 auto File = FM.getFileRef(Filename);
29 EXPECT_THAT_EXPECTED(File, llvm::Succeeded());
30 return *File;
33 TEST(CanonicalIncludesTest, SystemHeaderMap) {
34 auto InMemFS = llvm::makeIntrusiveRefCnt<llvm::vfs::InMemoryFileSystem>();
35 FileManager Files(FileSystemOptions(), InMemFS);
37 CanonicalIncludes CI;
38 LangOptions Language;
39 Language.CPlusPlus = true;
40 CI.addSystemHeadersMapping(Language);
42 // We should have a path from 'bits/stl_vector.h' to '<vector>'.
43 // FIXME: The Standrad Library map in CanonicalIncludes expects forward
44 // slashes and Windows would use backward slashes instead, so the headers are
45 // not matched appropriately.
46 auto STLVectorFile = addFile(*InMemFS, Files, "bits/stl_vector.h");
47 ASSERT_EQ("<vector>", CI.mapHeader(STLVectorFile.getName()));
50 } // namespace
51 } // namespace clangd
52 } // namespace clang