Skip to content

Commit 3e7dbda

Browse files
Merge remote-tracking branch 'intel_llvm/sycl' into constexprrec2
2 parents 6fd33a9 + 808b38d commit 3e7dbda

File tree

5,934 files changed

+234014
-142206
lines changed

Some content is hidden

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

5,934 files changed

+234014
-142206
lines changed

.clang-tidy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Checks: '-*,clang-diagnostic-*,llvm-*,misc-*,-misc-unused-parameters,-misc-non-private-member-variables-in-classes,readability-identifier-naming'
1+
Checks: '-*,clang-diagnostic-*,llvm-*,misc-*,-misc-unused-parameters,-misc-non-private-member-variables-in-classes,-misc-no-recursion,readability-identifier-naming'
22
CheckOptions:
33
- key: readability-identifier-naming.ClassCase
44
value: CamelCase

.git-blame-ignore-revs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,6 @@ d8f0e6caa91e230a486c948ab643174e40bdf215
4040

4141
# Wiped out some non-ascii characters that snuck into the copyright.
4242
5b08a8a43254ed30bd953e869b0fd9fc1e8b82d0
43+
44+
# Use C++11 default member initializers in LLDB. NFC.
45+
9494c510af56d9c8593ab69017dcaa232210b235

.github/workflows/gh_pages.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@ jobs:
2424
python $GITHUB_WORKSPACE/repo/buildbot/configure.py -w $GITHUB_WORKSPACE \
2525
-s $GITHUB_WORKSPACE/repo -o $GITHUB_WORKSPACE/build -t Release --docs
2626
cmake --build . --target doxygen-sycl
27+
cmake --build . --target doxygen-clang
2728
cmake --build . --target docs-sycl-html
29+
cmake --build . --target docs-clang-html
2830
- name: Deploy
2931
env:
3032
SSH_KEY: ${{secrets.ACTIONS_DEPLOY_KEY}}
@@ -39,8 +41,9 @@ jobs:
3941
git rm -rf .
4042
touch .nojekyll
4143
yes | \cp -rf $GITHUB_WORKSPACE/build/tools/sycl/doc/html/* .
42-
mkdir doxygen
43-
yes | \cp -rf $GITHUB_WORKSPACE/build/tools/sycl/doc/doxygen/html/* doxygen/
44+
mv $GITHUB_WORKSPACE/build/tools/sycl/doc/doxygen/html doxygen/
45+
mv $GITHUB_WORKSPACE/build/tools/clang/docs/html clang/
46+
mv $GITHUB_WORKSPACE/build/tools/clang/docs/doxygen/html clang_doxygen/
4447
git config --global user.name "iclsrc"
4548
git config --global user.email "[email protected]"
4649
git add .

.mailmap

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# This file allows mapping several author and committer email addresses and
2+
# names to a single canonical one for `git shortlog`, `git log --author`,
3+
# or `git check-mailmap`.
4+
#
5+
# For example, if you commit as `[email protected]` but sometimes use
6+
# "Rañdom Person" and sometimes "Random Person" as name and you want the former
7+
# to be your canonical name, add
8+
#
9+
# Rañdom Person <[email protected]>
10+
#
11+
# If you commit as both `[email protected]` and `[email protected]` and
12+
# you want the former to be your canonical email address, add
13+
#
14+
15+
#
16+
# Combinations of both are possible too, see
17+
# https://git-scm.com/docs/gitmailmap for format details.
18+
#
19+
# You can commit changes for your own names and email addresses without review.
20+
# If you want to add entries for other people, please have them review the
21+
# addition.
22+
#
23+
# Please keep this file sorted.
24+
25+
26+
27+
28+
29+
Jon Roelofs <[email protected]> Jon Roelofs <[email protected]>
30+
Jon Roelofs <[email protected]> Jonathan Roelofs <[email protected]>
31+
Jon Roelofs <[email protected]> Jonathan Roelofs <[email protected]>
32+
Martin Storsjö <[email protected]>

buildbot/configure.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ def do_configure(args):
2525
llvm_enable_projects = 'clang;' + llvm_external_projects
2626
libclc_targets_to_build = ''
2727
sycl_build_pi_cuda = 'OFF'
28+
sycl_build_pi_esimd_cpu = 'ON'
2829
sycl_werror = 'ON'
2930
llvm_enable_assertions = 'ON'
3031
llvm_enable_doxygen = 'OFF'
@@ -44,6 +45,9 @@ def do_configure(args):
4445
libclc_targets_to_build = 'nvptx64--;nvptx64--nvidiacl'
4546
sycl_build_pi_cuda = 'ON'
4647

48+
if args.disable_esimd_cpu:
49+
sycl_build_pi_esimd_cpu = 'OFF'
50+
4751
if args.no_werror:
4852
sycl_werror = 'OFF'
4953

@@ -86,7 +90,8 @@ def do_configure(args):
8690
"-DLLVM_ENABLE_SPHINX={}".format(llvm_enable_sphinx),
8791
"-DBUILD_SHARED_LIBS={}".format(llvm_build_shared_libs),
8892
"-DSYCL_ENABLE_XPTI_TRACING={}".format(sycl_enable_xpti_tracing),
89-
"-DLLVM_ENABLE_LLD={}".format(llvm_enable_lld)
93+
"-DLLVM_ENABLE_LLD={}".format(llvm_enable_lld),
94+
"-DSYCL_BUILD_PI_ESIMD_CPU={}".format(sycl_build_pi_esimd_cpu)
9095
]
9196

9297
if args.l0_headers and args.l0_loader:
@@ -147,6 +152,7 @@ def main():
147152
metavar="BUILD_TYPE", default="Release", help="build type: Debug, Release")
148153
parser.add_argument("--cuda", action='store_true', help="switch from OpenCL to CUDA")
149154
parser.add_argument("--arm", action='store_true', help="build ARM support rather than x86")
155+
parser.add_argument("--disable-esimd-cpu", action='store_true', help="build without ESIMD_CPU support")
150156
parser.add_argument("--no-assertions", action='store_true', help="build without assertions")
151157
parser.add_argument("--docs", action='store_true', help="build Doxygen documentation")
152158
parser.add_argument("--no-werror", action='store_true', help="Don't treat warnings as errors")

clang-tools-extra/clang-tidy/abseil/DurationRewriter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ stripFloatLiteralFraction(const MatchFinder::MatchResult &Result,
208208
if (const auto *LitFloat = llvm::dyn_cast<FloatingLiteral>(&Node))
209209
// Attempt to simplify a `Duration` factory call with a literal argument.
210210
if (llvm::Optional<llvm::APSInt> IntValue = truncateIfIntegral(*LitFloat))
211-
return IntValue->toString(/*radix=*/10);
211+
return toString(*IntValue, /*radix=*/10);
212212

