Skip to content

Commit ef083af

Browse files
authored
Merge branch 'main' into lldb-dap-settings
2 parents 059ea3b + 7ca6490 commit ef083af

File tree

162 files changed

+4109
-2327
lines changed

Some content is hidden

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

162 files changed

+4109
-2327
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/AST/OperationKinds.def

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,7 @@ CAST_OPERATION(ArrayToPointerDecay)
119119
CAST_OPERATION(FunctionToPointerDecay)
120120

121121
/// CK_NullToPointer - Null pointer constant to pointer, ObjC
122-
/// pointer, or block pointer. The result of this conversion can
123-
/// still be a null pointer constant if it has type std::nullptr_t.
122+
/// pointer, block pointer, or std::nullptr_t.
124123
/// (void*) 0
125124
/// void (^block)() = 0;
126125
CAST_OPERATION(NullToPointer)

clang/include/clang/CIR/Dialect/IR/CIRTypes.td

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,18 +292,18 @@ def CIR_ArrayType : CIR_Type<"Array", "array",
292292
`CIR.array` represents C/C++ constant arrays.
293293
}];
294294

295-
let parameters = (ins "mlir::Type":$eltType, "uint64_t":$size);
295+
let parameters = (ins "mlir::Type":$elementType, "uint64_t":$size);
296296

297297
let builders = [
298298
TypeBuilderWithInferredContext<(ins
299-
"mlir::Type":$eltType, "uint64_t":$size
299+
"mlir::Type":$elementType, "uint64_t":$size
300300
), [{
301-
return $_get(eltType.getContext(), eltType, size);
301+
return $_get(elementType.getContext(), elementType, size);
302302
}]>,
303303
];
304304

305305
let assemblyFormat = [{
306-
`<` $eltType `x` $size `>`
306+
`<` $elementType `x` $size `>`
307307
}];
308308
}
309309

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/Sema/SemaOpenACC.h

Lines changed: 64 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -125,38 +125,78 @@ class SemaOpenACC : public SemaBase {
125125
/// 'loop' clause enforcement, where this is 'blocked' by a compute construct.
126126
llvm::SmallVector<OpenACCReductionClause *> ActiveReductionClauses;
127127

128-
// Type to check the info about the 'for stmt'.
129-
struct ForStmtBeginChecker {
128+
// Type to check the 'for' (or range-for) statement for compatibility with the
129+
// 'loop' directive.
130+
class ForStmtBeginChecker {
130131
SemaOpenACC &SemaRef;
131132
SourceLocation ForLoc;
132-
bool IsRangeFor = false;
133-
std::optional<const CXXForRangeStmt *> RangeFor = nullptr;
134-
const Stmt *Init = nullptr;
135-
bool InitChanged = false;
136-
std::optional<const Stmt *> Cond = nullptr;
137-
std::optional<const Stmt *> Inc = nullptr;
133+
bool IsInstantiation = false;
134+
135+
struct RangeForInfo {
136+
const CXXForRangeStmt *Uninstantiated = nullptr;
137+
const CXXForRangeStmt *CurrentVersion = nullptr;
138+
// GCC 7.x requires this constructor, else the construction of variant
139+
// doesn't work correctly.
140+
RangeForInfo() : Uninstantiated{nullptr}, CurrentVersion{nullptr} {}
141+
RangeForInfo(const CXXForRangeStmt *Uninst, const CXXForRangeStmt *Cur)
142+
: Uninstantiated{Uninst}, CurrentVersion{Cur} {}
143+
};
144+
145+
struct ForInfo {
146+
const Stmt *Init = nullptr;
147+
const Stmt *Condition = nullptr;
148+
const Stmt *Increment = nullptr;
149+
};
150+
151+
struct CheckForInfo {
152+
ForInfo Uninst;
153+
ForInfo Current;
154+
};
155+
156+
std::variant<RangeForInfo, CheckForInfo> Info;
138157
// Prevent us from checking 2x, which can happen with collapse & tile.
139158
bool AlreadyChecked = false;
140159

141-
ForStmtBeginChecker(SemaOpenACC &SemaRef, SourceLocation ForLoc,
142-
std::optional<const CXXForRangeStmt *> S)
143-
: SemaRef(SemaRef), ForLoc(ForLoc), IsRangeFor(true), RangeFor(S) {}
160+
void checkRangeFor();
161+
162+
bool checkForInit(const Stmt *InitStmt, const ValueDecl *&InitVar,
163+
bool Diag);
164+
bool checkForCond(const Stmt *CondStmt, const ValueDecl *InitVar,
165+
bool Diag);
166+
bool checkForInc(const Stmt *IncStmt, const ValueDecl *InitVar, bool Diag);
144167

168+
void checkFor();
169+
170+
// void checkRangeFor(); ?? ERICH
171+
// const ValueDecl *checkInit();
172+
// void checkCond(const ValueDecl *Init);
173+
// void checkInc(const ValueDecl *Init);
174+
public:
175+
// Checking for non-instantiation version of a Range-for.
145176
ForStmtBeginChecker(SemaOpenACC &SemaRef, SourceLocation ForLoc,
146-
const Stmt *I, bool InitChanged,
147-
std::optional<const Stmt *> C,
148-
std::optional<const Stmt *> Inc)
149-
: SemaRef(SemaRef), ForLoc(ForLoc), IsRangeFor(false), Init(I),
150-
InitChanged(InitChanged), Cond(C), Inc(Inc) {}
151-
// Do the checking for the For/Range-For. Currently this implements the 'not
152-
// seq' restrictions only, and should be called either if we know we are a
153-
// top-level 'for' (the one associated via associated-stmt), or extended via
154-
// 'collapse'.
155-
void check();
177+
const CXXForRangeStmt *RangeFor)
178+
: SemaRef(SemaRef), ForLoc(ForLoc), IsInstantiation(false),
179+
Info(RangeForInfo{nullptr, RangeFor}) {}
180+
// Checking for an instantiation of the range-for.
181+
ForStmtBeginChecker(SemaOpenACC &SemaRef, SourceLocation ForLoc,
182+
const CXXForRangeStmt *OldRangeFor,
183+
const CXXForRangeStmt *RangeFor)
184+
: SemaRef(SemaRef), ForLoc(ForLoc), IsInstantiation(true),
185+
Info(RangeForInfo{OldRangeFor, RangeFor}) {}
186+
// Checking for a non-instantiation version of a traditional for.
187+
ForStmtBeginChecker(SemaOpenACC &SemaRef, SourceLocation ForLoc,
188+
const Stmt *Init, const Stmt *Cond, const Stmt *Inc)
189+
: SemaRef(SemaRef), ForLoc(ForLoc), IsInstantiation(false),
190+
Info(CheckForInfo{{}, {Init, Cond, Inc}}) {}
191+
// Checking for an instantiation version of a traditional for.
192+
ForStmtBeginChecker(SemaOpenACC &SemaRef, SourceLocation ForLoc,
193+
const Stmt *OldInit, const Stmt *OldCond,
194+
const Stmt *OldInc, const Stmt *Init, const Stmt *Cond,
195+
const Stmt *Inc)
196+
: SemaRef(SemaRef), ForLoc(ForLoc), IsInstantiation(true),
197+
Info(CheckForInfo{{OldInit, OldCond, OldInc}, {Init, Cond, Inc}}) {}
156198

157-
const ValueDecl *checkInit();
158-
void checkCond();
159-
void checkInc(const ValueDecl *Init);
199+
void check();
160200
};
161201

162202
/// Helper function for checking the 'for' and 'range for' stmts.

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

0 commit comments

Comments
 (0)