Skip to content

Commit 1dd9d9b

Browse files
author
iclsrc
committed
Merge from 'sycl' to 'sycl-web'
2 parents d06f631 + 7863c0b commit 1dd9d9b

File tree

2,763 files changed

+121808
-32640
lines changed

Some content is hidden

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

2,763 files changed

+121808
-32640
lines changed

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

+10-3
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,19 @@ void ClangTidyCheck::OptionsView::store(ClangTidyOptions::OptionMap &Options,
155155
Options[NamePrefix + LocalName.str()] = Value;
156156
}
157157

158-
void ClangTidyCheck::OptionsView::store(ClangTidyOptions::OptionMap &Options,
159-
StringRef LocalName,
160-
int64_t Value) const {
158+
void ClangTidyCheck::OptionsView::storeInt(ClangTidyOptions::OptionMap &Options,
159+
StringRef LocalName,
160+
int64_t Value) const {
161161
store(Options, LocalName, llvm::itostr(Value));
162162
}
163163

164+
template <>
165+
void ClangTidyCheck::OptionsView::store<bool>(
166+
ClangTidyOptions::OptionMap &Options, StringRef LocalName,
167+
bool Value) const {
168+
store(Options, LocalName, Value ? StringRef("true") : StringRef("false"));
169+
}
170+
164171
llvm::Expected<int64_t>
165172
ClangTidyCheck::OptionsView::getEnumInt(StringRef LocalName,
166173
ArrayRef<NameAndValue> Mapping,

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

+17-3
Original file line numberDiff line numberDiff line change
@@ -405,9 +405,13 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback {
405405
StringRef Value) const;
406406

407407
/// Stores an option with the check-local name \p LocalName with
408-
/// ``int64_t`` value \p Value to \p Options.
409-
void store(ClangTidyOptions::OptionMap &Options, StringRef LocalName,
410-
int64_t Value) const;
408+
/// integer value \p Value to \p Options.
409+
template <typename T>
410+
std::enable_if_t<std::is_integral<T>::value>
411+
store(ClangTidyOptions::OptionMap &Options, StringRef LocalName,
412+
T Value) const {
413+
storeInt(Options, LocalName, Value);
414+
}
411415

412416
/// Stores an option with the check-local name \p LocalName as the string
413417
/// representation of the Enum \p Value to \p Options.
@@ -448,6 +452,9 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback {
448452
return Result;
449453
}
450454

455+
void storeInt(ClangTidyOptions::OptionMap &Options, StringRef LocalName,
456+
int64_t Value) const;
457+
451458
static void logErrToStdErr(llvm::Error &&Err);
452459

453460
std::string NamePrefix;
@@ -509,6 +516,13 @@ template <>
509516
bool ClangTidyCheck::OptionsView::getLocalOrGlobal<bool>(StringRef LocalName,
510517
bool Default) const;
511518

519+
/// Stores an option with the check-local name \p LocalName with
520+
/// bool value \p Value to \p Options.
521+
template <>
522+
void ClangTidyCheck::OptionsView::store<bool>(
523+
ClangTidyOptions::OptionMap &Options, StringRef LocalName,
524+
bool Value) const;
525+
512526
} // namespace tidy
513527
} // namespace clang
514528

clang-tools-extra/clangd/CMakeLists.txt

+5
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,13 @@ set(LLVM_LINK_COMPONENTS
2525
Support
2626
AllTargetsInfos
2727
FrontendOpenMP
28+
Option
2829
)
2930

