Skip to content

Commit 6a09035

Browse files
committed
merge main into amd-staging
Change-Id: I5db306ee623039204961e02ae59145f4df84029c
2 parents 41eecb2 + 2205d23 commit 6a09035

File tree

55 files changed

+5156
-5381
lines changed

Some content is hidden

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

55 files changed

+5156
-5381
lines changed

clang/include/clang/Basic/DiagnosticGroups.td

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,8 @@ def CXX98CompatPedantic : DiagGroup<"c++98-compat-pedantic",
348348
CXXPre20CompatPedantic,
349349
CXXPre23CompatPedantic]>;
350350

351-
def CXX11Narrowing : DiagGroup<"c++11-narrowing">;
351+
def CXX11NarrowingConstReference : DiagGroup<"c++11-narrowing-const-reference">;
352+
def CXX11Narrowing : DiagGroup<"c++11-narrowing", [CXX11NarrowingConstReference]>;
352353

353354
def CXX11WarnInconsistentOverrideDestructor :
354355
DiagGroup<"inconsistent-missing-destructor-override">;

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6158,12 +6158,24 @@ def err_illegal_initializer_type : Error<"illegal initializer type %0">;
61586158
def ext_init_list_type_narrowing : ExtWarn<
61596159
"type %0 cannot be narrowed to %1 in initializer list">,
61606160
InGroup<CXX11Narrowing>, DefaultError, SFINAEFailure;
6161+
// *_narrowing_const_reference diagnostics have the same messages, but are
6162+
// controlled by -Wc++11-narrowing-const-reference for narrowing involving a
6163+
// const reference.
6164+
def ext_init_list_type_narrowing_const_reference : ExtWarn<
6165+
"type %0 cannot be narrowed to %1 in initializer list">,
6166+
InGroup<CXX11NarrowingConstReference>, DefaultError, SFINAEFailure;
61616167
def ext_init_list_variable_narrowing : ExtWarn<
61626168
"non-constant-expression cannot be narrowed from type %0 to %1 in "
61636169
"initializer list">, InGroup<CXX11Narrowing>, DefaultError, SFINAEFailure;
6170+
def ext_init_list_variable_narrowing_const_reference : ExtWarn<
6171+
"non-constant-expression cannot be narrowed from type %0 to %1 in "
6172+
"initializer list">, InGroup<CXX11NarrowingConstReference>, DefaultError, SFINAEFailure;
61646173
def ext_init_list_constant_narrowing : ExtWarn<
61656174
"constant expression evaluates to %0 which cannot be narrowed to type %1">,
61666175
InGroup<CXX11Narrowing>, DefaultError, SFINAEFailure;
6176+
def ext_init_list_constant_narrowing_const_reference : ExtWarn<
6177+
"constant expression evaluates to %0 which cannot be narrowed to type %1">,
6178+
InGroup<CXX11NarrowingConstReference>, DefaultError, SFINAEFailure;
61676179
def warn_init_list_type_narrowing : Warning<
61686180
"type %0 cannot be narrowed to %1 in initializer list in C++11">,
61696181
InGroup<CXX11Narrowing>, DefaultIgnore;

