Skip to content

Commit c62e237

Browse files
authored
LLVM and SPIRV-LLVM-Translator pulldown (WW44-45) #2717
LLVM: llvm/llvm-project@d3205bb SPIRV-LLVM-Translator: KhronosGroup/SPIRV-LLVM-Translator@d606b72
2 parents c23c339 + 672e55e commit c62e237

File tree

1,296 files changed

+129526
-12536
lines changed

Some content is hidden

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

1,296 files changed

+129526
-12536
lines changed

clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,22 @@
1313
#include "clang/Lex/PreprocessorOptions.h"
1414
#include "clang/Serialization/ASTReader.h"
1515

16+
#define DEBUG_TYPE "clang-tidy"
17+
1618
namespace clang {
1719
namespace tooling {
1820

1921
class ExpandModularHeadersPPCallbacks::FileRecorder {
2022
public:
2123
/// Records that a given file entry is needed for replaying callbacks.
22-
void addNecessaryFile(const FileEntry *File) { FilesToRecord.insert(File); }
24+
void addNecessaryFile(const FileEntry *File) {
25+
// Don't record modulemap files because it breaks same file detection.
26+
if (!(File->getName().endswith("module.modulemap") ||
27+
File->getName().endswith("module.private.modulemap") ||
28+
File->getName().endswith("module.map") ||
29+
File->getName().endswith("module_private.map")))
30+
FilesToRecord.insert(File);
31+
}
2332

2433
/// Records content for a file and adds it to the FileSystem.
2534
void recordFileContent(const FileEntry *File,
@@ -30,12 +39,12 @@ class ExpandModularHeadersPPCallbacks::FileRecorder {
3039
return;
3140

3241
// FIXME: Why is this happening? We might be losing contents here.
33-
if (!ContentCache.getRawBuffer())
42+
llvm::Optional<StringRef> Data = ContentCache.getBufferDataIfLoaded();
43+
if (!Data)
3444
return;
3545

3646
InMemoryFs.addFile(File->getName(), /*ModificationTime=*/0,
37-
llvm::MemoryBuffer::getMemBufferCopy(
38-
ContentCache.getRawBuffer()->getBuffer()));
47+
llvm::MemoryBuffer::getMemBufferCopy(*Data));
3948
// Remove the file from the set of necessary files.
4049
FilesToRecord.erase(File);
4150
}
@@ -44,8 +53,8 @@ class ExpandModularHeadersPPCallbacks::FileRecorder {
4453
/// `FilesToRecord` should be empty.
4554
void checkAllFilesRecorded() {
4655
for (auto FileEntry : FilesToRecord)
47-
llvm::errs() << "Did not record contents for input file: "
48-
<< FileEntry->getName() << "\n";
56+
LLVM_DEBUG(llvm::dbgs() << "Did not record contents for input file: "
57+
<< FileEntry->getName() << "\n");
4958
}
5059

5160
private:

clang-tools-extra/clang-tidy/google/AvoidCStyleCastsCheck.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ namespace readability {
2525
/// This check is similar to `-Wold-style-cast`, but it suggests automated fixes
2626
/// in some cases. The reported locations should not be different from the
2727
/// ones generated by `-Wold-style-cast`.
28+
///
29+
/// For the user-facing documentation see:
30+
/// http://clang.llvm.org/extra/clang-tidy/checks/google-readability-casting.html
2831
class AvoidCStyleCastsCheck : public ClangTidyCheck {
2932
public:
3033
AvoidCStyleCastsCheck(StringRef Name, ClangTidyContext *Context)

clang-tools-extra/clang-tidy/google/AvoidUnderscoreInGoogletestNameCheck.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ namespace readability {
1818

1919
// Check for underscores in the names of googletest tests, per
2020
// https://github.com/google/googletest/blob/master/googletest/docs/faq.md#why-should-test-suite-names-and-test-names-not-contain-underscore
21+
///
22+
/// For the user-facing documentation see:
23+
/// http://clang.llvm.org/extra/clang-tidy/checks/google-readability-avoid-underscore-in-googletest-name.html
2124
class AvoidUnderscoreInGoogletestNameCheck : public ClangTidyCheck {
2225
public:
2326
using ClangTidyCheck::ClangTidyCheck;

clang-tools-extra/clang-tidy/google/DefaultArgumentsCheck.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ namespace google {
1818
/// Checks that default parameters are not given for virtual methods.
1919
///
2020
/// See https://google.github.io/styleguide/cppguide.html#Default_Arguments
21+
///
22+
/// For the user-facing documentation see:
23+
/// http://clang.llvm.org/extra/clang-tidy/checks/google-default-arguments.html
2124
class DefaultArgumentsCheck : public ClangTidyCheck {
2225
public:
2326
DefaultArgumentsCheck(StringRef Name, ClangTidyContext *Context)

clang-tools-extra/clang-tidy/google/ExplicitConstructorCheck.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ namespace google {
1818
/// Checks that all single-argument constructors are explicit.
1919
///
2020
/// See https://google.github.io/styleguide/cppguide.html#Explicit_Constructors
21+
///
22+
/// For the user-facing documentation see:
23+
/// http://clang.llvm.org/extra/clang-tidy/checks/google-explicit-constructor.html
2124
class ExplicitConstructorCheck : public ClangTidyCheck {
2225
public:
2326
ExplicitConstructorCheck(StringRef Name, ClangTidyContext *Context)

clang-tools-extra/clang-tidy/google/ExplicitMakePairCheck.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ namespace build {
2222
/// specified explicitly, and such use isn't intended in any case.
2323
///
2424
/// Corresponding cpplint.py check name: 'build/explicit_make_pair'.
25+
///
26+
/// For the user-facing documentation see:
27+
/// http://clang.llvm.org/extra/clang-tidy/checks/google-build-explicit-make-pair.html
2528
class ExplicitMakePairCheck : public ClangTidyCheck {
2629
public:
2730
ExplicitMakePairCheck(StringRef Name, ClangTidyContext *Context)

clang-tools-extra/clang-tidy/google/GlobalNamesInHeadersCheck.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ namespace readability {
2727
///
2828
/// For extension-less header files, using an empty string or leaving an
2929
/// empty string between ";" if there are other filename extensions.
30+
///
31+
/// For the user-facing documentation see:
32+
/// http://clang.llvm.org/extra/clang-tidy/checks/google-global-names-in-headers.html
3033
class GlobalNamesInHeadersCheck : public ClangTidyCheck {
3134
public:
3235
GlobalNamesInHeadersCheck(StringRef Name, ClangTidyContext *Context);

clang-tools-extra/clang-tidy/google/IntegerTypesCheck.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ namespace runtime {
2525
/// with `u?intXX(_t)?`.
2626
///
2727
/// Corresponding cpplint.py check: 'runtime/int'.
28+
///
29+
/// For the user-facing documentation see:
30+
/// http://clang.llvm.org/extra/clang-tidy/checks/google-runtime-int.html
2831
class IntegerTypesCheck : public ClangTidyCheck {
2932
public:
3033
IntegerTypesCheck(StringRef Name, ClangTidyContext *Context);

clang-tools-extra/clang-tidy/google/OverloadedUnaryAndCheck.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ namespace runtime {
2121
/// https://google.github.io/styleguide/cppguide.html#Operator_Overloading
2222
///
2323
/// Corresponding cpplint.py check name: 'runtime/operator'.
24+
///
25+
/// For the user-facing documentation see:
26+
/// http://clang.llvm.org/extra/clang-tidy/checks/google-runtime-operator.html
2427
class OverloadedUnaryAndCheck : public ClangTidyCheck {
2528
public:
2629
OverloadedUnaryAndCheck(StringRef Name, ClangTidyContext *Context)

clang-tools-extra/clang-tidy/google/TodoCommentCheck.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ namespace readability {
1919
/// Finds TODO comments without a username or bug number.
2020
///
2121
/// Corresponding cpplint.py check: 'readability/todo'
22+
///
23+
/// For the user-facing documentation see:
24+
/// http://clang.llvm.org/extra/clang-tidy/checks/google-readability-todo.html
2225
class TodoCommentCheck : public ClangTidyCheck {
2326
public:
2427
TodoCommentCheck(StringRef Name, ClangTidyContext *Context);

clang-tools-extra/clang-tidy/google/UnnamedNamespaceInHeaderCheck.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ namespace build {
3030
/// https://google.github.io/styleguide/cppguide.html#Namespaces
3131
///
3232
/// Corresponding cpplint.py check name: 'build/namespaces'.
33+
///
34+
/// For the user-facing documentation see:
35+
/// http://clang.llvm.org/extra/clang-tidy/checks/google-build-namespaces.html
3336
class UnnamedNamespaceInHeaderCheck : public ClangTidyCheck {
3437
public:
3538
UnnamedNamespaceInHeaderCheck(StringRef Name, ClangTidyContext *Context);

clang-tools-extra/clang-tidy/google/UsingNamespaceDirectiveCheck.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ namespace build {
3131
/// \endcode
3232
///
3333
/// Corresponding cpplint.py check name: `build/namespaces`.
34+
///
35+
/// For the user-facing documentation see:
36+
/// https://clang.llvm.org/extra/clang-tidy/checks/google-build-using-namespace.html
3437
class UsingNamespaceDirectiveCheck : public ClangTidyCheck {
3538
public:
3639
UsingNamespaceDirectiveCheck(StringRef Name, ClangTidyContext *Context)

clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,10 @@ void UnnecessaryCopyInitialization::registerMatchers(MatchFinder *Finder) {
6363
declStmt(
6464
has(varDecl(hasLocalStorage(),
6565
hasType(qualType(
66-
hasCanonicalType(
67-
matchers::isExpensiveToCopy()),
66+
hasCanonicalType(allOf(
67+
matchers::isExpensiveToCopy(),
68+
unless(hasDeclaration(namedDecl(
69+
hasName("::std::function")))))),
6870
unless(hasDeclaration(namedDecl(
6971
matchers::matchesAnyListedName(
7072
AllowedTypes)))))),

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: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
if (CLANGD_ENABLE_REMOTE)
2-
generate_grpc_protos(RemoteIndexProtos "Index.proto")
2+
generate_protos(RemoteIndexServiceProto "Service.proto" GRPC)
3+
generate_protos(RemoteIndexProto "Index.proto")
4+
add_dependencies(RemoteIndexServiceProto RemoteIndexProto)
35
include_directories(${CMAKE_CURRENT_BINARY_DIR})
46
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../)
57

@@ -12,7 +14,8 @@ if (CLANGD_ENABLE_REMOTE)
1214
Client.cpp
1315

1416
LINK_LIBS
15-
RemoteIndexProtos
17+
RemoteIndexProto
18+
RemoteIndexServiceProto
1619
clangdRemoteMarshalling
1720

1821
protobuf
@@ -21,7 +24,8 @@ if (CLANGD_ENABLE_REMOTE)
2124
clangdSupport
2225

2326
DEPENDS
24-
RemoteIndexProtos
27+
RemoteIndexProto
28+
RemoteIndexServiceProto
2529
)
2630

2731
add_subdirectory(marshalling)

clang-tools-extra/clangd/index/remote/Client.cpp

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@
99
#include <grpc++/grpc++.h>
1010

1111
#include "Client.h"
12-
#include "Index.grpc.pb.h"
12+
#include "Service.grpc.pb.h"
1313
#include "index/Index.h"
1414
#include "index/Serialization.h"
1515
#include "marshalling/Marshalling.h"
1616
#include "support/Logger.h"
1717
#include "support/Trace.h"
18+
#include "clang/Basic/Version.h"
1819
#include "llvm/ADT/StringRef.h"
1920
#include "llvm/Support/Error.h"
2021

@@ -28,7 +29,8 @@ namespace {
2829
class IndexClient : public clangd::SymbolIndex {
2930
template <typename RequestT, typename ReplyT>
3031
using StreamingCall = std::unique_ptr<grpc::ClientReader<ReplyT>> (
31-
remote::SymbolIndex::Stub::*)(grpc::ClientContext *, const RequestT &);
32+
remote::v1::SymbolIndex::Stub::*)(grpc::ClientContext *,
33+
const RequestT &);
3234

3335
template <typename RequestT, typename ReplyT, typename ClangdRequestT,
3436
typename CallbackT>
@@ -40,6 +42,7 @@ class IndexClient : public clangd::SymbolIndex {
4042
const auto RPCRequest = ProtobufMarshaller->toProtobuf(Request);
4143
SPAN_ATTACH(Tracer, "Request", RPCRequest.DebugString());
4244
grpc::ClientContext Context;
45+
Context.AddMetadata("version", clang::getClangToolFullVersion("clangd"));
4346
std::chrono::system_clock::time_point Deadline =
4447
std::chrono::system_clock::now() + DeadlineWaitingTime;
4548
Context.set_deadline(Deadline);
@@ -73,7 +76,7 @@ class IndexClient : public clangd::SymbolIndex {
7376
IndexClient(
7477
std::shared_ptr<grpc::Channel> Channel, llvm::StringRef ProjectRoot,
7578
std::chrono::milliseconds DeadlineTime = std::chrono::milliseconds(1000))
76-
: Stub(remote::SymbolIndex::NewStub(Channel)),
79+
: Stub(remote::v1::SymbolIndex::NewStub(Channel)),
7780
ProtobufMarshaller(new Marshaller(/*RemoteIndexRoot=*/"",
7881
/*LocalIndexRoot=*/ProjectRoot)),
7982
DeadlineWaitingTime(DeadlineTime) {
@@ -82,25 +85,26 @@ class IndexClient : public clangd::SymbolIndex {
8285

8386
void lookup(const clangd::LookupRequest &Request,
8487
llvm::function_ref<void(const clangd::Symbol &)> Callback) const {
85-
streamRPC(Request, &remote::SymbolIndex::Stub::Lookup, Callback);
88+
streamRPC(Request, &remote::v1::SymbolIndex::Stub::Lookup, Callback);
8689
}
8790

8891
bool
8992
fuzzyFind(const clangd::FuzzyFindRequest &Request,
9093
llvm::function_ref<void(const clangd::Symbol &)> Callback) const {
91-
return streamRPC(Request, &remote::SymbolIndex::Stub::FuzzyFind, Callback);
94+
return streamRPC(Request, &remote::v1::SymbolIndex::Stub::FuzzyFind,
95+
Callback);
9296
}
9397

9498
bool refs(const clangd::RefsRequest &Request,
9599
llvm::function_ref<void(const clangd::Ref &)> Callback) const {
96-
return streamRPC(Request, &remote::SymbolIndex::Stub::Refs, Callback);
100+
return streamRPC(Request, &remote::v1::SymbolIndex::Stub::Refs, Callback);
97101
}
98102

99103
void
100104
relations(const clangd::RelationsRequest &Request,
101105
llvm::function_ref<void(const SymbolID &, const clangd::Symbol &)>
102106
Callback) const {
103-
streamRPC(Request, &remote::SymbolIndex::Stub::Relations,
107+
streamRPC(Request, &remote::v1::SymbolIndex::Stub::Relations,
104108
// Unpack protobuf Relation.
105109
[&](std::pair<SymbolID, clangd::Symbol> SubjectAndObject) {
106110
Callback(SubjectAndObject.first, SubjectAndObject.second);
@@ -112,7 +116,7 @@ class IndexClient : public clangd::SymbolIndex {
112116
size_t estimateMemoryUsage() const { return 0; }
113117

114118
private:
115-
std::unique_ptr<remote::SymbolIndex::Stub> Stub;
119+
std::unique_ptr<remote::v1::SymbolIndex::Stub> Stub;
116120
std::unique_ptr<Marshaller> ProtobufMarshaller;
117121
// Each request will be terminated if it takes too long.
118122
std::chrono::milliseconds DeadlineWaitingTime;

0 commit comments

Comments
 (0)