31+
if(MSVC AND NOT CLANG_CL)
32+
set_source_files_properties(CompileCommands.cpp PROPERTIES COMPILE_FLAGS -wd4130) # disables C4130: logical operation on address of string constant
33+
endif()
34+
3035
add_clang_library(clangDaemon
3136
AST.cpp
3237
ClangdLSPServer.cpp

clang-tools-extra/clangd/ClangdLSPServer.cpp

+10-1
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,8 @@ void ClangdLSPServer::onInitialize(const InitializeParams &Params,
637637
->insert(
638638
{"semanticHighlighting",
639639
llvm::json::Object{{"scopes", buildHighlightScopeLookupTable()}}});
640+
if (ClangdServerOpts.FoldingRanges)
641+
Result.getObject("capabilities")->insert({"foldingRangeProvider", true});
640642
Reply(std::move(Result));
641643
}
642644

@@ -929,7 +931,6 @@ void ClangdLSPServer::onDocumentFormatting(
929931
static std::vector<SymbolInformation>
930932
flattenSymbolHierarchy(llvm::ArrayRef<DocumentSymbol> Symbols,
931933
const URIForFile &FileURI) {
932-
933934
std::vector<SymbolInformation> Results;
934935
std::function<void(const DocumentSymbol &, llvm::StringRef)> Process =
935936
[&](const DocumentSymbol &S, llvm::Optional<llvm::StringRef> ParentName) {
@@ -968,6 +969,12 @@ void ClangdLSPServer::onDocumentSymbol(const DocumentSymbolParams &Params,
968969
});
969970
}
970971

972+
void ClangdLSPServer::onFoldingRange(
973+
const FoldingRangeParams &Params,
974+
Callback<std::vector<FoldingRange>> Reply) {
975+
Server->foldingRanges(Params.textDocument.uri.file(), std::move(Reply));
976+
}
977+
971978
static llvm::Optional<Command> asCommand(const CodeAction &Action) {
972979
Command Cmd;
973980
if (Action.command && Action.edit)
@@ -1395,6 +1402,8 @@ ClangdLSPServer::ClangdLSPServer(
13951402
MsgHandler->bind("textDocument/documentLink", &ClangdLSPServer::onDocumentLink);
13961403
MsgHandler->bind("textDocument/semanticTokens/full", &ClangdLSPServer::onSemanticTokens);
13971404
MsgHandler->bind("textDocument/semanticTokens/full/delta", &ClangdLSPServer::onSemanticTokensDelta);
1405+
if (Opts.FoldingRanges)
1406+
MsgHandler->bind("textDocument/foldingRange", &ClangdLSPServer::onFoldingRange);
13981407
// clang-format on
13991408
}
14001409

clang-tools-extra/clangd/ClangdLSPServer.h

+2
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,8 @@ class ClangdLSPServer : private ClangdServer::Callbacks {
8787
// otherwise.
8888
void onDocumentSymbol(const DocumentSymbolParams &,
8989
Callback<llvm::json::Value>);
90+
void onFoldingRange(const FoldingRangeParams &,
91+
Callback<std::vector<FoldingRange>>);
9092
void onCodeAction(const CodeActionParams &, Callback<llvm::json::Value>);
9193
void onCompletion(const CompletionParams &, Callback<CompletionList>);
9294
void onSignatureHelp(const TextDocumentPositionParams &,

clang-tools-extra/clangd/ClangdServer.cpp

+16
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
#include "llvm/Support/ScopedPrinter.h"
4949
#include "llvm/Support/raw_ostream.h"
5050
#include <algorithm>
51+
#include <chrono>
5152
#include <future>
5253
#include <memory>
5354
#include <mutex>
@@ -674,6 +675,18 @@ void ClangdServer::documentSymbols(llvm::StringRef File,
674675
TUScheduler::InvalidateOnUpdate);
675676
}
676677

678+
void ClangdServer::foldingRanges(llvm::StringRef File,
679+
Callback<std::vector<FoldingRange>> CB) {
680+
auto Action =
681+
[CB = std::move(CB)](llvm::Expected<InputsAndAST> InpAST) mutable {
682+
if (!InpAST)
683+
return CB(InpAST.takeError());
684+
CB(clangd::getFoldingRanges(InpAST->AST));
685+
};
686+
WorkScheduler.runWithAST("foldingRanges", File, std::move(Action),
687+
TUScheduler::InvalidateOnUpdate);
688+
}
689+
677690
void ClangdServer::findReferences(PathRef File, Position Pos, uint32_t Limit,
678691
Callback<ReferencesResult> CB) {
679692
auto Action = [Pos, Limit, CB = std::move(CB),
@@ -750,6 +763,9 @@ Context ClangdServer::createProcessingContext(PathRef File) const {
750763
return Context::current().clone();
751764

752765
config::Params Params;
766+
// Don't reread config files excessively often.
767+
// FIXME: when we see a config file change event, use the event timestamp.
768+
Params.FreshTime = std::chrono::steady_clock::now() - std::chrono::seconds(5);
753769
llvm::SmallString<256> PosixPath;
754770
if (!File.empty()) {
755771
assert(llvm::sys::path::is_absolute(File));

clang-tools-extra/clangd/ClangdServer.h

+6
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,9 @@ class ClangdServer {
157157
/// Enable notification-based semantic highlighting.
158158
bool TheiaSemanticHighlighting = false;
159159

160+
/// Enable preview of FoldingRanges feature.
161+
bool FoldingRanges = false;
162+
160163
/// Returns true if the tweak should be enabled.
161164
std::function<bool(const Tweak &)> TweakFilter = [](const Tweak &T) {
162165
return !T.hidden(); // only enable non-hidden tweaks.
@@ -246,6 +249,9 @@ class ClangdServer {
246249
void documentSymbols(StringRef File,
247250
Callback<std::vector<DocumentSymbol>> CB);
248251

252+
/// Retrieve ranges that can be used to fold code within the specified file.
253+
void foldingRanges(StringRef File, Callback<std::vector<FoldingRange>> CB);
254+
249255
/// Retrieve locations for symbol references.
250256
void findReferences(PathRef File, Position Pos, uint32_t Limit,
251257
Callback<ReferencesResult> CB);

0 commit comments

Comments
 (0)