Skip to content

Commit 01136cc

Browse files
committed
Merge from 'main' to 'sycl-web' (#3)
Also includes follow-up conflict resolution fix for 54cd04d. CONFLICT (content): Merge conflict in clang/include/clang/Driver/Options.td
2 parents 51fec43 + 22f1949 commit 01136cc

File tree

870 files changed

+11548
-2545
lines changed

Some content is hidden

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

870 files changed

+11548
-2545
lines changed

.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

.mailmap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
# Please keep this file sorted.
2424

2525
26+
2627
2728
2829
Jon Roelofs <[email protected]> Jon Roelofs <[email protected]>

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

Lines changed: 32 additions & 25 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",
@@ -294,34 +298,37 @@ void NarrowingConversionsCheck::handleIntegralCast(const ASTContext &Context,
294298
SourceLocation SourceLoc,
295299
const Expr &Lhs,
296300
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)
301+
if (WarnOnIntegerNarrowingConversion) {
302+
const BuiltinType *ToType = getBuiltinType(Lhs);
303+
// From [conv.integral]p7.3.8:
304+
// Conversions to unsigned integer is well defined so no warning is issued.
305+
// "The resulting value is the smallest unsigned value equal to the source
306+
// value modulo 2^n where n is the number of bits used to represent the
307+
// destination type."
308+
if (ToType->isUnsignedInteger())
313309
return;
314-
}
310+
const BuiltinType *FromType = getBuiltinType(Rhs);
315311

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;
312+
// With this option, we don't warn on conversions that have equivalent width
313+
// in bits. eg. uint32 <-> int32.
314+
if (!WarnOnEquivalentBitWidth) {
315+
uint64_t FromTypeSize = Context.getTypeSize(FromType);
316+
uint64_t ToTypeSize = Context.getTypeSize(ToType);
317+
if (FromTypeSize == ToTypeSize)
318+
return;
319+
}
320+
321+
llvm::APSInt IntegerConstant;
322+
if (getIntegerConstantExprValue(Context, Rhs, IntegerConstant)) {
323+
if (!isWideEnoughToHold(Context, IntegerConstant, *ToType))
324+
diagNarrowIntegerConstantToSignedInt(SourceLoc, Lhs, Rhs,
325+
IntegerConstant,
326+
Context.getTypeSize(FromType));
327+
return;
328+
}
329+
if (!isWideEnoughToHold(Context, *FromType, *ToType))
330+
diagNarrowTypeToSignedInt(SourceLoc, Lhs, Rhs);
322331
}
323-
if (!isWideEnoughToHold(Context, *FromType, *ToType))
324-
diagNarrowTypeToSignedInt(SourceLoc, Lhs, Rhs);
325332
}
326333

