Skip to content

Commit 3dccbcd

Browse files
committed
LLVM and SPIRV-LLVM-Translator pulldown (WW52)
LLVM: llvm/llvm-project@9c11e9528683 SPIRV-LLVM-Translator: KhronosGroup/SPIRV-LLVM-Translator@5f289ba
2 parents 5983dfd + 3057d0c commit 3dccbcd

File tree

2,247 files changed

+161064
-143572
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,247 files changed

+161064
-143572
lines changed

.github/workflows/llvm-bugs.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: LLVM Bugs notifier
2+
3+
on:
4+
issues:
5+
types:
6+
- opened
7+
8+
jobs:
9+
auto-subscribe:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/setup-node@v2
13+
with:
14+
node-version: 14
15+
- run: npm install mailgun.js form-data
16+
- name: Send notification
17+
uses: actions/github-script@v5
18+
env:
19+
MAILGUN_API_KEY: ${{ secrets.LLVM_BUGS_KEY }}
20+
with:
21+
script: |
22+
const Mailgun = require("mailgun.js");
23+
const formData = require('form-data');
24+
const mailgun = new Mailgun(formData);
25+
26+
const DOMAIN = "email.llvm.org";
27+
28+
const mg = mailgun.client({username: 'api', key: process.env.MAILGUN_API_KEY});
29+
30+
github.rest.issues.get({
31+
issue_number: context.issue.number,
32+
owner: context.repo.owner,
33+
repo: context.repo.repo,
34+
})
35+
.then(function(issue) {
36+
const payload = {
37+
author : issue.data.user.login,
38+
issue : issue.data.number,
39+
title : issue.data.title,
40+
url : issue.data.html_url,
41+
labels : issue.data.labels.map(label => { return label.name }),
42+
assignee : issue.data.assignees.map(assignee => { return assignee.login }),
43+
body : issue.data.body
44+
};
45+
46+
const data = {
47+
from: "LLVM Bugs <[email protected]>",
48+
49+
subject: `[Bug ${issue.data.number}] ${issue.data.title}`,
50+
template: "new-github-issue",
51+
'h:X-Mailgun-Variables': JSON.stringify(payload)
52+
};
53+
54+
return mg.messages.create(DOMAIN, data)
55+
})
56+
.then(msg => console.log(msg));

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@ void ThrowKeywordMissingCheck::registerMatchers(MatchFinder *Finder) {
2424
cxxConstructExpr(
2525
hasType(cxxRecordDecl(
2626
isSameOrDerivedFrom(matchesName("[Ee]xception|EXCEPTION")))),
27-
unless(anyOf(hasAncestor(stmt(
28-
anyOf(cxxThrowExpr(), callExpr(), returnStmt()))),
29-
hasAncestor(decl(anyOf(varDecl(), fieldDecl()))),
30-
allOf(hasAncestor(CtorInitializerList),
31-
unless(hasAncestor(cxxCatchStmt()))))))
27+
unless(anyOf(
28+
hasAncestor(
29+
stmt(anyOf(cxxThrowExpr(), callExpr(), returnStmt()))),
30+
hasAncestor(decl(anyOf(varDecl(), fieldDecl()))),
31+
hasAncestor(expr(cxxNewExpr(hasAnyPlacementArg(anything())))),
32+
allOf(hasAncestor(CtorInitializerList),
33+
unless(hasAncestor(cxxCatchStmt()))))))
3234
.bind("temporary-exception-not-thrown"),
3335
this);
3436
}

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

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ NarrowingConversionsCheck::NarrowingConversionsCheck(StringRef Name,
3737
: ClangTidyCheck(Name, Context),
3838
WarnOnIntegerNarrowingConversion(
3939
Options.get("WarnOnIntegerNarrowingConversion", true)),
40+
WarnOnIntegerToFloatingPointNarrowingConversion(
41+
Options.get("WarnOnIntegerToFloatingPointNarrowingConversion", true)),
4042
WarnOnFloatingPointNarrowingConversion(
4143
Options.get("WarnOnFloatingPointNarrowingConversion", true)),
4244
WarnWithinTemplateInstantiation(
@@ -49,6 +51,8 @@ void NarrowingConversionsCheck::storeOptions(
4951
ClangTidyOptions::OptionMap &Opts) {
5052
Options.store(Opts, "WarnOnIntegerNarrowingConversion",
5153
WarnOnIntegerNarrowingConversion);
54+
Options.store(Opts, "WarnOnIntegerToFloatingPointNarrowingConversion",
55+
WarnOnIntegerToFloatingPointNarrowingConversion);
5256
Options.store(Opts, "WarnOnFloatingPointNarrowingConversion",
5357
WarnOnFloatingPointNarrowingConversion);
5458
Options.store(Opts, "WarnWithinTemplateInstantiation",
@@ -425,19 +429,21 @@ void NarrowingConversionsCheck::handleIntegralToBoolean(
425429
void NarrowingConversionsCheck::handleIntegralToFloating(
426430
const ASTContext &Context, SourceLocation SourceLoc, const Expr &Lhs,
427431
const Expr &Rhs) {
428-
const BuiltinType *ToType = getBuiltinType(Lhs);
429-
llvm::APSInt IntegerConstant;
430-
if (getIntegerConstantExprValue(Context, Rhs, IntegerConstant)) {
431-
if (!isWideEnoughToHold(Context, IntegerConstant, *ToType))
432-
diagNarrowIntegerConstant(SourceLoc, Lhs, Rhs, IntegerConstant);
433-
return;
434-
}
432+
if (WarnOnIntegerToFloatingPointNarrowingConversion) {
433+
const BuiltinType *ToType = getBuiltinType(Lhs);
434+
llvm::APSInt IntegerConstant;
435+
if (getIntegerConstantExprValue(Context, Rhs, IntegerConstant)) {
436+
if (!isWideEnoughToHold(Context, IntegerConstant, *ToType))
437+
diagNarrowIntegerConstant(SourceLoc, Lhs, Rhs, IntegerConstant);
438+
return;
439+
}
435440

436-
const BuiltinType *FromType = getBuiltinType(Rhs);
437-
if (isWarningInhibitedByEquivalentSize(Context, *FromType, *ToType))
438-
return;
439-
if (!isWideEnoughToHold(Context, *FromType, *ToType))
440-
diagNarrowType(SourceLoc, Lhs, Rhs);
441+
const BuiltinType *FromType = getBuiltinType(Rhs);
442+
if (isWarningInhibitedByEquivalentSize(Context, *FromType, *ToType))
443+
return;
444+
if (!isWideEnoughToHold(Context, *FromType, *ToType))
445+
diagNarrowType(SourceLoc, Lhs, Rhs);
446+
}
441447
}
442448

443449
void NarrowingConversionsCheck::handleFloatingToIntegral(

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ class NarrowingConversionsCheck : public ClangTidyCheck {
9898
const BuiltinType &ToType) const;
9999

100100
const bool WarnOnIntegerNarrowingConversion;
101+
const bool WarnOnIntegerToFloatingPointNarrowingConversion;
101102
const bool WarnOnFloatingPointNarrowingConversion;
102103
const bool WarnWithinTemplateInstantiation;
103104
const bool WarnOnEquivalentBitWidth;

clang-tools-extra/clangd/ClangdLSPServer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ void ClangdLSPServer::onInitialize(const InitializeParams &Params,
555555
}},
556556
{"signatureHelpProvider",
557557
llvm::json::Object{
558-
{"triggerCharacters", {"(", ","}},
558+
{"triggerCharacters", {"(", ",", ")"}},
559559
}},
560560
{"declarationProvider", true},
561561
{"definitionProvider", true},

clang-tools-extra/clangd/ClangdServer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ struct UpdateIndexCallbacks : public ParsingCallbacks {
7171
: FIndex(FIndex), ServerCallbacks(ServerCallbacks) {}
7272

7373
void onPreambleAST(PathRef Path, llvm::StringRef Version, ASTContext &Ctx,
74-
std::shared_ptr<clang::Preprocessor> PP,
74+
Preprocessor &PP,
7575
const CanonicalIncludes &CanonIncludes) override {
7676
if (FIndex)
77-
FIndex->updatePreamble(Path, Version, Ctx, std::move(PP), CanonIncludes);
77+
FIndex->updatePreamble(Path, Version, Ctx, PP, CanonIncludes);
7878
}
7979

8080
void onMainAST(PathRef Path, ParsedAST &AST, PublishFn Publish) override {

clang-tools-extra/clangd/ParsedAST.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,8 @@ ParsedAST::build(llvm::StringRef Filename, const ParseInputs &Inputs,
395395
if (IsInsideMainFile &&
396396
tidy::shouldSuppressDiagnostic(DiagLevel, Info, *CTContext,
397397
TidySuppressedErrors,
398-
/*AllowIO=*/false)) {
398+
/*AllowIO=*/false,
399+
/*EnableNolintBlocks=*/false)) {
399400
// FIXME: should we expose the suppression error (invalid use of
400401
// NOLINT comments)?
401402
return DiagnosticsEngine::Ignored;

clang-tools-extra/clangd/Preamble.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,7 @@ class CppFilePreambleCallbacks : public PreambleCallbacks {
8484
void AfterExecute(CompilerInstance &CI) override {
8585
if (ParsedCallback) {
8686
trace::Span Tracer("Running PreambleCallback");
87-
ParsedCallback(CI.getASTContext(), CI.getPreprocessorPtr(),
88-
CanonIncludes);
87+
ParsedCallback(CI.getASTContext(), CI.getPreprocessor(), CanonIncludes);
8988
}
9089

9190
const SourceManager &SM = CI.getSourceManager();

clang-tools-extra/clangd/Preamble.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,8 @@ struct PreambleData {
7272
bool MainIsIncludeGuarded = false;
7373
};
7474

75-
using PreambleParsedCallback =
76-
std::function<void(ASTContext &, std::shared_ptr<clang::Preprocessor>,
77-
const CanonicalIncludes &)>;
75+
using PreambleParsedCallback = std::function<void(ASTContext &, Preprocessor &,
76+
const CanonicalIncludes &)>;
7877

7978
/// Build a preamble for the new inputs unless an old one can be reused.
8079
/// If \p PreambleCallback is set, it will be run on top of the AST while

clang-tools-extra/clangd/TUScheduler.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -977,11 +977,9 @@ void PreambleThread::build(Request Req) {
977977

978978
LatestBuild = clang::clangd::buildPreamble(
979979
FileName, *Req.CI, Inputs, StoreInMemory,
980-
[this, Version(Inputs.Version)](ASTContext &Ctx,
981-
std::shared_ptr<clang::Preprocessor> PP,
980+
[this, Version(Inputs.Version)](ASTContext &Ctx, Preprocessor &PP,
982981
const CanonicalIncludes &CanonIncludes) {
983-
Callbacks.onPreambleAST(FileName, Version, Ctx, std::move(PP),
984-
CanonIncludes);
982+
Callbacks.onPreambleAST(FileName, Version, Ctx, PP, CanonIncludes);
985983
});
986984
if (LatestBuild && isReliable(LatestBuild->CompileCommand))
987985
HeaderIncluders.update(FileName, LatestBuild->Includes.allHeaders());

clang-tools-extra/clangd/TUScheduler.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,7 @@ class ParsingCallbacks {
134134
/// contains only AST nodes from the #include directives at the start of the
135135
/// file. AST node in the current file should be observed on onMainAST call.
136136
virtual void onPreambleAST(PathRef Path, llvm::StringRef Version,
137-
ASTContext &Ctx,
138-
std::shared_ptr<clang::Preprocessor> PP,
137+
ASTContext &Ctx, Preprocessor &PP,
139138
const CanonicalIncludes &) {}
140139

141140
/// The argument function is run under the critical section guarding against

clang-tools-extra/clangd/index/FileIndex.cpp

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ namespace clang {
4545
namespace clangd {
4646
namespace {
4747

48-
SlabTuple indexSymbols(ASTContext &AST, std::shared_ptr<Preprocessor> PP,
48+
SlabTuple indexSymbols(ASTContext &AST, Preprocessor &PP,
4949
llvm::ArrayRef<Decl *> DeclsToIndex,
5050
const MainFileMacros *MacroRefsToIndex,
5151
const CanonicalIncludes &Includes, bool IsIndexMainAST,
@@ -77,7 +77,7 @@ SlabTuple indexSymbols(ASTContext &AST, std::shared_ptr<Preprocessor> PP,
7777

7878
SymbolCollector Collector(std::move(CollectorOpts));
7979
Collector.setPreprocessor(PP);
80-
index::indexTopLevelDecls(AST, *PP, DeclsToIndex, Collector, IndexOpts);
80+
index::indexTopLevelDecls(AST, PP, DeclsToIndex, Collector, IndexOpts);
8181
if (MacroRefsToIndex)
8282
Collector.handleMacros(*MacroRefsToIndex);
8383

@@ -219,18 +219,18 @@ FileShardedIndex::getShard(llvm::StringRef Uri) const {
219219

220220
SlabTuple indexMainDecls(ParsedAST &AST) {
221221
return indexSymbols(
222-
AST.getASTContext(), AST.getPreprocessorPtr(),
223-
AST.getLocalTopLevelDecls(), &AST.getMacros(), AST.getCanonicalIncludes(),
222+
AST.getASTContext(), AST.getPreprocessor(), AST.getLocalTopLevelDecls(),
223+
&AST.getMacros(), AST.getCanonicalIncludes(),
224224
/*IsIndexMainAST=*/true, AST.version(), /*CollectMainFileRefs=*/true);
225225
}
226226

227227
SlabTuple indexHeaderSymbols(llvm::StringRef Version, ASTContext &AST,
228-
std::shared_ptr<Preprocessor> PP,
228+
Preprocessor &PP,
229229
const CanonicalIncludes &Includes) {
230230
std::vector<Decl *> DeclsToIndex(
231231
AST.getTranslationUnitDecl()->decls().begin(),
232232
AST.getTranslationUnitDecl()->decls().end());
233-
return indexSymbols(AST, std::move(PP), DeclsToIndex,
233+
return indexSymbols(AST, PP, DeclsToIndex,
234234
/*MainFileMacros=*/nullptr, Includes,
235235
/*IsIndexMainAST=*/false, Version,
236236
/*CollectMainFileRefs=*/false);
@@ -424,12 +424,11 @@ FileIndex::FileIndex()
424424
MainFileIndex(std::make_unique<MemIndex>()) {}
425425

426426
void FileIndex::updatePreamble(PathRef Path, llvm::StringRef Version,
427-
ASTContext &AST,
428-
std::shared_ptr<Preprocessor> PP,
427+
ASTContext &AST, Preprocessor &PP,
429428
const CanonicalIncludes &Includes) {
430429
IndexFileIn IF;
431430
std::tie(IF.Symbols, std::ignore, IF.Relations) =
432-
indexHeaderSymbols(Version, AST, std::move(PP), Includes);
431+
indexHeaderSymbols(Version, AST, PP, Includes);
433432
FileShardedIndex ShardedIndex(std::move(IF));
434433
for (auto Uri : ShardedIndex.getAllSources()) {
435434
auto IF = ShardedIndex.getShard(Uri);

clang-tools-extra/clangd/index/FileIndex.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,7 @@ class FileIndex : public MergedIndex {
115115
/// Update preamble symbols of file \p Path with all declarations in \p AST
116116
/// and macros in \p PP.
117117
void updatePreamble(PathRef Path, llvm::StringRef Version, ASTContext &AST,
118-
std::shared_ptr<Preprocessor> PP,
119-
const CanonicalIncludes &Includes);
118+
Preprocessor &PP, const CanonicalIncludes &Includes);
120119

121120
/// Update symbols and references from main file \p Path with
122121
/// `indexMainDecls`.
@@ -163,7 +162,7 @@ SlabTuple indexMainDecls(ParsedAST &AST);
163162
/// Index declarations from \p AST and macros from \p PP that are declared in
164163
/// included headers.
165164
SlabTuple indexHeaderSymbols(llvm::StringRef Version, ASTContext &AST,
166-
std::shared_ptr<Preprocessor> PP,
165+
Preprocessor &PP,
167166
const CanonicalIncludes &Includes);
168167

169168
/// Takes slabs coming from a TU (multiple files) and shards them per

clang-tools-extra/clangd/index/SymbolCollector.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ class SymbolCollector::HeaderFileURICache {
186186
// Weird double-indirect access to PP, which might not be ready yet when
187187
// HeaderFiles is created but will be by the time it's used.
188188
// (IndexDataConsumer::setPreprocessor can happen before or after initialize)
189-
const std::shared_ptr<Preprocessor> &PP;
189+
Preprocessor *&PP;
190190
const SourceManager &SM;
191191
const CanonicalIncludes *Includes;
192192
llvm::StringRef FallbackDir;
@@ -195,8 +195,7 @@ class SymbolCollector::HeaderFileURICache {
195195
llvm::DenseMap<FileID, llvm::StringRef> CacheFIDToInclude;
196196

197197
public:
198-
HeaderFileURICache(const std::shared_ptr<Preprocessor> &PP,
199-
const SourceManager &SM,
198+
HeaderFileURICache(Preprocessor *&PP, const SourceManager &SM,
200199
const SymbolCollector::Options &Opts)
201200
: PP(PP), SM(SM), Includes(Opts.Includes), FallbackDir(Opts.FallbackDir) {
202201
}
@@ -304,7 +303,7 @@ SymbolCollector::~SymbolCollector() = default;
304303
void SymbolCollector::initialize(ASTContext &Ctx) {
305304
ASTCtx = &Ctx;
306305
HeaderFileURIs = std::make_unique<HeaderFileURICache>(
307-
PP, ASTCtx->getSourceManager(), Opts);
306+
this->PP, ASTCtx->getSourceManager(), Opts);
308307
CompletionAllocator = std::make_shared<GlobalCodeCompletionAllocator>();
309308
CompletionTUInfo =
310309
std::make_unique<CodeCompletionTUInfo>(CompletionAllocator);
@@ -365,7 +364,7 @@ bool SymbolCollector::handleDeclOccurrence(
365364
const Decl *D, index::SymbolRoleSet Roles,
366365
llvm::ArrayRef<index::SymbolRelation> Relations, SourceLocation Loc,
367366
index::IndexDataConsumer::ASTNodeInfo ASTNode) {
368-
assert(ASTCtx && PP.get() && HeaderFileURIs);
367+
assert(ASTCtx && PP && HeaderFileURIs);
369368
assert(CompletionAllocator && CompletionTUInfo);
370369
assert(ASTNode.OrigD);
371370
// Indexing API puts canonical decl into D, which might not have a valid
@@ -486,7 +485,7 @@ bool SymbolCollector::handleDeclOccurrence(
486485
}
487486

488487
void SymbolCollector::handleMacros(const MainFileMacros &MacroRefsToIndex) {
489-
assert(HeaderFileURIs && PP.get());
488+
assert(HeaderFileURIs && PP);
490489
const auto &SM = PP->getSourceManager();
491490
const auto *MainFileEntry = SM.getFileEntryForID(SM.getMainFileID());
492491
assert(MainFileEntry);
@@ -533,7 +532,7 @@ bool SymbolCollector::handleMacroOccurrence(const IdentifierInfo *Name,
533532
const MacroInfo *MI,
534533
index::SymbolRoleSet Roles,
535534
SourceLocation Loc) {
536-
assert(PP.get());
535+
assert(PP);
537536
// Builtin macros don't have useful locations and aren't needed in completion.
538537
if (MI->isBuiltinMacro())
539538
return true;
@@ -805,7 +804,7 @@ const Symbol *SymbolCollector::addDeclaration(const NamedDecl &ND, SymbolID ID,
805804

806805
// Add completion info.
807806
// FIXME: we may want to choose a different redecl, or combine from several.
808-
assert(ASTCtx && PP.get() && "ASTContext and Preprocessor must be set.");
807+
assert(ASTCtx && PP && "ASTContext and Preprocessor must be set.");
809808
// We use the primary template, as clang does during code completion.
810809
CodeCompletionResult SymbolCompletion(&getTemplateOrThis(ND), 0);
811810
const auto *CCS = SymbolCompletion.CreateCodeCompletionString(

clang-tools-extra/clangd/index/SymbolCollector.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,9 @@ class SymbolCollector : public index::IndexDataConsumer {
100100
void initialize(ASTContext &Ctx) override;
101101

102102
void setPreprocessor(std::shared_ptr<Preprocessor> PP) override {
103-
this->PP = std::move(PP);
103+
this->PP = PP.get();
104104
}
105+
void setPreprocessor(Preprocessor &PP) { this->PP = &PP; }
105106

106107
bool
107108
handleDeclOccurrence(const Decl *D, index::SymbolRoleSet Roles,
@@ -153,7 +154,7 @@ class SymbolCollector : public index::IndexDataConsumer {
153154
// All relations collected from the AST.
154155
RelationSlab::Builder Relations;
155156
ASTContext *ASTCtx;
156-
std::shared_ptr<Preprocessor> PP;
157+
Preprocessor *PP = nullptr;
157158
std::shared_ptr<GlobalCodeCompletionAllocator> CompletionAllocator;
158159
std::unique_ptr<CodeCompletionTUInfo> CompletionTUInfo;
159160
Options Opts;

clang-tools-extra/clangd/index/dex/Trigram.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ namespace dex {
2828
// Produce trigrams (including duplicates) and pass them to Out().
2929
template <typename Func>
3030
static void identifierTrigrams(llvm::StringRef Identifier, Func Out) {
31+
assert(!Identifier.empty());
3132
// Apply fuzzy matching text segmentation.
3233
llvm::SmallVector<CharRole> Roles(Identifier.size());
3334
calculateRoles(Identifier,
@@ -104,6 +105,9 @@ void generateIdentifierTrigrams(llvm::StringRef Identifier,
104105
// The magic number was tuned by running IndexBenchmark.DexBuild.
105106
constexpr unsigned ManyTrigramsIdentifierThreshold = 14;
106107
Result.clear();
108+
if (Identifier.empty())
109+
return;
110+
107111
if (Identifier.size() < ManyTrigramsIdentifierThreshold) {
108112
identifierTrigrams(Identifier, [&](Trigram T) {
109113
if (!llvm::is_contained(Result, T))

0 commit comments

Comments
 (0)