Skip to content

Commit f623915

Browse files
author
z1.cciauto
committed
merge main into amd-staging
2 parents 3f2154c + 31bd7a5 commit f623915

File tree

140 files changed

+1618
-1234
lines changed

Some content is hidden

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

140 files changed

+1618
-1234
lines changed

clang-tools-extra/clang-tidy/modernize/UseDesignatedInitializersCheck.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,9 @@ void UseDesignatedInitializersCheck::registerMatchers(MatchFinder *Finder) {
121121
hasAnyBase(hasType(cxxRecordDecl(has(fieldDecl()))));
122122
Finder->addMatcher(
123123
initListExpr(
124-
hasType(cxxRecordDecl(RestrictToPODTypes ? isPOD() : isAggregate(),
125-
unless(HasBaseWithFields))
124+
hasType(cxxRecordDecl(
125+
RestrictToPODTypes ? isPOD() : isAggregate(),
126+
unless(anyOf(HasBaseWithFields, hasName("::std::array"))))
126127
.bind("type")),
127128
IgnoreSingleElementAggregates ? hasMoreThanOneElement() : anything(),
128129
unless(isFullyDesignated()))

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,10 @@ Changes in existing checks
182182
``constexpr`` and ``static``` values on member initialization and by detecting
183183
explicit casting of built-in types within member list initialization.
184184

185+
- Improved :doc:`modernize-use-designated-initializers
186+
<clang-tidy/checks/modernize/use-designated-initializers>` check by avoiding
187+
diagnosing designated initializers for ``std::array`` initializations.
188+
185189
- Improved :doc:`modernize-use-ranges
186190
<clang-tidy/checks/modernize/use-ranges>` check by updating suppress
187191
warnings logic for ``nullptr`` in ``std::find``.

clang-tools-extra/docs/clang-tidy/checks/modernize/use-designated-initializers.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ Options
5454

5555
The value `false` specifies that even initializers for aggregate types with
5656
only a single element should be checked. The default value is `true`.
57+
``std::array`` initializations are always excluded, as the type is a
58+
standard library abstraction and not intended to be initialized with
59+
designated initializers.
5760

5861
.. option:: RestrictToPODTypes
5962

clang-tools-extra/test/clang-tidy/checkers/modernize/use-designated-initializers.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,3 +209,18 @@ struct S15{
209209
S15(S14& d):d{d}{}
210210
S14& d;
211211
};
212+
213+
//Issue #133715
214+
namespace std {
215+
template<typename T, unsigned int N>
216+
struct array {
217+
T __elems[N];
218+
};
219+
template<typename T, typename... U>
220+
array(T, U...) -> array<T, 1 + sizeof...(U)>;
221+
}
222+
223+
std::array a{1,2,3};
224+
std::array<int,2> b{10, 11};
225+
using array = std::array<int, 2>;
226+
array c{10, 11};

clang/include/clang/Frontend/CompilerInvocation.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class CompilerInvocationBase {
8989
std::shared_ptr<PreprocessorOptions> PPOpts;
9090

9191
/// Options controlling the static analyzer.
92-
AnalyzerOptionsRef AnalyzerOpts;
92+
std::shared_ptr<AnalyzerOptions> AnalyzerOpts;
9393

9494
std::shared_ptr<MigratorOptions> MigratorOpts;
9595

clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ class PositiveAnalyzerOption {
176176
/// and should be eventually converted into -analyzer-config flags. New analyzer
177177
/// options should not be implemented as frontend flags. Frontend flags still
178178
/// make sense for things that do not affect the actual analysis.
179-
class AnalyzerOptions : public RefCountedBase<AnalyzerOptions> {
179+
class AnalyzerOptions {
180180
public:
181181
using ConfigTable = llvm::StringMap<std::string>;
182182

@@ -416,8 +416,6 @@ class AnalyzerOptions : public RefCountedBase<AnalyzerOptions> {
416416
}
417417
};
418418

419-
using AnalyzerOptionsRef = IntrusiveRefCntPtr<AnalyzerOptions>;
420-
421419
//===----------------------------------------------------------------------===//
422420
// We'll use AnalyzerOptions in the frontend, but we can't link the frontend
423421
// with clangStaticAnalyzerCore, because clangStaticAnalyzerCore depends on

clang/lib/Basic/Targets/SPIR.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,13 @@ static const unsigned SPIRDefIsPrivMap[] = {
5858
// Used by both the SPIR and SPIR-V targets.
5959
static const unsigned SPIRDefIsGenMap[] = {
6060
4, // Default
61-
// Some OpenCL address space values for this map are dummy and they can't be
62-
// used
6361
1, // opencl_global
64-
0, // opencl_local
65-
0, // opencl_constant
62+
3, // opencl_local
63+
2, // opencl_constant
6664
0, // opencl_private
67-
0, // opencl_generic
68-
0, // opencl_global_device
69-
0, // opencl_global_host
65+
4, // opencl_generic
66+
5, // opencl_global_device
67+
6, // opencl_global_host
7068
// cuda_* address space mapping is intended for HIPSPV (HIP to SPIR-V
7169
// translation). This mapping is enabled when the language mode is HIP.
7270
1, // cuda_device

clang/lib/CIR/CodeGen/CIRGenExpr.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ LValue CIRGenFunction::emitLValueForField(LValue base, const FieldDecl *field) {
311311
assert(!cir::MissingFeatures::opTBAA());
312312

313313
Address addr = base.getAddress();
314-
if (auto *classDef = dyn_cast<CXXRecordDecl>(rec)) {
314+
if (isa<CXXRecordDecl>(rec)) {
315315
cgm.errorNYI(field->getSourceRange(), "emitLValueForField: C++ class");
316316
return LValue();
317317
}
@@ -701,7 +701,7 @@ CIRGenFunction::emitArraySubscriptExpr(const clang::ArraySubscriptExpr *e) {
701701
}
702702

703703
LValue CIRGenFunction::emitMemberExpr(const MemberExpr *e) {
704-
if (auto *vd = dyn_cast<VarDecl>(e->getMemberDecl())) {
704+
if (isa<VarDecl>(e->getMemberDecl())) {
705705
cgm.errorNYI(e->getSourceRange(), "emitMemberExpr: VarDecl");
706706
return LValue();
707707
}
@@ -734,7 +734,7 @@ LValue CIRGenFunction::emitMemberExpr(const MemberExpr *e) {
734734
return lv;
735735
}
736736

737-
if (const auto *fd = dyn_cast<FunctionDecl>(nd)) {
737+
if (isa<FunctionDecl>(nd)) {
738738
cgm.errorNYI(e->getSourceRange(), "emitMemberExpr: FunctionDecl");
739739
return LValue();
740740
}

clang/lib/CIR/CodeGen/CIRGenModule.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ void CIRGenModule::emitGlobalVarDefinition(const clang::VarDecl *vd,
366366
bool isTentative) {
367367
const QualType astTy = vd->getType();
368368
const mlir::Type type = convertType(vd->getType());
369-
if (clang::IdentifierInfo *identifier = vd->getIdentifier()) {
369+
if (vd->getIdentifier()) {
370370
StringRef name = getMangledName(GlobalDecl(vd));
371371
auto varOp =
372372
builder.create<cir::GlobalOp>(getLoc(vd->getSourceRange()), name, type);

clang/lib/Driver/SanitizerArgs.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1028,10 +1028,6 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC,
10281028
StableABI = Args.hasFlag(options::OPT_fsanitize_stable_abi,
10291029
options::OPT_fno_sanitize_stable_abi, false);
10301030

1031-
AsanUseAfterScope = Args.hasFlag(
1032-
options::OPT_fsanitize_address_use_after_scope,
1033-
options::OPT_fno_sanitize_address_use_after_scope, AsanUseAfterScope);
1034-
10351031
AsanPoisonCustomArrayCookie = Args.hasFlag(
10361032
options::OPT_fsanitize_address_poison_custom_array_cookie,
10371033
options::OPT_fno_sanitize_address_poison_custom_array_cookie,
@@ -1093,7 +1089,6 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC,
10931089
}
10941090

10951091
} else {
1096-
AsanUseAfterScope = false;
10971092
// -fsanitize=pointer-compare/pointer-subtract requires -fsanitize=address.
10981093
SanitizerMask DetectInvalidPointerPairs =
10991094
SanitizerKind::PointerCompare | SanitizerKind::PointerSubtract;
@@ -1107,6 +1102,14 @@ SanitizerArgs::SanitizerArgs(const ToolChain &TC,
11071102
}
11081103
}
11091104

1105+
if (AllAddedKinds & (SanitizerKind::Address | SanitizerKind::KernelAddress)) {
1106+
AsanUseAfterScope = Args.hasFlag(
1107+
options::OPT_fsanitize_address_use_after_scope,
1108+
options::OPT_fno_sanitize_address_use_after_scope, AsanUseAfterScope);
1109+
} else {
1110+
AsanUseAfterScope = false;
1111+
}
1112+
11101113
if (AllAddedKinds & SanitizerKind::HWAddress) {
11111114
if (Arg *HwasanAbiArg =
11121115
Args.getLastArg(options::OPT_fsanitize_hwaddress_abi_EQ)) {

0 commit comments

Comments
 (0)