327334
void NarrowingConversionsCheck::handleIntegralToBoolean(

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

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

96+
const bool WarnOnIntegerNarrowingConversion;
9697
const bool WarnOnFloatingPointNarrowingConversion;
9798
const bool WarnWithinTemplateInstantiation;
9899
const bool WarnOnEquivalentBitWidth;

clang-tools-extra/clangd/unittests/SelectionTests.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -659,10 +659,11 @@ TEST(SelectionTest, CreateAll) {
659659
AST.getASTContext(), AST.getTokens(), Test.point("ambiguous"),
660660
Test.point("ambiguous"), [&](SelectionTree T) {
661661
// Expect to see the right-biased tree first.
662-
if (Seen == 0)
662+
if (Seen == 0) {
663663
EXPECT_EQ("BinaryOperator", nodeKind(T.commonAncestor()));
664-
else if (Seen == 1)
664+
} else if (Seen == 1) {
665665
EXPECT_EQ("IntegerLiteral", nodeKind(T.commonAncestor()));
666+
}
666667
++Seen;
667668
return false;
668669
});

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
@@ -13,7 +13,8 @@ Guidelines, corresponding to rule ES.46. See
1313
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#es46-avoid-lossy-narrowing-truncating-arithmetic-conversions.
1414

1515
We enforce only part of the guideline, more specifically, we flag narrowing conversions from:
16-
- an integer to a narrower integer (e.g. ``char`` to ``unsigned char``),
16+
- an integer to a narrower integer (e.g. ``char`` to ``unsigned char``)
17+
if WarnOnIntegerNarrowingConversion Option is set,
1718
- an integer to a narrower floating-point (e.g. ``uint64_t`` to ``float``),
1819
- a floating-point to an integer (e.g. ``double`` to ``int``),
1920
- a floating-point to a narrower floating-point (e.g. ``double`` to ``float``)
@@ -30,6 +31,11 @@ This check will flag:
3031
Options
3132
-------
3233

34+
.. option:: WarnOnIntegerNarrowingConversion
35+
36+
When `true`, the check will warn on narrowing integer conversion
37+
(e.g. ``int`` to ``size_t``). `true` by default.
38+
3339
.. option:: WarnOnFloatingPointNarrowingConversion
3440

3541
When `true`, the check will warn on narrowing floating point conversion
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// RUN: %check_clang_tidy -check-suffix=DEFAULT %s \
2+
// RUN: cppcoreguidelines-narrowing-conversions %t -- \
3+
// RUN: -config='{CheckOptions: [{key: cppcoreguidelines-narrowing-conversions.WarnOnIntegerNarrowingConversion, 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.WarnOnIntegerNarrowingConversion, value: false}]}'
8+
9+
void foo(unsigned long long value) {
10+
int a = value;
11+
// CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:11: warning: narrowing conversion from 'unsigned long long' to signed type 'int' is implementation-defined [cppcoreguidelines-narrowing-conversions]
12+
// DISABLED: No warning for integer narrowing conversions when WarnOnIntegerNarrowingConversion = false.
13+
long long b = value;
14+
// CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:17: warning: narrowing conversion from 'unsigned long long' to signed type 'long long' is implementation-defined [cppcoreguidelines-narrowing-conversions]
15+
// DISABLED: No warning for integer narrowing conversions when WarnOnIntegerNarrowingConversion = false.
16+
}
17+
18+
void casting_float_to_bool_is_still_operational_when_integer_narrowing_is_disabled(float f) {
19+
if (f) {
20+
// CHECK-MESSAGES-DEFAULT: :[[@LINE-1]]:7: warning: narrowing conversion from 'float' to 'bool' [cppcoreguidelines-narrowing-conversions]
21+
// CHECK-MESSAGES-DISABLED: :[[@LINE-2]]:7: warning: narrowing conversion from 'float' to 'bool' [cppcoreguidelines-narrowing-conversions]
22+
}
23+
}

clang/cmake/caches/Fuchsia-stage2.cmake

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,7 @@ if(WIN32)
3030
set(LLVM_USE_CRT_RELEASE "MT" CACHE STRING "")
3131
endif()
3232

33-
if(NOT WIN32)
34-
set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "")
35-
endif()
33+
set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "")
3634
if(NOT APPLE)
3735
# TODO: Remove this once we switch to ld64.lld.
3836
set(CLANG_DEFAULT_LINKER lld CACHE STRING "")

clang/cmake/caches/Fuchsia.cmake

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ if(WIN32)
2121
set(LLVM_USE_CRT_RELEASE "MT" CACHE STRING "")
2222
endif()
2323

24-
if(NOT WIN32)
25-
set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "")
26-
endif()
24+
set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "")
2725
if(NOT APPLE)
2826
# TODO: Remove this once we switch to ld64.lld.
2927
set(CLANG_DEFAULT_LINKER lld CACHE STRING "")

