Skip to content

Commit 1433a5f

Browse files
committed
Merge commit 'b8c9ebfac89857e4a3bb6602d6567b0954b31011' into feature/merge-upstream-20211217
2 parents 74db2f5 + b8c9ebf commit 1433a5f

File tree

667 files changed

+25808
-11900
lines changed

Some content is hidden

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

667 files changed

+25808
-11900
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/test/initialize-params.test

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,8 @@
107107
# CHECK-NEXT: "signatureHelpProvider": {
108108
# CHECK-NEXT: "triggerCharacters": [
109109
# CHECK-NEXT: "(",
110-
# CHECK-NEXT: ","
110+
# CHECK-NEXT: ",",
111+
# CHECK-NEXT: ")"
111112
# CHECK-NEXT: ]
112113
# CHECK-NEXT: },
113114
# CHECK-NEXT: "textDocumentSync": {

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,16 @@ Changes in existing checks
148148

149149
- Fixed a false positive in :doc:`fuchsia-trailing-return
150150
<clang-tidy/checks/fuchsia-trailing-return>` for C++17 deduction guides.
151+
152+
- Fixed a false positive in :doc:`bugprone-throw-keyword-missing
153+
<clang-tidy/checks/bugprone-throw-keyword-missing>` when creating an exception object
154+
using placement new
155+
156+
- :doc:`cppcoreguidelines-narrowing-conversions <clang-tidy/checks/cppcoreguidelines-narrowing-conversions>`
157+
check now supports a `WarnOnIntegerToFloatingPointNarrowingConversion`
158+
option to control whether to warn on narrowing integer to floating-point
159+
conversions.
160+
151161

152162
Removed checks
153163
^^^^^^^^^^^^^^

clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-narrowing-conversions.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#es4
1515
We enforce only part of the guideline, more specifically, we flag narrowing conversions from:
1616
- an integer to a narrower integer (e.g. ``char`` to ``unsigned char``)
1717
if WarnOnIntegerNarrowingConversion Option is set,
18-
- an integer to a narrower floating-point (e.g. ``uint64_t`` to ``float``),
18+
- an integer to a narrower floating-point (e.g. ``uint64_t`` to ``float``)
19+
if WarnOnIntegerToFloatingPointNarrowingConversion Option is set,
1920
- a floating-point to an integer (e.g. ``double`` to ``int``),
2021
- a floating-point to a narrower floating-point (e.g. ``double`` to ``float``)
2122
if WarnOnFloatingPointNarrowingConversion Option is set.
@@ -36,6 +37,11 @@ Options
3637
When `true`, the check will warn on narrowing integer conversion
3738
(e.g. ``int`` to ``size_t``). `true` by default.
3839

40+
.. option:: WarnOnIntegerToFloatingPointNarrowingConversion
41+
42+
When `true`, the check will warn on narrowing integer to floating-point
43+
conversion (e.g. ``size_t`` to ``double``). `true` by default.
44+
3945
.. option:: WarnOnFloatingPointNarrowingConversion
4046

4147
When `true`, the check will warn on narrowing floating point conversion

clang-tools-extra/test/clang-tidy/checkers/bugprone-throw-keyword-missing.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,3 +175,14 @@ struct ExceptionRAII {
175175
void exceptionRAIITest() {
176176
ExceptionRAII E;
177177
}
178+
179+
namespace std {
180+
typedef decltype(sizeof(void*)) size_t;
181+
}
182+
183+
void* operator new(std::size_t, void*);
184+
185+
void placeMentNewTest() {
186+
alignas(RegularException) unsigned char expr[sizeof(RegularException)];
187+
new (expr) RegularException{};
188+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// RUN: %check_clang_tidy -check-suffix=DEFAULT %s \
2+
// RUN: cppcoreguidelines-narrowing-conversions %t -- \
3+
// RUN: -config='{CheckOptions: [{key: cppcoreguidelines-narrowing-conversions.WarnOnIntegerToFloatingPointNarrowingConversion, value: true}]}'
4+
5+
// RUN: %check_clang_tidy -check-suffix=DISABLED %s \
6+
// RUN: cppcoreguidelines-narrowing-conversions %t -- \
7+
// RUN: -config='{CheckOptions: [{key: cppcoreguidelines-narrowing-conversions.WarnOnIntegerToFloatingPointNarrowingConversion, value: false}]}'
8+
9+
void foo(unsigned long long value) {
10+
double a = value;
11+
// CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:14: warning: narrowing conversion from 'unsigned long long' to 'double' [cppcoreguidelines-narrowing-conversions]
12+
// DISABLED: No warning for integer to floating-point narrowing conversions when WarnOnIntegerToFloatingPointNarrowingConversion = false.
13+
}
14+
15+
void floating_point_to_integer_is_still_not_ok(double f) {
16+
int a = f;
17+
// CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:11: warning: narrowing conversion from 'double' to 'int' [cppcoreguidelines-narrowing-conversions]
18+
// CHECK-MESSAGES-DISABLED: :[[@LINE-2]]:11: warning: narrowing conversion from 'double' to 'int' [cppcoreguidelines-narrowing-conversions]
19+
}

0 commit comments

Comments
 (0)