Skip to content

Commit 5a64d6b

Browse files
committed
Merge from 'master' to 'sycl-web' (#2)
CONFLICT (content): Merge conflict in README.md
2 parents dc447ec + cbe0ee1 commit 5a64d6b

File tree

570 files changed

+10274
-5549
lines changed

Some content is hidden

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

570 files changed

+10274
-5549
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ template <> struct MappingTraits<FileFilter> {
4747
IO.mapRequired("name", File.Name);
4848
IO.mapOptional("lines", File.LineRanges);
4949
}
50-
static StringRef validate(IO &io, FileFilter &File) {
50+
static std::string validate(IO &io, FileFilter &File) {
5151
if (File.Name.empty())
5252
return "No file name specified";
5353
for (const FileFilter::LineRange &Range : File.LineRanges) {
5454
if (Range.first <= 0 || Range.second <= 0)
5555
return "Invalid line range";
5656
}
57-
return StringRef();
57+
return "";
5858
}
5959
};
6060

clang-tools-extra/clang-tidy/bugprone/DynamicStaticInitializersCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ AST_MATCHER(clang::VarDecl, hasConstantDeclaration) {
2121
if (Init && !Init->isValueDependent()) {
2222
if (Node.isConstexpr())
2323
return true;
24-
return Node.checkInitIsICE();
24+
return Node.evaluateValue();
2525
}
2626
return false;
2727
}

clang-tools-extra/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,23 +85,21 @@ struct DenseMapInfo<
8585
clang::tidy::cppcoreguidelines::SpecialMemberFunctionsCheck::ClassDefId;
8686

8787
static inline ClassDefId getEmptyKey() {
88-
return ClassDefId(
89-
clang::SourceLocation::getFromRawEncoding(static_cast<unsigned>(-1)),
90-
"EMPTY");
88+
return ClassDefId(DenseMapInfo<clang::SourceLocation>::getEmptyKey(),
89+
"EMPTY");
9190
}
9291

9392
static inline ClassDefId getTombstoneKey() {
94-
return ClassDefId(
95-
clang::SourceLocation::getFromRawEncoding(static_cast<unsigned>(-2)),
96-
"TOMBSTONE");
93+
return ClassDefId(DenseMapInfo<clang::SourceLocation>::getTombstoneKey(),
94+
"TOMBSTONE");
9795
}
9896

9997
static unsigned getHashValue(ClassDefId Val) {
10098
assert(Val != getEmptyKey() && "Cannot hash the empty key!");
10199
assert(Val != getTombstoneKey() && "Cannot hash the tombstone key!");
102100

103101
std::hash<ClassDefId::second_type> SecondHash;
104-
return Val.first.getRawEncoding() + SecondHash(Val.second);
102+
return Val.first.getHashValue() + SecondHash(Val.second);
105103
}
106104

107105
static bool isEqual(const ClassDefId &LHS, const ClassDefId &RHS) {

clang-tools-extra/clang-tidy/google/UpgradeGoogletestCaseCheck.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,7 @@ void UpgradeGoogletestCaseCheck::check(const MatchFinder::MatchResult &Result) {
298298
}
299299

300300
if (IsInInstantiation) {
301-
if (MatchedTemplateLocations.count(
302-
ReplacementRange.getBegin().getRawEncoding()) == 0) {
301+
if (MatchedTemplateLocations.count(ReplacementRange.getBegin()) == 0) {
303302
// For each location matched in a template instantiation, we check if
304303
// the location can also be found in `MatchedTemplateLocations`. If it
305304
// is not found, that means the expression did not create a match
@@ -313,8 +312,7 @@ void UpgradeGoogletestCaseCheck::check(const MatchFinder::MatchResult &Result) {
313312
if (IsInTemplate) {
314313
// We gather source locations from template matches not in template
315314
// instantiations for future matches.
316-
MatchedTemplateLocations.insert(
317-
ReplacementRange.getBegin().getRawEncoding());
315+
MatchedTemplateLocations.insert(ReplacementRange.getBegin());
318316
}
319317

320318
if (!AddFix) {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class UpgradeGoogletestCaseCheck : public ClangTidyCheck {
3333
void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
3434

3535
private:
36-
llvm::DenseSet<unsigned> MatchedTemplateLocations;
36+
llvm::DenseSet<SourceLocation> MatchedTemplateLocations;
3737
};
3838

3939
} // namespace google

clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,23 +28,22 @@ struct DenseMapInfo<clang::tidy::RenamerClangTidyCheck::NamingCheckId> {
2828
using NamingCheckId = clang::tidy::RenamerClangTidyCheck::NamingCheckId;
2929

3030
static inline NamingCheckId getEmptyKey() {
31-
return NamingCheckId(
32-
clang::SourceLocation::getFromRawEncoding(static_cast<unsigned>(-1)),
33-
"EMPTY");
31+
return NamingCheckId(DenseMapInfo<clang::SourceLocation>::getEmptyKey(),
32+
"EMPTY");
3433
}
3534

3635
static inline NamingCheckId getTombstoneKey() {
37-
return NamingCheckId(
38-
clang::SourceLocation::getFromRawEncoding(static_cast<unsigned>(-2)),
39-
"TOMBSTONE");
36+
return NamingCheckId(DenseMapInfo<clang::SourceLocation>::getTombstoneKey(),
37+
"TOMBSTONE");
4038
}
4139

4240
static unsigned getHashValue(NamingCheckId Val) {
4341
assert(Val != getEmptyKey() && "Cannot hash the empty key!");
4442
assert(Val != getTombstoneKey() && "Cannot hash the tombstone key!");
4543

4644
std::hash<NamingCheckId::second_type> SecondHash;
47-
return Val.first.getRawEncoding() + SecondHash(Val.second);
45+
return DenseMapInfo<clang::SourceLocation>::getHashValue(Val.first) +
46+
SecondHash(Val.second);
4847
}
4948

5049
static bool isEqual(const NamingCheckId &LHS, const NamingCheckId &RHS) {
@@ -173,8 +172,7 @@ void RenamerClangTidyCheck::addUsage(
173172
// is already in there
174173
RenamerClangTidyCheck::NamingCheckFailure &Failure =
175174
NamingCheckFailures[Decl];
176-
177-
if (!Failure.RawUsageLocs.insert(FixLocation.getRawEncoding()).second)
175+
if (!Failure.RawUsageLocs.insert(FixLocation).second)
178176
return;
179177

180178
if (!Failure.ShouldFix())
@@ -550,9 +548,8 @@ void RenamerClangTidyCheck::onEndOfTranslationUnit() {
550548
//
551549
// Other multi-token identifiers, such as operators are not checked at
552550
// all.
553-
Diag << FixItHint::CreateReplacement(
554-
SourceRange(SourceLocation::getFromRawEncoding(Loc)),
555-
Failure.Info.Fixup);
551+
Diag << FixItHint::CreateReplacement(SourceRange(Loc),
552+
Failure.Info.Fixup);
556553
}
557554
}
558555
}

clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,8 @@ class RenamerClangTidyCheck : public ClangTidyCheck {
9494

9595
ShouldFixStatus FixStatus = ShouldFixStatus::ShouldFix;
9696

97-
/// A set of all the identifier usages starting SourceLocation, in
98-
/// their encoded form.
99-
llvm::DenseSet<unsigned> RawUsageLocs;
97+
/// A set of all the identifier usages starting SourceLocation.
98+
llvm::DenseSet<SourceLocation> RawUsageLocs;
10099

101100
NamingCheckFailure() = default;
102101
};

clang-tools-extra/clangd/FindTarget.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,7 +1014,7 @@ class ExplicitReferenceCollector
10141014
}
10151015

10161016
bool VisitTypeLoc(TypeLoc TTL) {
1017-
if (TypeLocsToSkip.count(TTL.getBeginLoc().getRawEncoding()))
1017+
if (TypeLocsToSkip.count(TTL.getBeginLoc()))
10181018
return true;
10191019
visitNode(DynTypedNode::create(TTL));
10201020
return true;
@@ -1024,7 +1024,7 @@ class ExplicitReferenceCollector
10241024
// ElaboratedTypeLoc will reports information for its inner type loc.
10251025
// Otherwise we loose information about inner types loc's qualifier.
10261026
TypeLoc Inner = L.getNamedTypeLoc().getUnqualifiedLoc();
1027-
TypeLocsToSkip.insert(Inner.getBeginLoc().getRawEncoding());
1027+
TypeLocsToSkip.insert(Inner.getBeginLoc());
10281028
return RecursiveASTVisitor::TraverseElaboratedTypeLoc(L);
10291029
}
10301030

@@ -1090,7 +1090,7 @@ class ExplicitReferenceCollector
10901090
visitNode(DynTypedNode::create(L));
10911091
// Inner type is missing information about its qualifier, skip it.
10921092
if (auto TL = L.getTypeLoc())
1093-
TypeLocsToSkip.insert(TL.getBeginLoc().getRawEncoding());
1093+
TypeLocsToSkip.insert(TL.getBeginLoc());
10941094
return RecursiveASTVisitor::TraverseNestedNameSpecifierLoc(L);
10951095
}
10961096

@@ -1163,7 +1163,7 @@ class ExplicitReferenceCollector
11631163
llvm::function_ref<void(ReferenceLoc)> Out;
11641164
/// TypeLocs starting at these locations must be skipped, see
11651165
/// TraverseElaboratedTypeSpecifierLoc for details.
1166-
llvm::DenseSet</*SourceLocation*/ unsigned> TypeLocsToSkip;
1166+
llvm::DenseSet<SourceLocation> TypeLocsToSkip;
11671167
};
11681168
} // namespace
11691169

clang-tools-extra/clangd/Format.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ void closeBrackets(std::string &Code, const format::FormatStyle &Style) {
2626
SourceManagerForFile FileSM("dummy.cpp", Code);
2727
auto &SM = FileSM.get();
2828
FileID FID = SM.getMainFileID();
29-
Lexer Lex(FID, SM.getBuffer(FID), SM, format::getFormattingLangOpts(Style));
29+
Lexer Lex(FID, SM.getBufferOrFake(FID), SM,
30+
format::getFormattingLangOpts(Style));
3031
Token Tok;
3132
std::vector<char> Brackets;
3233
while (!Lex.LexFromRawLexer(Tok)) {

clang-tools-extra/clangd/Protocol.cpp

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,12 @@ bool fromJSON(const llvm::json::Value &E, TraceLevel &Out, llvm::json::Path P) {
179179
if (*S == "off") {
180180
Out = TraceLevel::Off;
181181
return true;
182-
} else if (*S == "messages") {
182+
}
183+
if (*S == "messages") {
183184
Out = TraceLevel::Messages;
184185
return true;
185-
} else if (*S == "verbose") {
186+
}
187+
if (*S == "verbose") {
186188
Out = TraceLevel::Verbose;
187189
return true;
188190
}
@@ -319,7 +321,8 @@ bool fromJSON(const llvm::json::Value &Params, ClientCapabilities &R,
319321
if (auto *Item = Completion->getObject("completionItem")) {
320322
if (auto SnippetSupport = Item->getBoolean("snippetSupport"))
321323
R.CompletionSnippets = *SnippetSupport;
322-
if (auto DocumentationFormat = Item->getArray("documentationFormat")) {
324+
if (const auto *DocumentationFormat =
325+
Item->getArray("documentationFormat")) {
323326
for (const auto &Format : *DocumentationFormat) {
324327
if (fromJSON(Format, R.CompletionDocumentationFormat, P))
325328
break;
@@ -645,7 +648,7 @@ bool fromJSON(const llvm::json::Value &Params, ExecuteCommandParams &R,
645648
if (!O || !O.map("command", R.command))
646649
return false;
647650

648-
auto Args = Params.getAsObject()->getArray("arguments");
651+
const auto *Args = Params.getAsObject()->getArray("arguments");
649652
if (R.command == ExecuteCommandParams::CLANGD_APPLY_FIX_COMMAND) {
650653
return Args && Args->size() == 1 &&
651654
fromJSON(Args->front(), R.workspaceEdit,

clang-tools-extra/clangd/Selection.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,10 @@ class SelectionVisitor : public RecursiveASTVisitor<SelectionVisitor> {
605605
bool canSafelySkipNode(const DynTypedNode &N) {
606606
SourceRange S = N.getSourceRange();
607607
if (auto *TL = N.get<TypeLoc>()) {
608+
// FIXME: TypeLoc::getBeginLoc()/getEndLoc() are pretty fragile
609+
// heuristics. We should consider only pruning critical TypeLoc nodes, to
610+
// be more robust.
611+
608612
// DeclTypeTypeLoc::getSourceRange() is incomplete, which would lead to
609613
// failing
610614
// to descend into the child expression.
@@ -616,6 +620,10 @@ class SelectionVisitor : public RecursiveASTVisitor<SelectionVisitor> {
616620
// rid of this patch.
617621
if (auto DT = TL->getAs<DecltypeTypeLoc>())
618622
S.setEnd(DT.getUnderlyingExpr()->getEndLoc());
623+
// AttributedTypeLoc may point to the attribute's range, NOT the modified
624+
// type's range.
625+
if (auto AT = TL->getAs<AttributedTypeLoc>())
626+
S = AT.getModifiedLoc().getSourceRange();
619627
}
620628
if (!SelChecker.mayHit(S)) {
621629
dlog("{1}skip: {0}", printNodeToString(N, PrintPolicy), indent());

clang-tools-extra/clangd/index/remote/marshalling/Marshalling.cpp

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -50,20 +50,23 @@ llvm::Expected<llvm::DenseSet<SymbolID>> getIDs(IDRange IDs) {
5050
Marshaller::Marshaller(llvm::StringRef RemoteIndexRoot,
5151
llvm::StringRef LocalIndexRoot)
5252
: Strings(Arena) {
53+
llvm::StringRef PosixSeparator =
54+
llvm::sys::path::get_separator(llvm::sys::path::Style::posix);
5355
if (!RemoteIndexRoot.empty()) {
5456
assert(llvm::sys::path::is_absolute(RemoteIndexRoot));
55-
assert(RemoteIndexRoot ==
56-
llvm::sys::path::convert_to_slash(RemoteIndexRoot));
57-
this->RemoteIndexRoot = RemoteIndexRoot.str();
58-
if (!RemoteIndexRoot.endswith(llvm::sys::path::get_separator()))
59-
*this->RemoteIndexRoot += llvm::sys::path::get_separator();
57+
this->RemoteIndexRoot = llvm::sys::path::convert_to_slash(
58+
RemoteIndexRoot, llvm::sys::path::Style::windows);
59+
llvm::StringRef Path(*this->RemoteIndexRoot);
60+
if (!Path.endswith(PosixSeparator))
61+
*this->RemoteIndexRoot += PosixSeparator;
6062
}
6163
if (!LocalIndexRoot.empty()) {
6264
assert(llvm::sys::path::is_absolute(LocalIndexRoot));
63-
assert(LocalIndexRoot == llvm::sys::path::convert_to_slash(LocalIndexRoot));
64-
this->LocalIndexRoot = LocalIndexRoot.str();
65-
if (!LocalIndexRoot.endswith(llvm::sys::path::get_separator()))
66-
*this->LocalIndexRoot += llvm::sys::path::get_separator();
65+
this->LocalIndexRoot = llvm::sys::path::convert_to_slash(
66+
LocalIndexRoot, llvm::sys::path::Style::windows);
67+
llvm::StringRef Path(*this->LocalIndexRoot);
68+
if (!Path.endswith(PosixSeparator))
69+
*this->LocalIndexRoot += PosixSeparator;
6770
}
6871
assert(!RemoteIndexRoot.empty() || !LocalIndexRoot.empty());
6972
}
@@ -92,6 +95,9 @@ Marshaller::fromProtobuf(const FuzzyFindRequest *Message) {
9295
for (const auto &Path : Message->proximity_paths()) {
9396
llvm::SmallString<256> LocalPath = llvm::StringRef(*RemoteIndexRoot);
9497
llvm::sys::path::append(LocalPath, Path);
98+
// FuzzyFindRequest requires proximity paths to have platform-native format
99+
// in order for SymbolIndex to process the query correctly.
100+
llvm::sys::path::native(LocalPath);
95101
Result.ProximityPaths.push_back(std::string(LocalPath));
96102
}
97103
for (const auto &Type : Message->preferred_types())
@@ -209,7 +215,7 @@ FuzzyFindRequest Marshaller::toProtobuf(const clangd::FuzzyFindRequest &From) {
209215
llvm::SmallString<256> RelativePath = llvm::StringRef(Path);
210216
if (llvm::sys::path::replace_path_prefix(RelativePath, *LocalIndexRoot, ""))
211217
RPCRequest.add_proximity_paths(llvm::sys::path::convert_to_slash(
212-
RelativePath, llvm::sys::path::Style::posix));
218+
RelativePath, llvm::sys::path::Style::windows));
213219
}
214220
for (const auto &Type : From.PreferredTypes)
215221
RPCRequest.add_preferred_types(Type);
@@ -315,12 +321,17 @@ llvm::Expected<std::string> Marshaller::uriToRelativePath(llvm::StringRef URI) {
315321
if (ParsedURI->scheme() != "file")
316322
return error("Can not use URI schemes other than file, given: '{0}'.", URI);
317323
llvm::SmallString<256> Result = ParsedURI->body();
324+
llvm::StringRef Path(Result);
325+
// Check for Windows paths (URI=file:///X:/path => Body=/X:/path)
326+
if (llvm::sys::path::is_absolute(Path.substr(1),
327+
llvm::sys::path::Style::windows))
328+
Result = Path.drop_front();
318329
if (!llvm::sys::path::replace_path_prefix(Result, *RemoteIndexRoot, ""))
319330
return error("File path '{0}' doesn't start with '{1}'.", Result.str(),
320331
*RemoteIndexRoot);
321-
// Make sure the result has UNIX slashes.
322-
return llvm::sys::path::convert_to_slash(Result,
323-
llvm::sys::path::Style::posix);
332+
assert(Result == llvm::sys::path::convert_to_slash(
333+
Result, llvm::sys::path::Style::windows));
334+
return std::string(Result);
324335
}
325336

326337
clangd::SymbolLocation::Position

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,24 @@ TEST_F(TargetDeclTest, ObjC) {
831831
EXPECT_DECLS("ObjCPropertyRefExpr",
832832
"@property(atomic, retain, readwrite) I *x");
833833

834+
Code = R"cpp(
835+
@interface MYObject
836+
@end
837+
@interface Interface
838+
@property(retain) [[MYObject]] *x;
839+
@end
840+
)cpp";
841+
EXPECT_DECLS("ObjCInterfaceTypeLoc", "@interface MYObject");
842+
843+
Code = R"cpp(
844+
@interface MYObject2
845+
@end
846+
@interface Interface
847+
@property(retain, nonnull) [[MYObject2]] *x;
848+
@end
849+
)cpp";
850+
EXPECT_DECLS("ObjCInterfaceTypeLoc", "@interface MYObject2");
851+
834852
Code = R"cpp(
835853
@protocol Foo
836854
@end

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1991,6 +1991,34 @@ TEST(Hover, All) {
19911991
HI.NamespaceScope = "ObjC::"; // FIXME: fix it
19921992
HI.Definition = "char data";
19931993
}},
1994+
{
1995+
R"cpp(
1996+
@interface MYObject
1997+
@end
1998+
@interface Interface
1999+
@property(retain) [[MYOb^ject]] *x;
2000+
@end
2001+
)cpp",
2002+
[](HoverInfo &HI) {
2003+
HI.Name = "MYObject";
2004+
HI.Kind = index::SymbolKind::Class;
2005+
HI.NamespaceScope = "";
2006+
HI.Definition = "@interface MYObject\n@end";
2007+
}},
2008+
{
2009+
R"cpp(
2010+
@interface MYObject
2011+
@end
2012+
@interface Interface
2013+
- (void)doWith:([[MYOb^ject]] *)object;
2014+
@end
2015+
)cpp",
2016+
[](HoverInfo &HI) {
2017+
HI.Name = "MYObject";
2018+
HI.Kind = index::SymbolKind::Class;
2019+
HI.NamespaceScope = "";
2020+
HI.Definition = "@interface MYObject\n@end";
2021+
}},
19942022
};
19952023

19962024
// Create a tiny index, so tests above can verify documentation is fetched.

0 commit comments

Comments
 (0)