Skip to content

Commit fd070d4

Browse files
committed
Merge from 'master' to 'sycl-web' (intel#103)
CONFLICT (content): Merge conflict in clang/test/CodeGen/annotations-field.c CONFLICT (content): Merge conflict in clang/lib/CodeGen/CodeGenFunction.cpp
2 parents 39c338d + d3205bb commit fd070d4

File tree

378 files changed

+10162
-2131
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

378 files changed

+10162
-2131
lines changed

clang-tools-extra/clangd/ParsedAST.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,9 @@ class ReplayPreamble : private PPCallbacks {
170170

171171
void replay() {
172172
for (const auto &Inc : Includes) {
173-
const FileEntry *File = nullptr;
173+
llvm::Optional<FileEntryRef> File;
174174
if (Inc.Resolved != "")
175-
if (auto FE = SM.getFileManager().getFile(Inc.Resolved))
176-
File = *FE;
175+
File = expectedToOptional(SM.getFileManager().getFileRef(Inc.Resolved));
177176

178177
// Re-lex the #include directive to find its interesting parts.
179178
auto HashLoc = SM.getComposedLoc(SM.getMainFileID(), Inc.HashOffset);
@@ -211,17 +210,16 @@ class ReplayPreamble : private PPCallbacks {
211210
SynthesizedFilenameTok.setKind(tok::header_name);
212211
SynthesizedFilenameTok.setLiteralData(Inc.Written.data());
213212

213+
const FileEntry *FE = File ? &File->getFileEntry() : nullptr;
214214
llvm::StringRef WrittenFilename =
215215
llvm::StringRef(Inc.Written).drop_front().drop_back();
216216
Delegate->InclusionDirective(HashTok->location(), SynthesizedIncludeTok,
217217
WrittenFilename, Inc.Written.front() == '<',
218-
FileTok->range(SM).toCharRange(SM), File,
218+
FileTok->range(SM).toCharRange(SM), FE,
219219
"SearchPath", "RelPath",
220220
/*Imported=*/nullptr, Inc.FileKind);
221221
if (File)
222-
// FIXME: Use correctly named FileEntryRef.
223-
Delegate->FileSkipped(FileEntryRef(File->getName(), *File),
224-
SynthesizedFilenameTok, Inc.FileKind);
222+
Delegate->FileSkipped(*File, SynthesizedFilenameTok, Inc.FileKind);
225223
else {
226224
llvm::SmallString<1> UnusedRecovery;
227225
Delegate->FileNotFound(WrittenFilename, UnusedRecovery);

clang-tools-extra/clangd/index/remote/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
if (CLANGD_ENABLE_REMOTE)
22
generate_protos(RemoteIndexServiceProto "Service.proto" GRPC)
33
generate_protos(RemoteIndexProto "Index.proto")
4+
add_dependencies(RemoteIndexServiceProto RemoteIndexProto)
45
include_directories(${CMAKE_CURRENT_BINARY_DIR})
56
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../)
67

clang-tools-extra/clangd/unittests/BackgroundIndexTests.cpp

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -230,49 +230,6 @@ TEST_F(BackgroundIndexTest, IndexTwoFiles) {
230230
FileURI("unittest:///root/B.cc")}));
231231
}
232232

233-
TEST_F(BackgroundIndexTest, RelationsMultiFile) {
234-
MockFS FS;
235-
FS.Files[testPath("root/Base.h")] = "class Base {};";
236-
FS.Files[testPath("root/A.cc")] = R"cpp(
237-
#include "Base.h"
238-
class A : public Base {};
239-
)cpp";
240-
FS.Files[testPath("root/B.cc")] = R"cpp(
241-
#include "Base.h"
242-
class B : public Base {};
243-
)cpp";
244-
245-
llvm::StringMap<std::string> Storage;
246-
size_t CacheHits = 0;
247-
MemoryShardStorage MSS(Storage, CacheHits);
248-
OverlayCDB CDB(/*Base=*/nullptr);
249-
BackgroundIndex Index(FS, CDB, [&](llvm::StringRef) { return &MSS; },
250-
/*Opts=*/{});
251-
252-
tooling::CompileCommand Cmd;
253-
Cmd.Filename = testPath("root/A.cc");
254-
Cmd.Directory = testPath("root");
255-
Cmd.CommandLine = {"clang++", Cmd.Filename};
256-
CDB.setCompileCommand(testPath("root/A.cc"), Cmd);
257-
ASSERT_TRUE(Index.blockUntilIdleForTest());
258-
259-
Cmd.Filename = testPath("root/B.cc");
260-
Cmd.CommandLine = {"clang++", Cmd.Filename};
261-
CDB.setCompileCommand(testPath("root/B.cc"), Cmd);
262-
ASSERT_TRUE(Index.blockUntilIdleForTest());
263-
264-
auto HeaderShard = MSS.loadShard(testPath("root/Base.h"));
265-
EXPECT_NE(HeaderShard, nullptr);
266-
SymbolID Base = findSymbol(*HeaderShard->Symbols, "Base").ID;
267-
268-
RelationsRequest Req;
269-
Req.Subjects.insert(Base);
270-
Req.Predicate = RelationKind::BaseOf;
271-
uint32_t Results = 0;
272-
Index.relations(Req, [&](const SymbolID &, const Symbol &) { ++Results; });
273-
EXPECT_EQ(Results, 2u);
274-
}
275-
276233
TEST_F(BackgroundIndexTest, MainFileRefs) {
277234
MockFS FS;
278235
FS.Files[testPath("root/A.h")] = R"cpp(

clang-tools-extra/clangd/unittests/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ add_unittest(ClangdUnitTests ClangdTests
8888
TestFS.cpp
8989
TestIndex.cpp
9090
TestTU.cpp
91+
TestWorkspace.cpp
9192
TypeHierarchyTests.cpp
9293
TweakTests.cpp
9394
TweakTesting.cpp

clang-tools-extra/clangd/unittests/FileIndexTests.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include "SyncAPI.h"
1515
#include "TestFS.h"
1616
#include "TestTU.h"
17+
#include "TestWorkspace.h"
1718
#include "URI.h"
1819
#include "index/CanonicalIncludes.h"
1920
#include "index/FileIndex.h"
@@ -426,6 +427,33 @@ TEST(FileIndexTest, Relations) {
426427
EXPECT_EQ(Results, 1u);
427428
}
428429

430+
TEST(FileIndexTest, RelationsMultiFile) {
431+
TestWorkspace Workspace;
432+
Workspace.addSource("Base.h", "class Base {};");
433+
Workspace.addMainFile("A.cpp", R"cpp(
434+
#include "Base.h"
435+
class A : public Base {};
436+
)cpp");
437+
Workspace.addMainFile("B.cpp", R"cpp(
438+
#include "Base.h"
439+
class B : public Base {};
440+
)cpp");
441+
442+
auto Index = Workspace.index();
443+
FuzzyFindRequest FFReq;
444+
FFReq.Query = "Base";
445+
FFReq.AnyScope = true;
446+
SymbolID Base;
447+
Index->fuzzyFind(FFReq, [&](const Symbol &S) { Base = S.ID; });
448+
449+
RelationsRequest Req;
450+
Req.Subjects.insert(Base);
451+
Req.Predicate = RelationKind::BaseOf;
452+
uint32_t Results = 0;
453+
Index->relations(Req, [&](const SymbolID &, const Symbol &) { ++Results; });
454+
EXPECT_EQ(Results, 2u);
455+
}
456+
429457
TEST(FileIndexTest, ReferencesInMainFileWithPreamble) {
430458
TestTU TU;
431459
TU.HeaderCode = "class Foo{};";

clang-tools-extra/clangd/unittests/TestTU.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ void deleteModuleCache(const std::string ModuleCachePath) {
8080
}
8181
}
8282

83-
std::shared_ptr<const PreambleData> TestTU::preamble() const {
83+
std::shared_ptr<const PreambleData>
84+
TestTU::preamble(PreambleParsedCallback PreambleCallback) const {
8485
MockFS FS;
8586
auto Inputs = inputs(FS);
8687
IgnoreDiagnostics Diags;
@@ -91,8 +92,7 @@ std::shared_ptr<const PreambleData> TestTU::preamble() const {
9192
auto ModuleCacheDeleter = llvm::make_scope_exit(
9293
std::bind(deleteModuleCache, CI->getHeaderSearchOpts().ModuleCachePath));
9394
return clang::clangd::buildPreamble(testPath(Filename), *CI, Inputs,
94-
/*StoreInMemory=*/true,
95-
/*PreambleCallback=*/nullptr);
95+
/*StoreInMemory=*/true, PreambleCallback);
9696
}
9797

9898
ParsedAST TestTU::build() const {

clang-tools-extra/clangd/unittests/TestTU.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ struct TestTU {
7979
// By default, build() will report Error diagnostics as GTest errors.
8080
// Suppress this behavior by adding an 'error-ok' comment to the code.
8181
ParsedAST build() const;
82-
std::shared_ptr<const PreambleData> preamble() const;
82+
std::shared_ptr<const PreambleData>
83+
preamble(PreambleParsedCallback PreambleCallback = nullptr) const;
8384
ParseInputs inputs(MockFS &FS) const;
8485
SymbolSlab headerSymbols() const;
8586
RefSlab headerRefs() const;
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
//===--- TestWorkspace.cpp - Utility for writing multi-file tests -*- C++-*===//
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+
//===----------------------------------------------------------------------===//
8+
9+
#include "TestWorkspace.h"
10+
11+
namespace clang {
12+
namespace clangd {
13+
14+
std::unique_ptr<SymbolIndex> TestWorkspace::index() {
15+
auto Index = std::make_unique<FileIndex>();
16+
for (const auto &Input : Inputs) {
17+
if (!Input.second.IsMainFile)
18+
continue;
19+
TU.Code = Input.second.Code;
20+
TU.Filename = Input.first().str();
21+
TU.preamble([&](ASTContext &Ctx, std::shared_ptr<clang::Preprocessor> PP,
22+
const CanonicalIncludes &CanonIncludes) {
23+
Index->updatePreamble(testPath(Input.first()), "null", Ctx, PP,
24+
CanonIncludes);
25+
});
26+
ParsedAST MainAST = TU.build();
27+
Index->updateMain(testPath(Input.first()), MainAST);
28+
}
29+
return Index;
30+
}
31+
32+
Optional<ParsedAST> TestWorkspace::openFile(llvm::StringRef Filename) {
33+
auto It = Inputs.find(Filename);
34+
if (It == Inputs.end()) {
35+
ADD_FAILURE() << "Accessing non-existing file: " << Filename;
36+
return llvm::None;
37+
}
38+
TU.Code = It->second.Code;
39+
TU.Filename = It->first().str();
40+
return TU.build();
41+
}
42+
43+
void TestWorkspace::addInput(llvm::StringRef Filename,
44+
const SourceFile &Input) {
45+
Inputs.insert(std::make_pair(Filename, Input));
46+
TU.AdditionalFiles.insert(std::make_pair(Filename, Input.Code));
47+
}
48+
} // namespace clangd
49+
} // namespace clang
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
//===--- TestWorkspace.h - Utility for writing multi-file tests --*- C++-*-===//
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+
//===----------------------------------------------------------------------===//
8+
//
9+
// TestWorkspace builds on TestTU to provide a way to write tests involving
10+
// several related files with inclusion relationships between them.
11+
//
12+
// The tests can exercise both index and AST based operations.
13+
//
14+
//===---------------------------------------------------------------------===//
15+
16+
#ifndef LLVM_CLANG_TOOLS_EXTRA_UNITTESTS_CLANGD_TESTWORKSPACE_H
17+
#define LLVM_CLANG_TOOLS_EXTRA_UNITTESTS_CLANGD_TESTWORKSPACE_H
18+
19+
#include "TestFS.h"
20+
#include "TestTU.h"
21+
#include "index/FileIndex.h"
22+
#include "index/Index.h"
23+
#include "llvm/ADT/StringRef.h"
24+
#include <string>
25+
#include <vector>
26+
27+
namespace clang {
28+
namespace clangd {
29+
30+
class TestWorkspace {
31+
public:
32+
// The difference between addSource() and addMainFile() is that only main
33+
// files will be indexed.
34+
void addSource(llvm::StringRef Filename, llvm::StringRef Code) {
35+
addInput(Filename.str(), {Code.str(), /*IsMainFile=*/false});
36+
}
37+
void addMainFile(llvm::StringRef Filename, llvm::StringRef Code) {
38+
addInput(Filename.str(), {Code.str(), /*IsMainFile=*/true});
39+
}
40+
41+
std::unique_ptr<SymbolIndex> index();
42+
43+
Optional<ParsedAST> openFile(llvm::StringRef Filename);
44+
45+
private:
46+
struct SourceFile {
47+
std::string Code;
48+
bool IsMainFile = false;
49+
};
50+
llvm::StringMap<SourceFile> Inputs;
51+
TestTU TU;
52+
53+
void addInput(llvm::StringRef Filename, const SourceFile &Input);
54+
};
55+
56+
} // namespace clangd
57+
} // namespace clang
58+
59+
#endif // LLVM_CLANG_TOOLS_EXTRA_UNITTESTS_CLANGD_TESTWORKSPACE_H

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,8 @@ X86 Support in Clang
190190
- The x86 intrinsics ``__rorb``, ``__rorw``, ``__rord``, ``__rorq`, ``_rotr``,
191191
``_rotwr`` and ``_lrotr`` may now be used within constant expressions.
192192

193-
- Support for ``-march=sapphirerapids`` was added.
193+
- Support for ``-march=alderlake``, ``-march=sapphirerapids`` and
194+
``-march=znver3`` was added.
194195

195196
- Support for ``-march=x86-64-v[234]`` has been added.
196197
See :doc:`UsersManual` for details about these micro-architecture levels.

0 commit comments

Comments
 (0)