213213
return llvm::None;
214214
}

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

Lines changed: 81 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ auto hasAnyListedName(const std::string &Names) {
3535
NarrowingConversionsCheck::NarrowingConversionsCheck(StringRef Name,
3636
ClangTidyContext *Context)
3737
: ClangTidyCheck(Name, Context),
38+
WarnOnIntegerNarrowingConversion(
39+
Options.get("WarnOnIntegerNarrowingConversion", true)),
3840
WarnOnFloatingPointNarrowingConversion(
3941
Options.get("WarnOnFloatingPointNarrowingConversion", true)),
4042
WarnWithinTemplateInstantiation(
@@ -45,6 +47,8 @@ NarrowingConversionsCheck::NarrowingConversionsCheck(StringRef Name,
4547

4648
void NarrowingConversionsCheck::storeOptions(
4749
ClangTidyOptions::OptionMap &Opts) {
50+
Options.store(Opts, "WarnOnIntegerNarrowingConversion",
51+
WarnOnIntegerNarrowingConversion);
4852
Options.store(Opts, "WarnOnFloatingPointNarrowingConversion",
4953
WarnOnFloatingPointNarrowingConversion);
5054
Options.store(Opts, "WarnWithinTemplateInstantiation",
@@ -67,8 +71,9 @@ void NarrowingConversionsCheck::registerMatchers(MatchFinder *Finder) {
6771
hasType(namedDecl(hasAnyListedName(IgnoreConversionFromTypes)));
6872

6973
// `IsConversionFromIgnoredType` will ignore narrowing calls from those types,
70-
// but not expressions that are promoted to `int64` due to a binary expression
71-
// with one of those types. For example, it will continue to reject:
74+
// but not expressions that are promoted to an ignored type as a result of a
75+
// binary expression with one of those types.
76+
// For example, it will continue to reject:
7277
// `int narrowed = int_value + container.size()`.
7378
// We attempt to address common incidents of compound expressions with
7479
// `IsIgnoredTypeTwoLevelsDeep`, allowing binary expressions that have one
@@ -217,6 +222,22 @@ static bool isWideEnoughToHold(const ASTContext &Context,
217222
return ToIntegerRange.contains(IntegerConstant);
218223
}
219224

225+
// Returns true iff the floating point constant can be losslessly represented
226+
// by an integer in the given destination type. eg. 2.0 can be accurately
227+
// represented by an int32_t, but neither 2^33 nor 2.001 can.
228+
static bool isFloatExactlyRepresentable(const ASTContext &Context,
229+
const llvm::APFloat &FloatConstant,
230+
const QualType &DestType) {
231+
unsigned DestWidth = Context.getIntWidth(DestType);
232+
bool DestSigned = DestType->isSignedIntegerOrEnumerationType();
233+
llvm::APSInt Result = llvm::APSInt(DestWidth, !DestSigned);
234+
bool IsExact = false;
235+
bool Overflows = FloatConstant.convertToInteger(
236+
Result, llvm::APFloat::rmTowardZero, &IsExact) &
237+
llvm::APFloat::opInvalidOp;
238+
return !Overflows && IsExact;
239+
}
240+
220241
static llvm::SmallString<64> getValueAsString(const llvm::APSInt &Value,
221242
uint64_t HexBits) {
222243
llvm::SmallString<64> Str;
@@ -233,6 +254,21 @@ static llvm::SmallString<64> getValueAsString(const llvm::APSInt &Value,
233254
return Str;
234255
}
235256

257+
bool NarrowingConversionsCheck::isWarningInhibitedByEquivalentSize(
258+
const ASTContext &Context, const BuiltinType &FromType,
259+
const BuiltinType &ToType) const {
260+
// With this option, we don't warn on conversions that have equivalent width
261+
// in bits. eg. uint32 <-> int32.
262+
if (!WarnOnEquivalentBitWidth) {
263+
uint64_t FromTypeSize = Context.getTypeSize(&FromType);
264+
uint64_t ToTypeSize = Context.getTypeSize(&ToType);
265+
if (FromTypeSize == ToTypeSize) {
266+
return true;
267+
}
268+
}
269+
return false;
270+
}
271+
236272
void NarrowingConversionsCheck::diagNarrowType(SourceLocation SourceLoc,
237273
const Expr &Lhs,
238274
const Expr &Rhs) {
@@ -294,34 +330,37 @@ void NarrowingConversionsCheck::handleIntegralCast(const ASTContext &Context,
294330
SourceLocation SourceLoc,
295331
const Expr &Lhs,
296332
const Expr &Rhs) {
297-
const BuiltinType *ToType = getBuiltinType(Lhs);
298-
// From [conv.integral]p7.3.8:
299-
// Conversions to unsigned integer is well defined so no warning is issued.
300-
// "The resulting value is the smallest unsigned value equal to the source
301-
// value modulo 2^n where n is the number of bits used to represent the
302-
// destination type."
303-
if (ToType->isUnsignedInteger())
304-
return;
305-
const BuiltinType *FromType = getBuiltinType(Rhs);
306-
307-
// With this option, we don't warn on conversions that have equivalent width
308-
// in bits. eg. uint32 <-> int32.
309-
if (!WarnOnEquivalentBitWidth) {
310-
uint64_t FromTypeSize = Context.getTypeSize(FromType);
311-
uint64_t ToTypeSize = Context.getTypeSize(ToType);
312-
if (FromTypeSize == ToTypeSize)
333+
if (WarnOnIntegerNarrowingConversion) {
334+
const BuiltinType *ToType = getBuiltinType(Lhs);
335+
// From [conv.integral]p7.3.8:
336+
// Conversions to unsigned integer is well defined so no warning is issued.
337+
// "The resulting value is the smallest unsigned value equal to the source
338+
// value modulo 2^n where n is the number of bits used to represent the
339+
// destination type."
340+
if (ToType->isUnsignedInteger())
313341
return;
314-
}
342+
const BuiltinType *FromType = getBuiltinType(Rhs);
315343

316-
llvm::APSInt IntegerConstant;
317-
if (getIntegerConstantExprValue(Context, Rhs, IntegerConstant)) {
318-
if (!isWideEnoughToHold(Context, IntegerConstant, *ToType))
319-
diagNarrowIntegerConstantToSignedInt(SourceLoc, Lhs, Rhs, IntegerConstant,
320-
Context.getTypeSize(FromType));
321-
return;
344+
// With this option, we don't warn on conversions that have equivalent width
345+
// in bits. eg. uint32 <-> int32.
346+
if (!WarnOnEquivalentBitWidth) {
347+
uint64_t FromTypeSize = Context.getTypeSize(FromType);
348+
uint64_t ToTypeSize = Context.getTypeSize(ToType);
349+
if (FromTypeSize == ToTypeSize)
350+
return;
351+
}
352+
353+
llvm::APSInt IntegerConstant;
354+
if (getIntegerConstantExprValue(Context, Rhs, IntegerConstant)) {
355+
if (!isWideEnoughToHold(Context, IntegerConstant, *ToType))
356+
diagNarrowIntegerConstantToSignedInt(SourceLoc, Lhs, Rhs,
357+
IntegerConstant,
358+
Context.getTypeSize(FromType));
359+
return;
360+
}
361+
if (!isWideEnoughToHold(Context, *FromType, *ToType))
362+
diagNarrowTypeToSignedInt(SourceLoc, Lhs, Rhs);
322363
}
323-
if (!isWideEnoughToHold(Context, *FromType, *ToType))
324-
diagNarrowTypeToSignedInt(SourceLoc, Lhs, Rhs);
325364
}
326365

327366
void NarrowingConversionsCheck::handleIntegralToBoolean(
@@ -344,7 +383,10 @@ void NarrowingConversionsCheck::handleIntegralToFloating(
344383
diagNarrowIntegerConstant(SourceLoc, Lhs, Rhs, IntegerConstant);
345384
return;
346385
}
386+
347387
const BuiltinType *FromType = getBuiltinType(Rhs);
388+
if (isWarningInhibitedByEquivalentSize(Context, *FromType, *ToType))
389+
return;
348390
if (!isWideEnoughToHold(Context, *FromType, *ToType))
349391
diagNarrowType(SourceLoc, Lhs, Rhs);
350392
}
@@ -353,25 +395,21 @@ void NarrowingConversionsCheck::handleFloatingToIntegral(
353395
const ASTContext &Context, SourceLocation SourceLoc, const Expr &Lhs,
354396
const Expr &Rhs) {
355397
llvm::APFloat FloatConstant(0.0);
398+
if (getFloatingConstantExprValue(Context, Rhs, FloatConstant)) {
399+
if (!isFloatExactlyRepresentable(Context, FloatConstant, Lhs.getType()))
400+
return diagNarrowConstant(SourceLoc, Lhs, Rhs);
356401

357-
// We always warn when Rhs is non-constexpr.
358-
if (!getFloatingConstantExprValue(Context, Rhs, FloatConstant))
359-
return diagNarrowType(SourceLoc, Lhs, Rhs);
402+
if (PedanticMode)
403+
return diagConstantCast(SourceLoc, Lhs, Rhs);
360404

361-
QualType DestType = Lhs.getType();
362-
unsigned DestWidth = Context.getIntWidth(DestType);
363-
bool DestSigned = DestType->isSignedIntegerOrEnumerationType();
364-
llvm::APSInt Result = llvm::APSInt(DestWidth, !DestSigned);
365-
bool IsExact = false;
366-
bool Overflows = FloatConstant.convertToInteger(
367-
Result, llvm::APFloat::rmTowardZero, &IsExact) &
368-
llvm::APFloat::opInvalidOp;
369-
// We warn iff the constant floating point value is not exactly representable.
370-
if (Overflows || !IsExact)
371-
return diagNarrowConstant(SourceLoc, Lhs, Rhs);
405+
return;
406+
}
372407

373-
if (PedanticMode)
374-
return diagConstantCast(SourceLoc, Lhs, Rhs);
408+
const BuiltinType *FromType = getBuiltinType(Rhs);
409+
const BuiltinType *ToType = getBuiltinType(Lhs);
410+
if (isWarningInhibitedByEquivalentSize(Context, *FromType, *ToType))
411+
return;
412+
diagNarrowType(SourceLoc, Lhs, Rhs); // Assumed always lossy.
375413
}
376414

377415
void NarrowingConversionsCheck::handleFloatingToBoolean(

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,11 @@ class NarrowingConversionsCheck : public ClangTidyCheck {
9393
void handleBinaryOperator(const ASTContext &Context,
9494
const BinaryOperator &Op);
9595

96+
bool isWarningInhibitedByEquivalentSize(const ASTContext &Context,
97+
const BuiltinType &FromType,
98+
const BuiltinType &ToType) const;
99+
100+
const bool WarnOnIntegerNarrowingConversion;
96101
const bool WarnOnFloatingPointNarrowingConversion;
97102
const bool WarnWithinTemplateInstantiation;
98103
const bool WarnOnEquivalentBitWidth;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ void ProBoundsConstantArrayIndexCheck::check(
9999

100100
if (Index->isSigned() && Index->isNegative()) {
101101
diag(Matched->getExprLoc(), "std::array<> index %0 is negative")
102-
<< Index->toString(10);
102+
<< toString(*Index, 10);
103103
return;
104104
}
105105

@@ -118,7 +118,7 @@ void ProBoundsConstantArrayIndexCheck::check(
118118
diag(Matched->getExprLoc(),
119119
"std::array<> index %0 is past the end of the array "
120120
"(which contains %1 elements)")
121-
<< Index->toString(10) << ArraySize.toString(10, false);
121+
<< toString(*Index, 10) << toString(ArraySize, 10, false);
122122
}
123123
}
124124

clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -27,37 +27,48 @@ StaticAssertCheck::StaticAssertCheck(StringRef Name, ClangTidyContext *Context)
2727
: ClangTidyCheck(Name, Context) {}
2828

2929
void StaticAssertCheck::registerMatchers(MatchFinder *Finder) {
30-
auto NegatedString =
31-
unaryOperator(hasOperatorName("!"), hasUnaryOperand(stringLiteral()));
30+
auto NegatedString = unaryOperator(
31+
hasOperatorName("!"), hasUnaryOperand(ignoringImpCasts(stringLiteral())));
3232
auto IsAlwaysFalse =
3333
expr(anyOf(cxxBoolLiteral(equals(false)), integerLiteral(equals(0)),
3434
cxxNullPtrLiteralExpr(), gnuNullExpr(), NegatedString))
3535
.bind("isAlwaysFalse");
36-
auto IsAlwaysFalseWithCast =
37-
anyOf(IsAlwaysFalse, cStyleCastExpr(has(IsAlwaysFalse)).bind("castExpr"));
38-
auto AssertExprRoot =
39-
anyOf(binaryOperator(
40-
hasAnyOperatorName("&&", "=="),
41-
hasEitherOperand(stringLiteral().bind("assertMSG")),
42-
anyOf(binaryOperator(hasEitherOperand(IsAlwaysFalseWithCast)),
43-
anything()))
44-
.bind("assertExprRoot"),
45-
IsAlwaysFalse);
36+
auto IsAlwaysFalseWithCast = ignoringParenImpCasts(anyOf(
37+
IsAlwaysFalse, cStyleCastExpr(has(ignoringParenImpCasts(IsAlwaysFalse)))
38+
.bind("castExpr")));
39+
auto AssertExprRoot = anyOf(
40+
binaryOperator(
41+
hasAnyOperatorName("&&", "=="),
42+
hasEitherOperand(ignoringImpCasts(stringLiteral().bind("assertMSG"))),
43+
anyOf(binaryOperator(hasEitherOperand(IsAlwaysFalseWithCast)),
44+
anything()))
45+
.bind("assertExprRoot"),
46+
IsAlwaysFalse);
4647
auto NonConstexprFunctionCall =
4748
callExpr(hasDeclaration(functionDecl(unless(isConstexpr()))));
4849
auto AssertCondition =
49-
expr(optionally(expr(anyOf(AssertExprRoot,
50-
unaryOperator(hasUnaryOperand(AssertExprRoot))))),
51-
unless(findAll(NonConstexprFunctionCall)))
50+
expr(
51+
anyOf(expr(ignoringParenCasts(anyOf(
52+
AssertExprRoot, unaryOperator(hasUnaryOperand(
53+
ignoringParenCasts(AssertExprRoot)))))),
54+
anything()),
55+
unless(findAll(NonConstexprFunctionCall)))
5256
.bind("condition");
5357
auto Condition =
54-
anyOf(callExpr(traverse(TK_AsIs, callExpr(hasDeclaration(functionDecl(
55-
hasName("__builtin_expect"))))),
56-
hasArgument(0, AssertCondition)),
58+
anyOf(ignoringParenImpCasts(callExpr(
59+
hasDeclaration(functionDecl(hasName("__builtin_expect"))),
60+
hasArgument(0, AssertCondition))),
5761
AssertCondition);
5862

63+
Finder->addMatcher(conditionalOperator(hasCondition(Condition),
64+
unless(isInTemplateInstantiation()))
65+
.bind("condStmt"),
66+
this);
67+
5968
Finder->addMatcher(
60-
mapAnyOf(ifStmt, conditionalOperator).with(hasCondition(Condition)).bind("condStmt"), this);
69+
ifStmt(hasCondition(Condition), unless(isInTemplateInstantiation()))
70+
.bind("condStmt"),
71+
this);
6172
}
6273

6374
void StaticAssertCheck::check(const MatchFinder::MatchResult &Result) {

0 commit comments

Comments
 (0)