Skip to content

Commit b2d2750

Browse files
committed
Merge from 'master' to 'sycl-web' (#1)
2 parents dd3c846 + f9e6d1e commit b2d2750

File tree

1,189 files changed

+35965
-17395
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,189 files changed

+35965
-17395
lines changed

.git-blame-ignore-revs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,6 @@ d8f0e6caa91e230a486c948ab643174e40bdf215
3131

3232
# Remove line-endings added by r320089. NFC.
3333
100a0eedc00b2bf48bcdc6c209c000745a4a0e48
34+
35+
# Cleanup __config indention. NFC.
36+
2b772b930e097ed6f06d698a51e291c7fd318baa

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ void MisplacedPointerArithmeticInAllocCheck::check(
7777
CallName = "operator new[]";
7878
} else {
7979
const auto *CtrE = New->getConstructExpr();
80-
if (!CtrE->getArg(CtrE->getNumArgs() - 1)
81-
->getType()
82-
->isIntegralOrEnumerationType())
80+
if (!CtrE || !CtrE->getArg(CtrE->getNumArgs() - 1)
81+
->getType()
82+
->isIntegralOrEnumerationType())
8383
return;
8484
CallName = "operator new";
8585
}

clang-tools-extra/clang-tidy/modernize/UseEqualsDeleteCheck.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@ void UseEqualsDeleteCheck::registerMatchers(MatchFinder *Finder) {
3636
Finder->addMatcher(
3737
cxxMethodDecl(
3838
PrivateSpecialFn,
39-
unless(anyOf(hasBody(stmt()), isDefaulted(), isDeleted(),
39+
unless(anyOf(hasAnyBody(stmt()), isDefaulted(), isDeleted(),
4040
ast_matchers::isTemplateInstantiation(),
4141
// Ensure that all methods except private special member
4242
// functions are defined.
4343
hasParent(cxxRecordDecl(hasMethod(unless(
44-
anyOf(PrivateSpecialFn, hasBody(stmt()), isPure(),
44+
anyOf(PrivateSpecialFn, hasAnyBody(stmt()), isPure(),
4545
isDefaulted(), isDeleted()))))))))
4646
.bind(SpecialFunction),
4747
this);

clang-tools-extra/clang-tidy/modernize/UseNoexceptCheck.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,16 @@ void UseNoexceptCheck::check(const MatchFinder::MatchResult &Result) {
7777
.getExceptionSpecRange();
7878
}
7979

80+
assert(FnTy && "FunctionProtoType is null.");
81+
if (isUnresolvedExceptionSpec(FnTy->getExceptionSpecType()))
82+
return;
83+
8084
assert(Range.isValid() && "Exception Source Range is invalid.");
8185

8286
CharSourceRange CRange = Lexer::makeFileCharRange(
8387
CharSourceRange::getTokenRange(Range), *Result.SourceManager,
8488
Result.Context->getLangOpts());
8589

86-
assert(FnTy && "FunctionProtoType is null.");
8790
bool IsNoThrow = FnTy->isNothrow();
8891
StringRef ReplacementStr =
8992
IsNoThrow

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ void UnnecessaryCopyInitialization::registerMatchers(MatchFinder *Finder) {
5454
on(declRefExpr(to(varDecl().bind("objectArg")))));
5555
auto ConstRefReturningFunctionCall =
5656
callExpr(callee(functionDecl(returns(ConstReference))),
57-
unless(callee(cxxMethodDecl())));
57+
unless(callee(cxxMethodDecl())))
58+
.bind("initFunctionCall");
5859

5960
auto localVarCopiedFrom = [this](const internal::Matcher<Expr> &CopyCtorArg) {
6061
return compoundStmt(
@@ -96,6 +97,8 @@ void UnnecessaryCopyInitialization::check(
9697
const auto *ObjectArg = Result.Nodes.getNodeAs<VarDecl>("objectArg");
9798
const auto *BlockStmt = Result.Nodes.getNodeAs<Stmt>("blockStmt");
9899
const auto *CtorCall = Result.Nodes.getNodeAs<CXXConstructExpr>("ctorCall");
100+
const auto *InitFunctionCall =
101+
Result.Nodes.getNodeAs<CallExpr>("initFunctionCall");
99102

100103
TraversalKindScope RAII(*Result.Context, ast_type_traits::TK_AsIs);
101104

@@ -113,6 +116,11 @@ void UnnecessaryCopyInitialization::check(
113116
return;
114117

115118
if (OldVar == nullptr) {
119+
// Only allow initialization of a const reference from a free function if it
120+
// has no arguments. Otherwise it could return an alias to one of its
121+
// arguments and the arguments need to be checked for const use as well.
122+
if (InitFunctionCall != nullptr && InitFunctionCall->getNumArgs() > 0)
123+
return;
116124
handleCopyFromMethodReturn(*NewVar, *BlockStmt, IssueFix, ObjectArg,
117125
*Result.Context);
118126
} else {

clang-tools-extra/clangd/ClangdLSPServer.cpp

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -147,13 +147,9 @@ llvm::Error validateEdits(const DraftStore &DraftMgr, const FileEdits &FE) {
147147
if (!InvalidFileCount)
148148
return llvm::Error::success();
149149
if (InvalidFileCount == 1)
150-
return llvm::createStringError(llvm::inconvertibleErrorCode(),
151-
"File must be saved first: " +
152-
LastInvalidFile);
153-
return llvm::createStringError(
154-
llvm::inconvertibleErrorCode(),
155-
"Files must be saved first: " + LastInvalidFile + " (and " +
156-
llvm::to_string(InvalidFileCount - 1) + " others)");
150+
return error("File must be saved first: {0}", LastInvalidFile);
151+
return error("Files must be saved first: {0} (and {1} others)",
152+
LastInvalidFile, InvalidFileCount - 1);
157153
}
158154

159155
} // namespace
@@ -284,10 +280,9 @@ class ClangdLSPServer::MessageHandler : public Transport::MessageHandler {
284280
}
285281
}
286282
if (OldestCB)
287-
OldestCB->second(llvm::createStringError(
288-
llvm::inconvertibleErrorCode(),
289-
llvm::formatv("failed to receive a client reply for request ({0})",
290-
OldestCB->first)));
283+
OldestCB->second(
284+
error("failed to receive a client reply for request ({0})",
285+
OldestCB->first));
291286
return ID;
292287
}
293288

@@ -661,8 +656,7 @@ void ClangdLSPServer::onSync(const NoParams &Params,
661656
if (Server->blockUntilIdleForTest(/*TimeoutSeconds=*/60))
662657
Reply(nullptr);
663658
else
664-
Reply(llvm::createStringError(llvm::inconvertibleErrorCode(),
665-
"Not idle after a minute"));
659+
Reply(error("Not idle after a minute"));
666660
}
667661

668662
void ClangdLSPServer::onDocumentDidOpen(
@@ -729,9 +723,7 @@ void ClangdLSPServer::onCommand(const ExecuteCommandParams &Params,
729723
std::string Reason = Response->failureReason
730724
? *Response->failureReason
731725
: "unknown reason";
732-
return Reply(llvm::createStringError(
733-
llvm::inconvertibleErrorCode(),
734-
("edits were not applied: " + Reason).c_str()));
726+
return Reply(error("edits were not applied: {0}", Reason));
735727
}
736728
return Reply(SuccessMessage);
737729
});
@@ -752,9 +744,7 @@ void ClangdLSPServer::onCommand(const ExecuteCommandParams &Params,
752744
Params.tweakArgs) {
753745
auto Code = DraftMgr.getDraft(Params.tweakArgs->file.file());
754746
if (!Code)
755-
return Reply(llvm::createStringError(
756-
llvm::inconvertibleErrorCode(),
757-
"trying to apply a code action for a non-added file"));
747+
return Reply(error("trying to apply a code action for a non-added file"));
758748

759749
auto Action = [this, ApplyEdit, Reply = std::move(Reply),
760750
File = Params.tweakArgs->file, Code = std::move(*Code)](

clang-tools-extra/clangd/ClangdServer.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,8 +342,7 @@ void ClangdServer::signatureHelp(PathRef File, Position Pos,
342342

343343
const auto *PreambleData = IP->Preamble;
344344
if (!PreambleData)
345-
return CB(llvm::createStringError(llvm::inconvertibleErrorCode(),
346-
"Failed to parse includes"));
345+
return CB(error("Failed to parse includes"));
347346

348347
ParseInputs ParseInput{IP->Command, &TFS, IP->Contents.str()};
349348
ParseInput.Index = Index;
@@ -537,9 +536,12 @@ void ClangdServer::enumerateTweaks(PathRef File, Range Sel,
537536

538537
void ClangdServer::applyTweak(PathRef File, Range Sel, StringRef TweakID,
539538
Callback<Tweak::Effect> CB) {
540-
// Tracks number of times a tweak has been applied.
539+
// Tracks number of times a tweak has been attempted.
541540
static constexpr trace::Metric TweakAttempt(
542541
"tweak_attempt", trace::Metric::Counter, "tweak_id");
542+
// Tracks number of times a tweak has failed to produce edits.
543+
static constexpr trace::Metric TweakFailed(
544+
"tweak_failed", trace::Metric::Counter, "tweak_id");
543545
TweakAttempt.record(1, TweakID);
544546
auto Action = [File = File.str(), Sel, TweakID = TweakID.str(),
545547
CB = std::move(CB),
@@ -570,6 +572,8 @@ void ClangdServer::applyTweak(PathRef File, Range Sel, StringRef TweakID,
570572
if (llvm::Error Err = reformatEdit(E, Style))
571573
elog("Failed to format {0}: {1}", It.first(), std::move(Err));
572574
}
575+
} else {
576+
TweakFailed.record(1, TweakID);
573577
}
574578
return CB(std::move(*Effect));
575579
};

clang-tools-extra/clangd/CodeComplete.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,7 @@ struct CodeCompletionBuilder {
333333
return ResolvedInserted.takeError();
334334
auto Spelled = Includes.calculateIncludePath(*ResolvedInserted, FileName);
335335
if (!Spelled)
336-
return llvm::createStringError(llvm::inconvertibleErrorCode(),
337-
"Header not on include path");
336+
return error("Header not on include path");
338337
return std::make_pair(
339338
std::move(*Spelled),
340339
Includes.shouldInsertInclude(*ResolvedDeclaring, *ResolvedInserted));

clang-tools-extra/clangd/ConfigYAML.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class Parser {
3838
DictParser Dict("Config", this);
3939
Dict.handle("If", [&](Node &N) { parse(F.If, N); });
4040
Dict.handle("CompileFlags", [&](Node &N) { parse(F.CompileFlags, N); });
41+
Dict.handle("Index", [&](Node &N) { parse(F.Index, N); });
4142
Dict.parse(N);
4243
return !(N.failed() || HadError);
4344
}

clang-tools-extra/clangd/DraftStore.cpp

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ llvm::Expected<DraftStore::Draft> DraftStore::updateDraft(
6464

6565
auto EntryIt = Drafts.find(File);
6666
if (EntryIt == Drafts.end()) {
67-
return llvm::make_error<llvm::StringError>(
68-
"Trying to do incremental update on non-added document: " + File,
69-
llvm::errc::invalid_argument);
67+
return error(llvm::errc::invalid_argument,
68+
"Trying to do incremental update on non-added document: {0}",
69+
File);
7070
}
7171
Draft &D = EntryIt->second;
7272
std::string Contents = EntryIt->second.Contents;
@@ -89,11 +89,9 @@ llvm::Expected<DraftStore::Draft> DraftStore::updateDraft(
8989
return EndIndex.takeError();
9090

9191
if (*EndIndex < *StartIndex)
92-
return llvm::make_error<llvm::StringError>(
93-
llvm::formatv(
94-
"Range's end position ({0}) is before start position ({1})", End,
95-
Start),
96-
llvm::errc::invalid_argument);
92+
return error(llvm::errc::invalid_argument,
93+
"Range's end position ({0}) is before start position ({1})",
94+
End, Start);
9795

9896
// Since the range length between two LSP positions is dependent on the
9997
// contents of the buffer we compute the range length between the start and
@@ -106,11 +104,10 @@ llvm::Expected<DraftStore::Draft> DraftStore::updateDraft(
106104
lspLength(Contents.substr(*StartIndex, *EndIndex - *StartIndex));
107105

108106
if (Change.rangeLength && ComputedRangeLength != *Change.rangeLength)
109-
return llvm::make_error<llvm::StringError>(
110-
llvm::formatv("Change's rangeLength ({0}) doesn't match the "
111-
"computed range length ({1}).",
112-
*Change.rangeLength, ComputedRangeLength),
113-
llvm::errc::invalid_argument);
107+
return error(llvm::errc::invalid_argument,
108+
"Change's rangeLength ({0}) doesn't match the "
109+
"computed range length ({1}).",
110+
*Change.rangeLength, ComputedRangeLength);
114111

115112
std::string NewContents;
116113
NewContents.reserve(*StartIndex + Change.text.length() +

0 commit comments

Comments
 (0)