Skip to content

Commit dee2ee9

Browse files
committed
Merge from 'master' to 'sycl-web' (#2)
CONFLICT (content): Merge conflict in clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
2 parents f1acb4a + 98f76ad commit dee2ee9

File tree

1,377 files changed

+114055
-27033
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,377 files changed

+114055
-27033
lines changed

.github/workflows/main-branch-sync.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: main branch sync
33
on:
44
push:
55
branches:
6-
- 'master'
6+
- 'main'
77

88
jobs:
99
branch_sync:
@@ -22,4 +22,4 @@ jobs:
2222
env:
2323
LLVMBOT_TOKEN: ${{ secrets.LLVMBOT_MAIN_SYNC }}
2424
run: |
25-
git push https://$LLVMBOT_TOKEN@github.com/${{ github.repository }} HEAD:main
25+
git push https://$LLVMBOT_TOKEN@github.com/${{ github.repository }} HEAD:master

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

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,22 @@ char UnparseableEnumOptionError::ID;
2121
char UnparseableIntegerOptionError::ID;
2222

2323
std::string MissingOptionError::message() const {
24-
llvm::SmallString<128> Buffer;
25-
llvm::raw_svector_ostream Output(Buffer);
26-
Output << "option not found '" << OptionName << '\'';
24+
llvm::SmallString<128> Buffer({"option not found '", OptionName, "'"});
2725
return std::string(Buffer);
2826
}
2927

3028
std::string UnparseableEnumOptionError::message() const {
31-
llvm::SmallString<128> Buffer;
32-
llvm::raw_svector_ostream Output(Buffer);
33-
Output << "invalid configuration value '" << LookupValue << "' for option '"
34-
<< LookupName << '\'';
29+
llvm::SmallString<256> Buffer({"invalid configuration value '", LookupValue,
30+
"' for option '", LookupName, "'"});
3531
if (SuggestedValue)
36-
Output << "; did you mean '" << *SuggestedValue << "'?";
32+
Buffer.append({"; did you mean '", *SuggestedValue, "'?"});
3733
return std::string(Buffer);
3834
}
3935

4036
std::string UnparseableIntegerOptionError::message() const {
41-
llvm::SmallString<128> Buffer;
42-
llvm::raw_svector_ostream Output(Buffer);
43-
Output << "invalid configuration value '" << LookupValue << "' for option '"
44-
<< LookupName << "'; expected "
45-
<< (IsBoolean ? "a bool" : "an integer value");
37+
llvm::SmallString<256> Buffer({"invalid configuration value '", LookupValue,
38+
"' for option '", LookupName, "'; expected ",
39+
(IsBoolean ? "a bool" : "an integer value")});
4640
return std::string(Buffer);
4741
}
4842

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,14 @@ void SignedCharMisuseCheck::registerMatchers(MatchFinder *Finder) {
8484
const auto UnSignedCharCastExpr =
8585
charCastExpression(false, IntegerType, "unsignedCastExpression");
8686

87-
// Catch assignments with singed char -> integer conversion.
87+
// Catch assignments with signed char -> integer conversion.
8888
const auto AssignmentOperatorExpr =
8989
expr(binaryOperator(hasOperatorName("="), hasLHS(hasType(IntegerType)),
9090
hasRHS(SignedCharCastExpr)));
9191

9292
Finder->addMatcher(AssignmentOperatorExpr, this);
9393

94-
// Catch declarations with singed char -> integer conversion.
94+
// Catch declarations with signed char -> integer conversion.
9595
const auto Declaration = varDecl(isDefinition(), hasType(IntegerType),
9696
hasInitializer(SignedCharCastExpr));
9797

clang-tools-extra/clangd/ClangdServer.cpp

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ ClangdServer::Options::operator TUScheduler::Options() const {
139139
ClangdServer::ClangdServer(const GlobalCompilationDatabase &CDB,
140140
const ThreadsafeFS &TFS, const Options &Opts,
141141
Callbacks *Callbacks)
142-
: ConfigProvider(Opts.ConfigProvider), TFS(TFS),
142+
: ConfigProvider(Opts.ConfigProvider), TFS(TFS), ServerCallbacks(Callbacks),
143143
DynamicIdx(Opts.BuildDynamicSymbolIndex
144144
? new FileIndex(Opts.HeavyweightDynamicSymbolIndex,
145145
Opts.CollectMainFileRefs)
@@ -829,16 +829,44 @@ Context ClangdServer::createProcessingContext(PathRef File) const {
829829
Params.Path = PosixPath.str();
830830
}
831831

832-
auto DiagnosticHandler = [](const llvm::SMDiagnostic &Diag) {
833-
if (Diag.getKind() == llvm::SourceMgr::DK_Error) {
834-
elog("config error at {0}:{1}:{2}: {3}", Diag.getFilename(),
835-
Diag.getLineNo(), Diag.getColumnNo(), Diag.getMessage());
836-
} else {
837-
log("config warning at {0}:{1}:{2}: {3}", Diag.getFilename(),
838-
Diag.getLineNo(), Diag.getColumnNo(), Diag.getMessage());
832+
llvm::StringMap<std::vector<Diag>> ReportableDiagnostics;
833+
auto ConfigDiagnosticHandler = [&](const llvm::SMDiagnostic &D) {
834+
// Ensure we create the map entry even for note diagnostics we don't report.
835+
// This means that when the file is parsed with no warnings, we'll
836+
// publish an empty set of diagnostics, clearing any the client has.
837+
auto *Reportable = D.getFilename().empty()
838+
? nullptr
839+
: &ReportableDiagnostics[D.getFilename()];
840+
switch (D.getKind()) {
841+
case llvm::SourceMgr::DK_Error:
842+
elog("config error at {0}:{1}:{2}: {3}", D.getFilename(), D.getLineNo(),
843+
D.getColumnNo(), D.getMessage());
844+
if (Reportable)
845+
Reportable->push_back(toDiag(D, Diag::ClangdConfig));
846+
break;
847+
case llvm::SourceMgr::DK_Warning:
848+
log("config warning at {0}:{1}:{2}: {3}", D.getFilename(), D.getLineNo(),
849+
D.getColumnNo(), D.getMessage());
850+
if (Reportable)
851+
Reportable->push_back(toDiag(D, Diag::ClangdConfig));
852+
break;
853+
case llvm::SourceMgr::DK_Note:
854+
case llvm::SourceMgr::DK_Remark:
855+
vlog("config note at {0}:{1}:{2}: {3}", D.getFilename(), D.getLineNo(),
856+
D.getColumnNo(), D.getMessage());
857+
break;
839858
}
840859
};
841-
Config C = ConfigProvider->getConfig(Params, DiagnosticHandler);
860+
Config C = ConfigProvider->getConfig(Params, ConfigDiagnosticHandler);
861+
// Blindly publish diagnostics for the (unopened) parsed config files.
862+
// We must avoid reporting diagnostics for *the same file* concurrently.
863+
// Source file diags are published elsewhere, but those are different files.
864+
if (!ReportableDiagnostics.empty()) {
865+
std::lock_guard<std::mutex> Lock(ConfigDiagnosticsMu);
866+
for (auto &Entry : ReportableDiagnostics)
867+
ServerCallbacks->onDiagnosticsReady(Entry.first(), /*Version=*/"",
868+
std::move(Entry.second));
869+
}
842870
return Context::current().derive(Config::Key, std::move(C));
843871
}
844872

clang-tools-extra/clangd/ClangdServer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,8 @@ class ClangdServer {
363363
config::Provider *ConfigProvider = nullptr;
364364

365365
const ThreadsafeFS &TFS;
366+
Callbacks *ServerCallbacks = nullptr;
367+
mutable std::mutex ConfigDiagnosticsMu;
366368

367369
Path ResourceDir;
368370
// The index used to look up symbols. This could be:

clang-tools-extra/clangd/ConfigProvider.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ Provider::fromAncestorRelativeYAMLFiles(llvm::StringRef RelPath,
8383
const ThreadsafeFS &FS;
8484

8585
mutable std::mutex Mu;
86-
// Keys are the ancestor directory, not the actual config path within it.
86+
// Keys are the (posix-style) ancestor directory, not the config within it.
8787
// We only insert into this map, so pointers to values are stable forever.
8888
// Mutex guards the map itself, not the values (which are threadsafe).
8989
mutable llvm::StringMap<FileConfigCache> Cache;
@@ -117,6 +117,8 @@ Provider::fromAncestorRelativeYAMLFiles(llvm::StringRef RelPath,
117117
if (It == Cache.end()) {
118118
llvm::SmallString<256> ConfigPath = Ancestor;
119119
path::append(ConfigPath, RelPath);
120+
// Use native slashes for reading the file, affects diagnostics.
121+
llvm::sys::path::native(ConfigPath);
120122
It = Cache.try_emplace(Ancestor, ConfigPath.str(), Ancestor).first;
121123
}
122124
Caches.push_back(&It->second);

clang-tools-extra/clangd/ConfigProvider.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ struct Params {
4646
/// Used to report problems in parsing or interpreting a config.
4747
/// Errors reflect structurally invalid config that should be user-visible.
4848
/// Warnings reflect e.g. unknown properties that are recoverable.
49+
/// Notes are used to report files and fragments.
50+
/// (This can be used to track when previous warnings/errors have been "fixed").
4951
using DiagnosticCallback = llvm::function_ref<void(const llvm::SMDiagnostic &)>;
5052

5153
/// A chunk of configuration that has been fully analyzed and is ready to apply.

clang-tools-extra/clangd/ConfigYAML.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,10 +273,16 @@ std::vector<Fragment> Fragment::parseYAML(llvm::StringRef YAML,
273273
Fragment Fragment;
274274
Fragment.Source.Manager = SM;
275275
Fragment.Source.Location = N->getSourceRange().Start;
276+
SM->PrintMessage(Fragment.Source.Location, llvm::SourceMgr::DK_Note,
277+
"Parsing config fragment");
276278
if (Parser(*SM).parse(Fragment, *N))
277279
Result.push_back(std::move(Fragment));
278280
}
279281
}
282+
SM->PrintMessage(SM->FindLocForLineAndColumn(SM->getMainFileID(), 0, 0),
283+
llvm::SourceMgr::DK_Note,
284+
"Parsed " + llvm::Twine(Result.size()) +
285+
" fragments from file");
280286
// Hack: stash the buffer in the SourceMgr to keep it alive.
281287
// SM has two entries: "main" non-owning buffer, and ignored owning buffer.
282288
SM->AddNewSourceBuffer(std::move(Buf), llvm::SMLoc());

clang-tools-extra/clangd/Diagnostics.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,32 @@ CodeAction toCodeAction(const Fix &F, const URIForFile &File) {
377377
return Action;
378378
}
379379

380+
Diag toDiag(const llvm::SMDiagnostic &D, Diag::DiagSource Source) {
381+
Diag Result;
382+
Result.Message = D.getMessage().str();
383+
switch (D.getKind()) {
384+
case llvm::SourceMgr::DK_Error:
385+
Result.Severity = DiagnosticsEngine::Error;
386+
break;
387+
case llvm::SourceMgr::DK_Warning:
388+
Result.Severity = DiagnosticsEngine::Warning;
389+
break;
390+
default:
391+
break;
392+
}
393+
Result.Source = Source;
394+
Result.AbsFile = D.getFilename().str();
395+
Result.InsideMainFile = D.getSourceMgr()->FindBufferContainingLoc(
396+
D.getLoc()) == D.getSourceMgr()->getMainFileID();
397+
if (D.getRanges().empty())
398+
Result.Range = {{D.getLineNo() - 1, D.getColumnNo()},
399+
{D.getLineNo() - 1, D.getColumnNo()}};
400+
else
401+
Result.Range = {{D.getLineNo() - 1, (int)D.getRanges().front().first},
402+
{D.getLineNo() - 1, (int)D.getRanges().front().second}};
403+
return Result;
404+
}
405+
380406
void toLSPDiags(
381407
const Diag &D, const URIForFile &File, const ClangdDiagnosticOptions &Opts,
382408
llvm::function_ref<void(clangd::Diagnostic, llvm::ArrayRef<Fix>)> OutFn) {
@@ -404,6 +430,9 @@ void toLSPDiags(
404430
case Diag::ClangTidy:
405431
Main.source = "clang-tidy";
406432
break;
433+
case Diag::ClangdConfig:
434+
Main.source = "clangd-config";
435+
break;
407436
case Diag::Unknown:
408437
break;
409438
}

clang-tools-extra/clangd/Diagnostics.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "llvm/ADT/Optional.h"
2121
#include "llvm/ADT/STLExtras.h"
2222
#include "llvm/ADT/StringSet.h"
23+
#include "llvm/Support/SourceMgr.h"
2324
#include <cassert>
2425
#include <string>
2526

@@ -86,10 +87,11 @@ struct Note : DiagBase {};
8687
struct Diag : DiagBase {
8788
std::string Name; // if ID was recognized.
8889
// The source of this diagnostic.
89-
enum {
90+
enum DiagSource {
9091
Unknown,
9192
Clang,
9293
ClangTidy,
94+
ClangdConfig,
9395
} Source = Unknown;
9496
/// Elaborate on the problem, usually pointing to a related piece of code.
9597
std::vector<Note> Notes;
@@ -98,6 +100,8 @@ struct Diag : DiagBase {
98100
};
99101
llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const Diag &D);
100102

103+
Diag toDiag(const llvm::SMDiagnostic &, Diag::DiagSource Source);
104+
101105
/// Conversion to LSP diagnostics. Formats the error message of each diagnostic
102106
/// to include all its notes. Notes inside main file are also provided as
103107
/// separate diagnostics with their corresponding fixits. Notes outside main

0 commit comments

Comments
 (0)