Skip to content

Commit 3398280

Browse files
committed
Merge remote-tracking branch 'upstream/main' into gh-101657
2 parents f3e4223 + a618ae2 commit 3398280

File tree

346 files changed

+23291
-5315
lines changed

Some content is hidden

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

346 files changed

+23291
-5315
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/Basic/DiagnosticFrontendKinds.td

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,10 @@ def err_modules_embed_file_not_found :
260260
DefaultFatal;
261261
def err_module_header_file_not_found :
262262
Error<"module header file '%0' not found">, DefaultFatal;
263+
def err_frontend_action_unsupported_input_format
264+
: Error<"%0 does not support input file format of file '%1': "
265+
"'%select{Source|ModuleMap|Precompiled|Unknown}2'">,
266+
DefaultFatal;
263267

264268
def err_test_module_file_extension_version : Error<
265269
"test module file extension '%0' has different version (%1.%2) than expected "

clang/include/clang/Basic/HeaderInclude.h

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,14 @@ enum HeaderIncludeFormatKind { HIFMT_None, HIFMT_Textual, HIFMT_JSON };
2323

2424
/// Whether header information is filtered or not. If HIFIL_Only_Direct_System
2525
/// is used, only information on system headers directly included from
26-
/// non-system headers is emitted.
27-
enum HeaderIncludeFilteringKind { HIFIL_None, HIFIL_Only_Direct_System };
26+
/// non-system files is emitted. The HIFIL_Direct_Per_File filtering shows the
27+
/// direct imports and includes for each non-system source and header file
28+
/// separately.
29+
enum HeaderIncludeFilteringKind {
30+
HIFIL_None,
31+
HIFIL_Only_Direct_System,
32+
HIFIL_Direct_Per_File
33+
};
2834

2935
inline HeaderIncludeFormatKind
3036
stringToHeaderIncludeFormatKind(const char *Str) {
@@ -40,6 +46,7 @@ inline bool stringToHeaderIncludeFiltering(const char *Str,
4046
llvm::StringSwitch<std::pair<bool, HeaderIncludeFilteringKind>>(Str)
4147
.Case("none", {true, HIFIL_None})
4248
.Case("only-direct-system", {true, HIFIL_Only_Direct_System})
49+
.Case("direct-per-file", {true, HIFIL_Direct_Per_File})
4350
.Default({false, HIFIL_None});
4451
Kind = P.second;
4552
return P.first;
@@ -64,6 +71,8 @@ headerIncludeFilteringKindToString(HeaderIncludeFilteringKind K) {
6471
return "none";
6572
case HIFIL_Only_Direct_System:
6673
return "only-direct-system";
74+
case HIFIL_Direct_Per_File:
75+
return "direct-per-file";
6776
}
6877
llvm_unreachable("Unknown HeaderIncludeFilteringKind enum");
6978
}

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/Driver/Options.td

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7793,7 +7793,8 @@ def header_include_format_EQ : Joined<["-"], "header-include-format=">,
77937793
MarshallingInfoEnum<DependencyOutputOpts<"HeaderIncludeFormat">, "HIFMT_Textual">;
77947794
def header_include_filtering_EQ : Joined<["-"], "header-include-filtering=">,
77957795
HelpText<"set the flag that enables filtering header information">,
7796-
Values<"none,only-direct-system">, NormalizedValues<["HIFIL_None", "HIFIL_Only_Direct_System"]>,
7796+
Values<"none,only-direct-system,direct-per-file">,
7797+
NormalizedValues<["HIFIL_None", "HIFIL_Only_Direct_System", "HIFIL_Direct_Per_File"]>,
77977798
MarshallingInfoEnum<DependencyOutputOpts<"HeaderIncludeFiltering">, "HIFIL_None">;
77987799
def show_includes : Flag<["--"], "show-includes">,
77997800
HelpText<"Print cl.exe style /showIncludes to stdout">;

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

0 commit comments

Comments
 (0)