clang/lib/APINotes/APINotesManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ APINotesManager::loadAPINotes(StringRef Buffer) {
125125

126126
bool APINotesManager::loadAPINotes(const DirectoryEntry *HeaderDir,
127127
FileEntryRef APINotesFile) {
128-
assert(Readers.find(HeaderDir) == Readers.end());
128+
assert(!Readers.contains(HeaderDir));
129129
if (auto Reader = loadAPINotes(APINotesFile)) {
130130
Readers[HeaderDir] = Reader.release();
131131
return false;

clang/lib/Sema/SemaInit.cpp

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5512,14 +5512,6 @@ static void TryOrBuildParenListInitialization(
55125512
} else if (auto *RT = Entity.getType()->getAs<RecordType>()) {
55135513
bool IsUnion = RT->isUnionType();
55145514
const CXXRecordDecl *RD = cast<CXXRecordDecl>(RT->getDecl());
5515-
if (RD->isInvalidDecl()) {
5516-
// Exit early to avoid confusion when processing members.
5517-
// We do the same for braced list initialization in
5518-
// `CheckStructUnionTypes`.
5519-
Sequence.SetFailed(
5520-
clang::InitializationSequence::FK_ParenthesizedListInitFailed);
5521-
return;
5522-
}
55235515

55245516
if (!IsUnion) {
55255517
for (const CXXBaseSpecifier &Base : RD->bases()) {
@@ -10411,40 +10403,53 @@ static void DiagnoseNarrowingInInitList(Sema &S,
1041110403
// No narrowing occurred.
1041210404
return;
1041310405

10414-
case NK_Type_Narrowing:
10406+
case NK_Type_Narrowing: {
1041510407
// This was a floating-to-integer conversion, which is always considered a
1041610408
// narrowing conversion even if the value is a constant and can be
1041710409
// represented exactly as an integer.
10418-
S.Diag(PostInit->getBeginLoc(), NarrowingErrs(S.getLangOpts())
10419-
? diag::ext_init_list_type_narrowing
10420-
: diag::warn_init_list_type_narrowing)
10410+
QualType T = EntityType.getNonReferenceType();
10411+
S.Diag(PostInit->getBeginLoc(),
10412+
NarrowingErrs(S.getLangOpts())
10413+
? (T == EntityType
10414+
? diag::ext_init_list_type_narrowing
10415+
: diag::ext_init_list_type_narrowing_const_reference)
10416+
: diag::warn_init_list_type_narrowing)
1042110417
<< PostInit->getSourceRange()
1042210418
<< PreNarrowingType.getLocalUnqualifiedType()
10423-
<< EntityType.getNonReferenceType().getLocalUnqualifiedType();
10419+
<< T.getLocalUnqualifiedType();
1042410420
break;
10421+
}
1042510422

10426-
case NK_Constant_Narrowing:
10423+
case NK_Constant_Narrowing: {
1042710424
// A constant value was narrowed.
10425+
QualType T = EntityType.getNonReferenceType();
1042810426
S.Diag(PostInit->getBeginLoc(),
1042910427
NarrowingErrs(S.getLangOpts())
10430-
? diag::ext_init_list_constant_narrowing
10428+
? (T == EntityType
10429+
? diag::ext_init_list_constant_narrowing
10430+
: diag::ext_init_list_constant_narrowing_const_reference)
1043110431
: diag::warn_init_list_constant_narrowing)
1043210432
<< PostInit->getSourceRange()
1043310433
<< ConstantValue.getAsString(S.getASTContext(), ConstantType)
1043410434
<< EntityType.getNonReferenceType().getLocalUnqualifiedType();
1043510435
break;
10436+
}
1043610437

10437-
case NK_Variable_Narrowing:
10438+
case NK_Variable_Narrowing: {
1043810439
// A variable's value may have been narrowed.
10440+
QualType T = EntityType.getNonReferenceType();
1043910441
S.Diag(PostInit->getBeginLoc(),
1044010442
NarrowingErrs(S.getLangOpts())
10441-
? diag::ext_init_list_variable_narrowing
10443+
? (T == EntityType
10444+
? diag::ext_init_list_variable_narrowing
10445+
: diag::ext_init_list_variable_narrowing_const_reference)
1044210446
: diag::warn_init_list_variable_narrowing)
1044310447
<< PostInit->getSourceRange()
1044410448
<< PreNarrowingType.getLocalUnqualifiedType()
1044510449
<< EntityType.getNonReferenceType().getLocalUnqualifiedType();
1044610450
break;
1044710451
}
10452+
}
1044810453

1044910454
SmallString<128> StaticCast;
1045010455
llvm::raw_svector_ostream OS(StaticCast);

clang/test/CXX/dcl.decl/dcl.init/dcl.init.list/p7-0x.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
// RUN: %clang_cc1 -fsyntax-only -std=c++11 -triple x86_64-apple-macosx10.6.7 -verify %s
2+
// The following narrowing does not involve const references, so
3+
// -Wno-c++11-narrowing-const-reference does not suppress the errors.
4+
// RUN: %clang_cc1 -fsyntax-only -std=c++11 -triple x86_64-apple-macosx10.6.7 -Wno-c++11-narrowing-const-reference -verify %s
25

36
// Verify that narrowing conversions in initializer lists cause errors in C++0x
47
// mode.

clang/test/SemaCXX/GH63151.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
// RUN: %clang_cc1 -fsyntax-only -verify %s
2-
1+
// RUN: %clang_cc1 -fsyntax-only -verify=expected,narrowing %s
2+
// RUN: %clang_cc1 -fsyntax-only -Wno-c++11-narrowing-const-reference -verify %s
33

44
struct A { A(const unsigned &x) {} };
55

66
void foo(int p) {
7-
A a { -1 }; // expected-error {{constant expression evaluates to -1 which cannot be narrowed to type 'unsigned int'}}
7+
A a { -1 }; // narrowing-error {{constant expression evaluates to -1 which cannot be narrowed to type 'unsigned int'}}
88
A b { 0 };
9-
A c { p }; // expected-error {{non-constant-expression cannot be narrowed from type 'int' to 'unsigned int' in initializer list}}
10-
A d { 0.5 }; // expected-error {{type 'double' cannot be narrowed to 'unsigned int' in initializer list}}
9+
A c { p }; // narrowing-error {{non-constant-expression cannot be narrowed from type 'int' to 'unsigned int' in initializer list}}
10+
A d { 0.5 }; // narrowing-error {{type 'double' cannot be narrowed to 'unsigned int' in initializer list}}
1111
// expected-warning@-1 {{implicit conversion from 'double' to 'unsigned int' changes value from 0.5 to 0}}
1212
}

clang/test/SemaCXX/crash-GH76228.cpp

Lines changed: 0 additions & 28 deletions
This file was deleted.

clang/test/SemaCXX/paren-list-agg-init.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ int test() {
289289
// used to crash
290290
S a(0, 1);
291291
S b(0);
292-
S c(0, 0, 1);
292+
S c(0, 0, 1); // beforecxx20-warning {{aggregate initialization of type 'S' from a parenthesized list of values is a C++20 extension}}
293293

294294
S d {0, 1};
295295
S e {0};

compiler-rt/test/hwasan/TestCases/strip_path_prefix.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
// RUN: %clang_hwasan -O0 %s -o %t && %env_hwasan_opts=strip_path_prefix=/TestCases/ not %run %t 2>&1 | FileCheck %s
1+
// RUN: %clang_hwasan -O0 -g %s -o %t && %env_hwasan_opts=strip_path_prefix=/TestCases/ not %run %t 2>&1 | FileCheck %s
22

33
// Stack histories currently are not recorded on x86.
44
// XFAIL: target=x86_64{{.*}}
55

6-
// FIXME: Android does not see a variable.
7-
// XFAIL: android
8-
96
#include <assert.h>
107
#include <sanitizer/hwasan_interface.h>
118
#include <stdio.h>

flang/lib/Lower/OpenMP.cpp

Lines changed: 74 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,12 @@ class ClauseProcessor {
607607
llvm::SmallVectorImpl<const Fortran::semantics::Symbol *>
608608
&useDeviceSymbols) const;
609609

610+
template <typename T>
611+
bool
612+
processMotionClauses(Fortran::semantics::SemanticsContext &semanticsContext,
613+
Fortran::lower::StatementContext &stmtCtx,
614+
llvm::SmallVectorImpl<mlir::Value> &mapOperands);
615+
610616
// Call this method for these clauses that should be supported but are not
611617
// implemented yet. It triggers a compilation error if any of the given
612618
// clauses is found.
@@ -1893,6 +1899,47 @@ bool ClauseProcessor::processUseDevicePtr(
18931899
});
18941900
}
18951901

1902+
template <typename T>
1903+
bool ClauseProcessor::processMotionClauses(
1904+
Fortran::semantics::SemanticsContext &semanticsContext,
1905+
Fortran::lower::StatementContext &stmtCtx,
1906+
llvm::SmallVectorImpl<mlir::Value> &mapOperands) {
1907+
return findRepeatableClause<T>(
1908+
[&](const T *motionClause, const Fortran::parser::CharBlock &source) {
1909+
mlir::Location clauseLocation = converter.genLocation(source);
1910+
fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
1911+
1912+
static_assert(std::is_same_v<T, ClauseProcessor::ClauseTy::To> ||
1913+
std::is_same_v<T, ClauseProcessor::ClauseTy::From>);
1914+
1915+
// TODO Support motion modifiers: present, mapper, iterator.
1916+
constexpr llvm::omp::OpenMPOffloadMappingFlags mapTypeBits =
1917+
std::is_same_v<T, ClauseProcessor::ClauseTy::To>
1918+
? llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_TO
1919+
: llvm::omp::OpenMPOffloadMappingFlags::OMP_MAP_FROM;
1920+
1921+
for (const Fortran::parser::OmpObject &ompObject : motionClause->v.v) {
1922+
llvm::SmallVector<mlir::Value> bounds;
1923+
std::stringstream asFortran;
1924+
Fortran::lower::AddrAndBoundsInfo info =
1925+
Fortran::lower::gatherDataOperandAddrAndBounds<
1926+
Fortran::parser::OmpObject, mlir::omp::DataBoundsOp,
1927+
mlir::omp::DataBoundsType>(
1928+
converter, firOpBuilder, semanticsContext, stmtCtx, ompObject,
1929+
clauseLocation, asFortran, bounds, treatIndexAsSection);
1930+
1931+
mlir::Value mapOp = createMapInfoOp(
1932+
firOpBuilder, clauseLocation, info.addr, asFortran, bounds,
1933+
static_cast<
1934+
std::underlying_type_t<llvm::omp::OpenMPOffloadMappingFlags>>(
1935+
mapTypeBits),
1936+
mlir::omp::VariableCaptureKind::ByRef, info.addr.getType());
1937+
1938+
mapOperands.push_back(mapOp);
1939+
}
1940+
});
1941+
}
1942+
18961943
template <typename... Ts>
18971944
void ClauseProcessor::processTODO(mlir::Location currentLocation,
18981945
llvm::omp::Directive directive) const {
@@ -2416,10 +2463,10 @@ genDataOp(Fortran::lower::AbstractConverter &converter,
24162463

24172464
template <typename OpTy>
24182465
static OpTy
2419-
genEnterExitDataOp(Fortran::lower::AbstractConverter &converter,
2420-
Fortran::semantics::SemanticsContext &semanticsContext,
2421-
mlir::Location currentLocation,
2422-
const Fortran::parser::OmpClauseList &clauseList) {
2466+
genEnterExitUpdateDataOp(Fortran::lower::AbstractConverter &converter,
2467+
Fortran::semantics::SemanticsContext &semanticsContext,
2468+
mlir::Location currentLocation,
2469+
const Fortran::parser::OmpClauseList &clauseList) {
24232470
fir::FirOpBuilder &firOpBuilder = converter.getFirOpBuilder();
24242471
Fortran::lower::StatementContext stmtCtx;
24252472
mlir::Value ifClauseOperand, deviceOperand;
@@ -2436,6 +2483,10 @@ genEnterExitDataOp(Fortran::lower::AbstractConverter &converter,
24362483
directiveName =
24372484
Fortran::parser::OmpIfClause::DirectiveNameModifier::TargetExitData;
24382485
directive = llvm::omp::Directive::OMPD_target_exit_data;
2486+
} else if constexpr (std::is_same_v<OpTy, mlir::omp::UpdateDataOp>) {
2487+
directiveName =
2488+
Fortran::parser::OmpIfClause::DirectiveNameModifier::TargetUpdate;
2489+
directive = llvm::omp::Directive::OMPD_target_update;
24392490
} else {
24402491
return nullptr;
24412492
}
@@ -2444,8 +2495,18 @@ genEnterExitDataOp(Fortran::lower::AbstractConverter &converter,
24442495
cp.processIf(directiveName, ifClauseOperand);
24452496
cp.processDevice(stmtCtx, deviceOperand);
24462497
cp.processNowait(nowaitAttr);
2447-
cp.processMap(currentLocation, directive, semanticsContext, stmtCtx,
2448-
mapOperands);
2498+
2499+
if constexpr (std::is_same_v<OpTy, mlir::omp::UpdateDataOp>) {
2500+
cp.processMotionClauses<Fortran::parser::OmpClause::To>(
2501+
semanticsContext, stmtCtx, mapOperands);
2502+
cp.processMotionClauses<Fortran::parser::OmpClause::From>(
2503+
semanticsContext, stmtCtx, mapOperands);
2504+
2505+
} else {
2506+
cp.processMap(currentLocation, directive, semanticsContext, stmtCtx,
2507+
mapOperands);
2508+
}
2509+
24492510
cp.processTODO<Fortran::parser::OmpClause::Depend>(currentLocation,
24502511
directive);
24512512

@@ -2847,15 +2908,17 @@ genOmpSimpleStandalone(Fortran::lower::AbstractConverter &converter,
28472908
genDataOp(converter, eval, semanticsContext, currentLocation, opClauseList);
28482909
break;
28492910
case llvm::omp::Directive::OMPD_target_enter_data:
2850-
genEnterExitDataOp<mlir::omp::EnterDataOp>(converter, semanticsContext,
2851-
currentLocation, opClauseList);
2911+
genEnterExitUpdateDataOp<mlir::omp::EnterDataOp>(
2912+
converter, semanticsContext, currentLocation, opClauseList);
28522913
break;
28532914
case llvm::omp::Directive::OMPD_target_exit_data:
2854-
genEnterExitDataOp<mlir::omp::ExitDataOp>(converter, semanticsContext,
2855-
currentLocation, opClauseList);
2915+
genEnterExitUpdateDataOp<mlir::omp::ExitDataOp>(
2916+
converter, semanticsContext, currentLocation, opClauseList);
28562917
break;
28572918
case llvm::omp::Directive::OMPD_target_update:
2858-
TODO(currentLocation, "OMPD_target_update");
2919+
genEnterExitUpdateDataOp<mlir::omp::UpdateDataOp>(
2920+
converter, semanticsContext, currentLocation, opClauseList);
2921+
break;
28592922
case llvm::omp::Directive::OMPD_ordered:
28602923
TODO(currentLocation, "OMPD_ordered");
28612924
}

0 commit comments

Comments
 (0)