Skip to content

Commit 5108ef8

Browse files
Merge from 'master' to 'sycl-web' (#3)
CONFLICT (content): Merge conflict in llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
2 parents 8da21f6 + 3c811ce commit 5108ef8

File tree

1,048 files changed

+17293
-7853
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,048 files changed

+17293
-7853
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: main branch sync
2+
3+
on:
4+
push:
5+
branches:
6+
- 'master'
7+
8+
jobs:
9+
branch_sync:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout Code
13+
uses: actions/checkout@v2
14+
with:
15+
fetch-depth: 0
16+
17+
- name: Update branch
18+
run: |
19+
git push https://${{ github.token }}@github.com/${{ github.repository }} HEAD:temp-test-main

clang-tools-extra/clang-query/QueryParser.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,6 @@ QueryRef QueryParser::parseSetTraversalKind(
134134
unsigned Value =
135135
LexOrCompleteWord<unsigned>(this, ValStr)
136136
.Case("AsIs", ast_type_traits::TK_AsIs)
137-
.Case("IgnoreImplicitCastsAndParentheses",
138-
ast_type_traits::TK_IgnoreImplicitCastsAndParentheses)
139137
.Case("IgnoreUnlessSpelledInSource",
140138
ast_type_traits::TK_IgnoreUnlessSpelledInSource)
141139
.Default(~0u);

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

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,11 @@ void UnusedRaiiCheck::check(const MatchFinder::MatchResult &Result) {
7979
// written type.
8080
auto Matches =
8181
match(expr(hasDescendant(typeLoc().bind("t"))), *E, *Result.Context);
82-
const auto *TL = selectFirst<TypeLoc>("t", Matches);
83-
assert(TL);
84-
D << FixItHint::CreateInsertion(
85-
Lexer::getLocForEndOfToken(TL->getEndLoc(), 0, *Result.SourceManager,
86-
getLangOpts()),
87-
Replacement);
82+
if (const auto *TL = selectFirst<TypeLoc>("t", Matches))
83+
D << FixItHint::CreateInsertion(
84+
Lexer::getLocForEndOfToken(TL->getEndLoc(), 0, *Result.SourceManager,
85+
getLangOpts()),
86+
Replacement);
8887
}
8988

9089
} // namespace bugprone

clang-tools-extra/clang-tidy/cppcoreguidelines/MacroUsageCheck.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ bool isCapsOnly(StringRef Name) {
3232
class MacroUsageCallbacks : public PPCallbacks {
3333
public:
3434
MacroUsageCallbacks(MacroUsageCheck *Check, const SourceManager &SM,
35-
StringRef RegExp, bool CapsOnly, bool IgnoreCommandLine)
36-
: Check(Check), SM(SM), RegExp(RegExp), CheckCapsOnly(CapsOnly),
35+
StringRef RegExpStr, bool CapsOnly, bool IgnoreCommandLine)
36+
: Check(Check), SM(SM), RegExp(RegExpStr), CheckCapsOnly(CapsOnly),
3737
IgnoreCommandLineMacros(IgnoreCommandLine) {}
3838
void MacroDefined(const Token &MacroNameTok,
3939
const MacroDirective *MD) override {
@@ -47,7 +47,7 @@ class MacroUsageCallbacks : public PPCallbacks {
4747
return;
4848

4949
StringRef MacroName = MacroNameTok.getIdentifierInfo()->getName();
50-
if (!CheckCapsOnly && !llvm::Regex(RegExp).match(MacroName))
50+
if (!CheckCapsOnly && !RegExp.match(MacroName))
5151
Check->warnMacro(MD, MacroName);
5252

5353
if (CheckCapsOnly && !isCapsOnly(MacroName))
@@ -57,7 +57,7 @@ class MacroUsageCallbacks : public PPCallbacks {
5757
private:
5858
MacroUsageCheck *Check;
5959
const SourceManager &SM;
60-
StringRef RegExp;
60+
const llvm::Regex RegExp;
6161
bool CheckCapsOnly;
6262
bool IgnoreCommandLineMacros;
6363
};

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "ASTUtils.h"
1111
#include "clang/AST/CXXInheritance.h"
1212
#include "clang/ASTMatchers/ASTMatchFinder.h"
13+
#include "clang/Basic/CharInfo.h"
1314
#include "clang/Frontend/CompilerInstance.h"
1415
#include "clang/Lex/PPCallbacks.h"
1516
#include "clang/Lex/Preprocessor.h"
@@ -463,6 +464,8 @@ void RenamerClangTidyCheck::check(const MatchFinder::MatchResult &Result) {
463464
Failure.FixStatus = ShouldFixStatus::ConflictsWithKeyword;
464465
else if (Ident->hasMacroDefinition())
465466
Failure.FixStatus = ShouldFixStatus::ConflictsWithMacroDefinition;
467+
} else if (!isValidIdentifier(Info.Fixup)) {
468+
Failure.FixStatus = ShouldFixStatus::FixInvalidIdentifier;
466469
}
467470

468471
Failure.Info = std::move(Info);
@@ -503,7 +506,8 @@ void RenamerClangTidyCheck::expandMacro(const Token &MacroNameTok,
503506
static std::string
504507
getDiagnosticSuffix(const RenamerClangTidyCheck::ShouldFixStatus FixStatus,
505508
const std::string &Fixup) {
506-
if (Fixup.empty())
509+
if (Fixup.empty() ||
510+
FixStatus == RenamerClangTidyCheck::ShouldFixStatus::FixInvalidIdentifier)
507511
return "; cannot be fixed automatically";
508512
if (FixStatus == RenamerClangTidyCheck::ShouldFixStatus::ShouldFix)
509513
return {};
@@ -517,7 +521,6 @@ getDiagnosticSuffix(const RenamerClangTidyCheck::ShouldFixStatus FixStatus,
517521
RenamerClangTidyCheck::ShouldFixStatus::ConflictsWithMacroDefinition)
518522
return "; cannot be fixed because '" + Fixup +
519523
"' would conflict with a macro definition";
520-
521524
llvm_unreachable("invalid ShouldFixStatus");
522525
}
523526

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ class RenamerClangTidyCheck : public ClangTidyCheck {
5959
/// automatically.
6060
ConflictsWithMacroDefinition,
6161

62+
/// The fixup results in an identifier that is not a valid c/c++ identifier.
63+
FixInvalidIdentifier,
64+
6265
/// Values pass this threshold will be ignored completely
6366
/// i.e no message, no fixup.
6467
IgnoreFailureThreshold,

clang-tools-extra/clangd/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ add_clang_library(clangDaemon
9797
index/IndexAction.cpp
9898
index/MemIndex.cpp
9999
index/Merge.cpp
100+
index/ProjectAware.cpp
100101
index/Ref.cpp
101102
index/Relation.cpp
102103
index/Serialization.cpp
@@ -139,7 +140,6 @@ clang_target_link_libraries(clangDaemon
139140
clangTooling
140141
clangToolingCore
141142
clangToolingInclusions
142-
clangToolingRefactoring
143143
clangToolingSyntax
144144
)
145145

clang-tools-extra/clangd/ClangdLSPServer.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -604,6 +604,7 @@ void ClangdLSPServer::onInitialize(const InitializeParams &Params,
604604
}},
605605
{"declarationProvider", true},
606606
{"definitionProvider", true},
607+
{"implementationProvider", true},
607608
{"documentHighlightProvider", true},
608609
{"documentLinkProvider",
609610
llvm::json::Object{
@@ -1291,6 +1292,22 @@ void ClangdLSPServer::onReference(const ReferenceParams &Params,
12911292
});
12921293
}
12931294

1295+
void ClangdLSPServer::onGoToImplementation(
1296+
const TextDocumentPositionParams &Params,
1297+
Callback<std::vector<Location>> Reply) {
1298+
Server->findImplementations(
1299+
Params.textDocument.uri.file(), Params.position,
1300+
[Reply = std::move(Reply)](
1301+
llvm::Expected<std::vector<LocatedSymbol>> Overrides) mutable {
1302+
if (!Overrides)
1303+
return Reply(Overrides.takeError());
1304+
std::vector<Location> Impls;
1305+
for (const LocatedSymbol &Sym : *Overrides)
1306+
Impls.push_back(Sym.PreferredDeclaration);
1307+
return Reply(std::move(Impls));
1308+
});
1309+
}
1310+
12941311
void ClangdLSPServer::onSymbolInfo(const TextDocumentPositionParams &Params,
12951312
Callback<std::vector<SymbolDetails>> Reply) {
12961313
Server->symbolInfo(Params.textDocument.uri.file(), Params.position,
@@ -1431,6 +1448,7 @@ ClangdLSPServer::ClangdLSPServer(class Transport &Transp,
14311448
MsgHandler->bind("textDocument/signatureHelp", &ClangdLSPServer::onSignatureHelp);
14321449
MsgHandler->bind("textDocument/definition", &ClangdLSPServer::onGoToDefinition);
14331450
MsgHandler->bind("textDocument/declaration", &ClangdLSPServer::onGoToDeclaration);
1451+
MsgHandler->bind("textDocument/implementation", &ClangdLSPServer::onGoToImplementation);
14341452
MsgHandler->bind("textDocument/references", &ClangdLSPServer::onReference);
14351453
MsgHandler->bind("textDocument/switchSourceHeader", &ClangdLSPServer::onSwitchSourceHeader);
14361454
MsgHandler->bind("textDocument/prepareRename", &ClangdLSPServer::onPrepareRename);

clang-tools-extra/clangd/ClangdLSPServer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,8 @@ class ClangdLSPServer : private ClangdServer::Callbacks {
115115
Callback<std::vector<Location>>);
116116
void onGoToDefinition(const TextDocumentPositionParams &,
117117
Callback<std::vector<Location>>);
118+
void onGoToImplementation(const TextDocumentPositionParams &,
119+
Callback<std::vector<Location>>);
118120
void onReference(const ReferenceParams &, Callback<std::vector<Location>>);
119121
void onSwitchSourceHeader(const TextDocumentIdentifier &,
120122
Callback<llvm::Optional<URIForFile>>);

clang-tools-extra/clangd/ClangdServer.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,18 @@ void ClangdServer::foldingRanges(llvm::StringRef File,
718718
TUScheduler::InvalidateOnUpdate);
719719
}
720720

721+
void ClangdServer::findImplementations(
722+
PathRef File, Position Pos, Callback<std::vector<LocatedSymbol>> CB) {
723+
auto Action = [Pos, CB = std::move(CB),
724+
this](llvm::Expected<InputsAndAST> InpAST) mutable {
725+
if (!InpAST)
726+
return CB(InpAST.takeError());
727+
CB(clangd::findImplementations(InpAST->AST, Pos, Index));
728+
};
729+
730+
WorkScheduler.runWithAST("Implementations", File, std::move(Action));
731+
}
732+
721733
void ClangdServer::findReferences(PathRef File, Position Pos, uint32_t Limit,
722734
Callback<ReferencesResult> CB) {
723735
auto Action = [Pos, Limit, CB = std::move(CB),

clang-tools-extra/clangd/ClangdServer.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,10 @@ class ClangdServer {
253253
/// Retrieve ranges that can be used to fold code within the specified file.
254254
void foldingRanges(StringRef File, Callback<std::vector<FoldingRange>> CB);
255255

256+
/// Retrieve implementations for virtual method.
257+
void findImplementations(PathRef File, Position Pos,
258+
Callback<std::vector<LocatedSymbol>> CB);
259+
256260
/// Retrieve locations for symbol references.
257261
void findReferences(PathRef File, Position Pos, uint32_t Limit,
258262
Callback<ReferencesResult> CB);

clang-tools-extra/clangd/Config.h

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626

2727
#include "support/Context.h"
2828
#include "llvm/ADT/FunctionExtras.h"
29+
#include "llvm/ADT/Optional.h"
30+
#include "llvm/ADT/StringMap.h"
2931
#include <string>
3032
#include <vector>
3133

@@ -57,10 +59,22 @@ struct Config {
5759
} CompileFlags;
5860

5961
enum class BackgroundPolicy { Build, Skip };
62+
/// Describes an external index configuration.
63+
struct ExternalIndexSpec {
64+
enum { File, Server } Kind;
65+
/// This is one of:
66+
/// - Address of a clangd-index-server, in the form of "ip:port".
67+
/// - Absolute path to an index produced by clangd-indexer.
68+
std::string Location;
69+
/// Absolute path to source root this index is associated with, uses
70+
/// forward-slashes.
71+
std::string MountPoint;
72+
};
6073
/// Controls background-index behavior.
6174
struct {
6275
/// Whether this TU should be indexed.
6376
BackgroundPolicy Background = BackgroundPolicy::Build;
77+
llvm::Optional<ExternalIndexSpec> External;
6478
} Index;
6579

6680
/// Style of the codebase.
@@ -70,9 +84,37 @@ struct Config {
7084
// ::). All nested namespaces are affected as well.
7185
std::vector<std::string> FullyQualifiedNamespaces;
7286
} Style;
87+
88+
/// Configures what clang-tidy checks to run and options to use with them.
89+
struct {
90+
// A comma-seperated list of globs to specify which clang-tidy checks to
91+
// run.
92+
std::string Checks;
93+
llvm::StringMap<std::string> CheckOptions;
94+
} ClangTidy;
7395
};
7496

7597
} // namespace clangd
7698
} // namespace clang
7799

100+
namespace llvm {
101+
template <> struct DenseMapInfo<clang::clangd::Config::ExternalIndexSpec> {
102+
using ExternalIndexSpec = clang::clangd::Config::ExternalIndexSpec;
103+
static inline ExternalIndexSpec getEmptyKey() {
104+
return {ExternalIndexSpec::File, "", ""};
105+
}
106+
static inline ExternalIndexSpec getTombstoneKey() {
107+
return {ExternalIndexSpec::File, "TOMB", "STONE"};
108+
}
109+
static unsigned getHashValue(const ExternalIndexSpec &Val) {
110+
return llvm::hash_combine(Val.Kind, Val.Location, Val.MountPoint);
111+
}
112+
static bool isEqual(const ExternalIndexSpec &LHS,
113+
const ExternalIndexSpec &RHS) {
114+
return std::tie(LHS.Kind, LHS.Location, LHS.MountPoint) ==
115+
std::tie(RHS.Kind, RHS.Location, RHS.MountPoint);
116+
}
117+
};
118+
} // namespace llvm
119+
78120
#endif

0 commit comments

Comments
 (0)