Skip to content

Commit 2eb1abc

Browse files
committed
Merge from 'master' to 'sycl-web' (#1)
2 parents 4141218 + 89051eb commit 2eb1abc

File tree

584 files changed

+14841
-6383
lines changed

Some content is hidden

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

584 files changed

+14841
-6383
lines changed

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -329,12 +329,11 @@ static void setStaticAnalyzerCheckerOpts(const ClangTidyOptions &Opts,
329329
AnalyzerOptionsRef AnalyzerOptions) {
330330
StringRef AnalyzerPrefix(AnalyzerCheckNamePrefix);
331331
for (const auto &Opt : Opts.CheckOptions) {
332-
StringRef OptName(Opt.first);
333-
if (!OptName.startswith(AnalyzerPrefix))
332+
StringRef OptName(Opt.getKey());
333+
if (!OptName.consume_front(AnalyzerPrefix))
334334
continue;
335335
// Analyzer options are always local options so we can ignore priority.
336-
AnalyzerOptions->Config[OptName.substr(AnalyzerPrefix.size())] =
337-
Opt.second.Value;
336+
AnalyzerOptions->Config[OptName] = Opt.getValue().Value;
338337
}
339338
}
340339

@@ -450,8 +449,8 @@ ClangTidyASTConsumerFactory::CreateASTConsumer(
450449
std::vector<std::string> ClangTidyASTConsumerFactory::getCheckNames() {
451450
std::vector<std::string> CheckNames;
452451
for (const auto &CheckFactory : *CheckFactories) {
453-
if (Context.isCheckEnabled(CheckFactory.first))
454-
CheckNames.push_back(CheckFactory.first);
452+
if (Context.isCheckEnabled(CheckFactory.getKey()))
453+
CheckNames.emplace_back(CheckFactory.getKey());
455454
}
456455

457456
#if CLANG_ENABLE_STATIC_ANALYZER

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ llvm::Expected<std::string>
7272
ClangTidyCheck::OptionsView::get(StringRef LocalName) const {
7373
const auto &Iter = CheckOptions.find(NamePrefix + LocalName.str());
7474
if (Iter != CheckOptions.end())
75-
return Iter->second.Value;
75+
return Iter->getValue().Value;
7676
return llvm::make_error<MissingOptionError>((NamePrefix + LocalName).str());
7777
}
7878

@@ -85,7 +85,7 @@ findPriorityOption(const ClangTidyOptions::OptionMap &Options, StringRef NamePre
8585
return IterGlobal;
8686
if (IterGlobal == Options.end())
8787
return IterLocal;
88-
if (IterLocal->second.Priority >= IterGlobal->second.Priority)
88+
if (IterLocal->getValue().Priority >= IterGlobal->getValue().Priority)
8989
return IterLocal;
9090
return IterGlobal;
9191
}
@@ -94,7 +94,7 @@ llvm::Expected<std::string>
9494
ClangTidyCheck::OptionsView::getLocalOrGlobal(StringRef LocalName) const {
9595
auto Iter = findPriorityOption(CheckOptions, NamePrefix, LocalName);
9696
if (Iter != CheckOptions.end())
97-
return Iter->second.Value;
97+
return Iter->getValue().Value;
9898
return llvm::make_error<MissingOptionError>((NamePrefix + LocalName).str());
9999
}
100100

@@ -135,7 +135,7 @@ llvm::Expected<bool>
135135
ClangTidyCheck::OptionsView::getLocalOrGlobal<bool>(StringRef LocalName) const {
136136
auto Iter = findPriorityOption(CheckOptions, NamePrefix, LocalName);
137137
if (Iter != CheckOptions.end())
138-
return getAsBool(Iter->second.Value, Iter->first);
138+
return getAsBool(Iter->getValue().Value, Iter->getKey());
139139
return llvm::make_error<MissingOptionError>((NamePrefix + LocalName).str());
140140
}
141141

@@ -177,7 +177,7 @@ llvm::Expected<int64_t> ClangTidyCheck::OptionsView::getEnumInt(
177177
if (Iter == CheckOptions.end())
178178
return llvm::make_error<MissingOptionError>((NamePrefix + LocalName).str());
179179

180-
StringRef Value = Iter->second.Value;
180+
StringRef Value = Iter->getValue().Value;
181181
StringRef Closest;
182182
unsigned EditDistance = -1;
183183
for (const auto &NameAndEnum : Mapping) {
@@ -199,9 +199,9 @@ llvm::Expected<int64_t> ClangTidyCheck::OptionsView::getEnumInt(
199199
}
200200
if (EditDistance < 3)
201201
return llvm::make_error<UnparseableEnumOptionError>(
202-
Iter->first, Iter->second.Value, std::string(Closest));
203-
return llvm::make_error<UnparseableEnumOptionError>(Iter->first,
204-
Iter->second.Value);
202+
Iter->getKey().str(), Iter->getValue().Value, Closest.str());
203+
return llvm::make_error<UnparseableEnumOptionError>(Iter->getKey().str(),
204+
Iter->getValue().Value);
205205
}
206206

207207
void ClangTidyCheck::OptionsView::logErrToStdErr(llvm::Error &&Err) {

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ namespace tidy {
1818

1919
void ClangTidyCheckFactories::registerCheckFactory(StringRef Name,
2020
CheckFactory Factory) {
21-
Factories[std::string(Name)] = std::move(Factory);
21+
Factories.insert_or_assign(Name, std::move(Factory));
2222
}
2323

2424
std::vector<std::unique_ptr<ClangTidyCheck>>
2525
ClangTidyCheckFactories::createChecks(ClangTidyContext *Context) {
2626
std::vector<std::unique_ptr<ClangTidyCheck>> Checks;
2727
for (const auto &Factory : Factories) {
28-
if (Context->isCheckEnabled(Factory.first))
29-
Checks.emplace_back(Factory.second(Factory.first, Context));
28+
if (Context->isCheckEnabled(Factory.getKey()))
29+
Checks.emplace_back(Factory.getValue()(Factory.getKey(), Context));
3030
}
3131
return Checks;
3232
}

clang-tools-extra/clang-tidy/ClangTidyModule.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class ClangTidyCheckFactories {
6969
std::vector<std::unique_ptr<ClangTidyCheck>>
7070
createChecks(ClangTidyContext *Context);
7171

72-
typedef std::map<std::string, CheckFactory> FactoryMap;
72+
typedef llvm::StringMap<CheckFactory> FactoryMap;
7373
FactoryMap::const_iterator begin() const { return Factories.begin(); }
7474
FactoryMap::const_iterator end() const { return Factories.end(); }
7575
bool empty() const { return Factories.empty(); }

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ struct NOptionMap {
7070
NOptionMap(IO &, const ClangTidyOptions::OptionMap &OptionMap) {
7171
Options.reserve(OptionMap.size());
7272
for (const auto &KeyValue : OptionMap)
73-
Options.emplace_back(KeyValue.first, KeyValue.second.Value);
73+
Options.emplace_back(KeyValue.getKey(), KeyValue.getValue().Value);
7474
}
7575
ClangTidyOptions::OptionMap denormalize(IO &) {
7676
ClangTidyOptions::OptionMap Map;
@@ -157,8 +157,10 @@ ClangTidyOptions ClangTidyOptions::mergeWith(const ClangTidyOptions &Other,
157157
mergeVectors(Result.ExtraArgsBefore, Other.ExtraArgsBefore);
158158

159159
for (const auto &KeyValue : Other.CheckOptions) {
160-
Result.CheckOptions[KeyValue.first] = ClangTidyValue(
161-
KeyValue.second.Value, KeyValue.second.Priority + Priority);
160+
Result.CheckOptions.insert_or_assign(
161+
KeyValue.getKey(),
162+
ClangTidyValue(KeyValue.getValue().Value,
163+
KeyValue.getValue().Priority + Priority));
162164
}
163165

164166
return Result;

clang-tools-extra/clang-tidy/ClangTidyOptions.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include "llvm/Support/ErrorOr.h"
1717
#include "llvm/Support/VirtualFileSystem.h"
1818
#include <functional>
19-
#include <map>
2019
#include <string>
2120
#include <system_error>
2221
#include <utility>
@@ -108,7 +107,7 @@ struct ClangTidyOptions {
108107
unsigned Priority;
109108
};
110109
typedef std::pair<std::string, std::string> StringPair;
111-
typedef std::map<std::string, ClangTidyValue> OptionMap;
110+
typedef llvm::StringMap<ClangTidyValue> OptionMap;
112111

113112
/// Key-value mapping used to store check-specific options.
114113
OptionMap CheckOptions;

clang-tools-extra/clangd/FindTarget.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -163,13 +163,12 @@ const Type *getPointeeType(const Type *T) {
163163
}
164164

165165
// Forward declaration, needed as this function is mutually recursive
166-
// with resolveDependentExprToDecls.
167-
const Type *resolveDependentExprToType(const Expr *E);
166+
// with resolveExprToDecls.
167+
const Type *resolveExprToType(const Expr *E);
168168

169-
// Try to heuristically resolve a dependent expression `E` to one
169+
// Try to heuristically resolve a possibly-dependent expression `E` to one
170170
// or more declarations that it likely references.
171-
std::vector<const NamedDecl *> resolveDependentExprToDecls(const Expr *E) {
172-
assert(E->isTypeDependent());
171+
std::vector<const NamedDecl *> resolveExprToDecls(const Expr *E) {
173172
if (const auto *ME = dyn_cast<CXXDependentScopeMemberExpr>(E)) {
174173
const Type *BaseType = ME->getBaseType().getTypePtrOrNull();
175174
if (ME->isArrow()) {
@@ -183,7 +182,7 @@ std::vector<const NamedDecl *> resolveDependentExprToDecls(const Expr *E) {
183182
// can get further by analyzing the depedent expression.
184183
Expr *Base = ME->isImplicitAccess() ? nullptr : ME->getBase();
185184
if (Base && BT->getKind() == BuiltinType::Dependent) {
186-
BaseType = resolveDependentExprToType(Base);
185+
BaseType = resolveExprToType(Base);
187186
}
188187
}
189188
return getMembersReferencedViaDependentName(
@@ -197,7 +196,7 @@ std::vector<const NamedDecl *> resolveDependentExprToDecls(const Expr *E) {
197196
/*IsNonstaticMember=*/false);
198197
}
199198
if (const auto *CE = dyn_cast<CallExpr>(E)) {
200-
const auto *CalleeType = resolveDependentExprToType(CE->getCallee());
199+
const auto *CalleeType = resolveExprToType(CE->getCallee());
201200
if (!CalleeType)
202201
return {};
203202
if (const auto *FnTypePtr = CalleeType->getAs<PointerType>())
@@ -209,15 +208,16 @@ std::vector<const NamedDecl *> resolveDependentExprToDecls(const Expr *E) {
209208
}
210209
}
211210
}
212-
if (const auto *ME = dyn_cast<MemberExpr>(E)) {
211+
if (const auto *ME = dyn_cast<MemberExpr>(E))
213212
return {ME->getMemberDecl()};
214-
}
213+
if (const auto *DRE = dyn_cast<DeclRefExpr>(E))
214+
return {DRE->getFoundDecl()};
215215
return {};
216216
}
217217

218-
// Try to heuristically resolve the type of a dependent expression `E`.
219-
const Type *resolveDependentExprToType(const Expr *E) {
220-
std::vector<const NamedDecl *> Decls = resolveDependentExprToDecls(E);
218+
// Try to heuristically resolve the type of a possibly-dependent expression `E`.
219+
const Type *resolveExprToType(const Expr *E) {
220+
std::vector<const NamedDecl *> Decls = resolveExprToDecls(E);
221221
if (Decls.size() != 1) // Names an overload set -- just bail.
222222
return nullptr;
223223
if (const auto *TD = dyn_cast<TypeDecl>(Decls[0])) {
@@ -426,12 +426,12 @@ struct TargetFinder {
426426
}
427427
void
428428
VisitCXXDependentScopeMemberExpr(const CXXDependentScopeMemberExpr *E) {
429-
for (const NamedDecl *D : resolveDependentExprToDecls(E)) {
429+
for (const NamedDecl *D : resolveExprToDecls(E)) {
430430
Outer.add(D, Flags);
431431
}
432432
}
433433
void VisitDependentScopeDeclRefExpr(const DependentScopeDeclRefExpr *E) {
434-
for (const NamedDecl *D : resolveDependentExprToDecls(E)) {
434+
for (const NamedDecl *D : resolveExprToDecls(E)) {
435435
Outer.add(D, Flags);
436436
}
437437
}

clang-tools-extra/clangd/XRefs.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ const syntax::Token *findNearbyIdentifier(const SpelledWord &Word,
518518
// Find where the word occurred in the token stream, to search forward & back.
519519
auto *I = llvm::partition_point(SpelledTokens, [&](const syntax::Token &T) {
520520
assert(SM.getFileID(T.location()) == SM.getFileID(Word.Location));
521-
return T.location() >= Word.Location; // Comparison OK: same file.
521+
return T.location() < Word.Location; // Comparison OK: same file.
522522
});
523523
// Search for matches after the cursor.
524524
for (const syntax::Token &Tok : llvm::makeArrayRef(I, SpelledTokens.end()))

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,16 @@ class IndexClient : public clangd::SymbolIndex {
9191
return streamRPC(Request, &remote::SymbolIndex::Stub::Refs, Callback);
9292
}
9393

94-
// FIXME(kirillbobyrev): Implement this.
9594
void
96-
relations(const clangd::RelationsRequest &,
97-
llvm::function_ref<void(const SymbolID &, const clangd::Symbol &)>)
98-
const {}
95+
relations(const clangd::RelationsRequest &Request,
96+
llvm::function_ref<void(const SymbolID &, const clangd::Symbol &)>
97+
Callback) const {
98+
streamRPC(Request, &remote::SymbolIndex::Stub::Relations,
99+
// Unpack protobuf Relation.
100+
[&](std::pair<SymbolID, clangd::Symbol> SubjectAndObject) {
101+
Callback(SubjectAndObject.first, SubjectAndObject.second);
102+
});
103+
}
99104

100105
// IndexClient does not take any space since the data is stored on the
101106
// server.

clang-tools-extra/clangd/index/remote/Index.proto

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ service SymbolIndex {
1818
rpc FuzzyFind(FuzzyFindRequest) returns (stream FuzzyFindReply) {}
1919

2020
rpc Refs(RefsRequest) returns (stream RefsReply) {}
21+
22+
rpc Relations(RelationsRequest) returns (stream RelationsReply) {}
2123
}
2224

2325
message LookupRequest { repeated string ids = 1; }
@@ -114,3 +116,25 @@ message HeaderWithReferences {
114116
string header = 1;
115117
uint32 references = 2;
116118
}
119+
120+
message RelationsRequest {
121+
repeated string subjects = 1;
122+
uint32 predicate = 2;
123+
uint32 limit = 3;
124+
}
125+
126+
// The response is a stream of reference messages, and one terminating has_more
127+
// message.
128+
message RelationsReply {
129+
oneof kind {
130+
Relation stream_result = 1;
131+
bool final_result = 2; // HasMore
132+
}
133+
}
134+
135+
// This struct does not mirror clangd::Relation but rather the arguments of
136+
// SymbolIndex::relations callback.
137+
message Relation {
138+
string subject_id = 1;
139+
Symbol object = 2;
140+
}

0 commit comments

Comments
 (0)