clang/include/clang-c/Index.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2588,7 +2588,11 @@ enum CXCursorKind {
25882588
*/
25892589
CXCursor_OMPMaskedDirective = 292,
25902590

2591-
CXCursor_LastStmt = CXCursor_OMPMaskedDirective,
2591+
/** OpenMP unroll directive.
2592+
*/
2593+
CXCursor_OMPUnrollDirective = 293,
2594+
2595+
CXCursor_LastStmt = CXCursor_OMPUnrollDirective,
25922596

25932597
/**
25942598
* Cursor that represents the translation unit itself.

clang/include/clang/AST/ComputeDependence.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ class OverloadExpr;
7171
class DependentScopeDeclRefExpr;
7272
class CXXConstructExpr;
7373
class CXXDefaultInitExpr;
74+
class CXXDefaultArgExpr;
7475
class LambdaExpr;
7576
class CXXUnresolvedConstructExpr;
7677
class CXXDependentScopeMemberExpr;
@@ -160,6 +161,7 @@ ExprDependence computeDependence(OverloadExpr *E, bool KnownDependent,
160161
ExprDependence computeDependence(DependentScopeDeclRefExpr *E);
161162
ExprDependence computeDependence(CXXConstructExpr *E);
162163
ExprDependence computeDependence(CXXDefaultInitExpr *E);
164+
ExprDependence computeDependence(CXXDefaultArgExpr *E);
163165
ExprDependence computeDependence(LambdaExpr *E,
164166
bool ContainsUnexpandedParameterPack);
165167
ExprDependence computeDependence(CXXUnresolvedConstructExpr *E);

clang/include/clang/AST/ExprCXX.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1257,7 +1257,7 @@ class CXXDefaultArgExpr final : public Expr {
12571257
Param->getDefaultArg()->getObjectKind()),
12581258
Param(Param), UsedContext(UsedContext) {
12591259
CXXDefaultArgExprBits.Loc = Loc;
1260-
setDependence(ExprDependence::None);
1260+
setDependence(computeDependence(this));
12611261
}
12621262

12631263
public:

clang/include/clang/AST/OpenMPClause.h

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -888,6 +888,114 @@ class OMPSizesClause final
888888
}
889889
};
890890

891+
/// Representation of the 'full' clause of the '#pragma omp unroll' directive.
892+
///
893+
/// \code
894+
/// #pragma omp unroll full
895+
/// for (int i = 0; i < 64; ++i)
896+
/// \endcode
897+
class OMPFullClause final : public OMPClause {
898+
friend class OMPClauseReader;
899+
900+
/// Build an empty clause.
901+
explicit OMPFullClause() : OMPClause(llvm::omp::OMPC_full, {}, {}) {}
902+
903+
public:
904+
/// Build an AST node for a 'full' clause.
905+
///
906+
/// \param C Context of the AST.
907+
/// \param StartLoc Starting location of the clause.
908+
/// \param EndLoc Ending location of the clause.
909+
static OMPFullClause *Create(const ASTContext &C, SourceLocation StartLoc,
910+
SourceLocation EndLoc);
911+
912+
/// Build an empty 'full' AST node for deserialization.
913+
///
914+
/// \param C Context of the AST.
915+
static OMPFullClause *CreateEmpty(const ASTContext &C);
916+
917+
child_range children() { return {child_iterator(), child_iterator()}; }
918+
const_child_range children() const {
919+
return {const_child_iterator(), const_child_iterator()};
920+
}
921+
922+
child_range used_children() {
923+
return child_range(child_iterator(), child_iterator());
924+
}
925+
const_child_range used_children() const {
926+
return const_child_range(const_child_iterator(), const_child_iterator());
927+
}
928+
929+
static bool classof(const OMPClause *T) {
930+
return T->getClauseKind() == llvm::omp::OMPC_full;
931+
}
932+
};
933+
934+
/// Representation of the 'partial' clause of the '#pragma omp unroll'
935+
/// directive.
936+
///
937+
/// \code
938+
/// #pragma omp unroll partial(4)
939+
/// for (int i = start; i < end; ++i)
940+
/// \endcode
941+
class OMPPartialClause final : public OMPClause {
942+
friend class OMPClauseReader;
943+
944+
/// Location of '('.
945+
SourceLocation LParenLoc;
946+
947+
/// Optional argument to the clause (unroll factor).
948+
Stmt *Factor;
949+
950+
/// Build an empty clause.
951+
explicit OMPPartialClause() : OMPClause(llvm::omp::OMPC_partial, {}, {}) {}
952+
953+
/// Set the unroll factor.
954+
void setFactor(Expr *E) { Factor = E; }
955+
956+
/// Sets the location of '('.
957+
void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
958+
959+
public:
960+
/// Build an AST node for a 'partial' clause.
961+
///
962+
/// \param C Context of the AST.
963+
/// \param StartLoc Location of the 'partial' identifier.
964+
/// \param LParenLoc Location of '('.
965+
/// \param EndLoc Location of ')'.
966+
/// \param Factor Clause argument.
967+
static OMPPartialClause *Create(const ASTContext &C, SourceLocation StartLoc,
968+
SourceLocation LParenLoc,
969+
SourceLocation EndLoc, Expr *Factor);
970+
971+
/// Build an empty 'partial' AST node for deserialization.
972+
///
973+
/// \param C Context of the AST.
974+
static OMPPartialClause *CreateEmpty(const ASTContext &C);
975+
976+
/// Returns the location of '('.
977+
SourceLocation getLParenLoc() const { return LParenLoc; }
978+
979+
/// Returns the argument of the clause or nullptr if not set.
980+
Expr *getFactor() const { return cast_or_null<Expr>(Factor); }
981+
982+
child_range children() { return child_range(&Factor, &Factor + 1); }
983+
const_child_range children() const {
984+
return const_child_range(&Factor, &Factor + 1);
985+
}
986+
987+
child_range used_children() {
988+
return child_range(child_iterator(), child_iterator());
989+
}
990+
const_child_range used_children() const {
991+
return const_child_range(const_child_iterator(), const_child_iterator());
992+
}
993+
994+
static bool classof(const OMPClause *T) {
995+
return T->getClauseKind() == llvm::omp::OMPC_partial;
996+
}
997+
};
998+
891999
/// This represents 'collapse' clause in the '#pragma omp ...'
8921000
/// directive.
8931001
///

clang/include/clang/AST/RecursiveASTVisitor.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2855,6 +2855,9 @@ DEF_TRAVERSE_STMT(OMPSimdDirective,
28552855
DEF_TRAVERSE_STMT(OMPTileDirective,
28562856
{ TRY_TO(TraverseOMPExecutableDirective(S)); })
28572857

2858+
DEF_TRAVERSE_STMT(OMPUnrollDirective,
2859+
{ TRY_TO(TraverseOMPExecutableDirective(S)); })
2860+
28582861
DEF_TRAVERSE_STMT(OMPForDirective,
28592862
{ TRY_TO(TraverseOMPExecutableDirective(S)); })
28602863

@@ -3111,6 +3114,17 @@ bool RecursiveASTVisitor<Derived>::VisitOMPSizesClause(OMPSizesClause *C) {
31113114
return true;
31123115
}
31133116

3117+
template <typename Derived>
3118+
bool RecursiveASTVisitor<Derived>::VisitOMPFullClause(OMPFullClause *C) {
3119+
return true;
3120+
}
3121+
3122+
template <typename Derived>
3123+
bool RecursiveASTVisitor<Derived>::VisitOMPPartialClause(OMPPartialClause *C) {
3124+
TRY_TO(TraverseStmt(C->getFactor()));
3125+
return true;
3126+
}
3127+
31143128
template <typename Derived>
31153129
bool
31163130
RecursiveASTVisitor<Derived>::VisitOMPCollapseClause(OMPCollapseClause *C) {

0 commit comments

Comments
 (0)