Skip to content

Commit 17cedbc

Browse files
committed
Merge remote-tracking branch 'origin/main' into pr/utostr
2 parents 1939bd3 + d38a5af commit 17cedbc

File tree

282 files changed

+8461
-4483
lines changed

Some content is hidden

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

282 files changed

+8461
-4483
lines changed

.ci/monolithic-linux.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ cmake -S "${MONOREPO_ROOT}"/llvm -B "${BUILD_DIR}" \
6060
-D MLIR_ENABLE_BINDINGS_PYTHON=ON \
6161
-D LLDB_ENABLE_PYTHON=ON \
6262
-D LLDB_ENFORCE_STRICT_TEST_REQUIREMENTS=ON \
63-
-D CMAKE_INSTALL_PREFIX="${INSTALL_DIR}"
63+
-D CMAKE_INSTALL_PREFIX="${INSTALL_DIR}" \
64+
-D CMAKE_EXE_LINKER_FLAGS="-no-pie"
6465

6566
start-group "ninja"
6667

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,8 @@ Changes in existing checks
215215

216216
- Improved :doc:`readability-identifier-naming
217217
<clang-tidy/checks/readability/identifier-naming>` check by ignoring
218-
declarations in system headers.
218+
declarations in system headers. The documentation is also improved to
219+
differentiate the general options from the specific ones.
219220

220221
- Improved :doc:`readability-qualified-auto
221222
<clang-tidy/checks/readability/qualified-auto>` check by adding the option

clang-tools-extra/docs/clang-tidy/checks/readability/identifier-naming.rst

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,21 @@ The options and their corresponding values are:
4343
- ``LowerCase`` - example: ``int i_Variable``
4444
- ``CamelCase`` - example: ``int IVariable``
4545

46-
Options
47-
-------
46+
Options summary
47+
---------------
4848

49-
The following options are described below:
49+
The available options are summarized below:
50+
51+
**General options**
5052

51-
- :option:`AbstractClassCase`, :option:`AbstractClassPrefix`, :option:`AbstractClassSuffix`, :option:`AbstractClassIgnoredRegexp`, :option:`AbstractClassHungarianPrefix`
5253
- :option:`AggressiveDependentMemberLookup`
5354
- :option:`CheckAnonFieldInParent`
55+
- :option:`GetConfigPerFile`
56+
- :option:`IgnoreMainLikeFunctions`
57+
58+
**Specific options**
59+
60+
- :option:`AbstractClassCase`, :option:`AbstractClassPrefix`, :option:`AbstractClassSuffix`, :option:`AbstractClassIgnoredRegexp`, :option:`AbstractClassHungarianPrefix`
5461
- :option:`ClassCase`, :option:`ClassPrefix`, :option:`ClassSuffix`, :option:`ClassIgnoredRegexp`, :option:`ClassHungarianPrefix`
5562
- :option:`ClassConstantCase`, :option:`ClassConstantPrefix`, :option:`ClassConstantSuffix`, :option:`ClassConstantIgnoredRegexp`, :option:`ClassConstantHungarianPrefix`
5663
- :option:`ClassMemberCase`, :option:`ClassMemberPrefix`, :option:`ClassMemberSuffix`, :option:`ClassMemberIgnoredRegexp`, :option:`ClassMemberHungarianPrefix`
@@ -66,13 +73,11 @@ The following options are described below:
6673
- :option:`EnumCase`, :option:`EnumPrefix`, :option:`EnumSuffix`, :option:`EnumIgnoredRegexp`
6774
- :option:`EnumConstantCase`, :option:`EnumConstantPrefix`, :option:`EnumConstantSuffix`, :option:`EnumConstantIgnoredRegexp`, :option:`EnumConstantHungarianPrefix`
6875
- :option:`FunctionCase`, :option:`FunctionPrefix`, :option:`FunctionSuffix`, :option:`FunctionIgnoredRegexp`
69-
- :option:`GetConfigPerFile`
7076
- :option:`GlobalConstantCase`, :option:`GlobalConstantPrefix`, :option:`GlobalConstantSuffix`, :option:`GlobalConstantIgnoredRegexp`, :option:`GlobalConstantHungarianPrefix`
7177
- :option:`GlobalConstantPointerCase`, :option:`GlobalConstantPointerPrefix`, :option:`GlobalConstantPointerSuffix`, :option:`GlobalConstantPointerIgnoredRegexp`, :option:`GlobalConstantPointerHungarianPrefix`
7278
- :option:`GlobalFunctionCase`, :option:`GlobalFunctionPrefix`, :option:`GlobalFunctionSuffix`, :option:`GlobalFunctionIgnoredRegexp`
7379
- :option:`GlobalPointerCase`, :option:`GlobalPointerPrefix`, :option:`GlobalPointerSuffix`, :option:`GlobalPointerIgnoredRegexp`, :option:`GlobalPointerHungarianPrefix`
7480
- :option:`GlobalVariableCase`, :option:`GlobalVariablePrefix`, :option:`GlobalVariableSuffix`, :option:`GlobalVariableIgnoredRegexp`, :option:`GlobalVariableHungarianPrefix`
75-
- :option:`IgnoreMainLikeFunctions`
7681
- :option:`InlineNamespaceCase`, :option:`InlineNamespacePrefix`, :option:`InlineNamespaceSuffix`, :option:`InlineNamespaceIgnoredRegexp`
7782
- :option:`LocalConstantCase`, :option:`LocalConstantPrefix`, :option:`LocalConstantSuffix`, :option:`LocalConstantIgnoredRegexp`, :option:`LocalConstantHungarianPrefix`
7883
- :option:`LocalConstantPointerCase`, :option:`LocalConstantPointerPrefix`, :option:`LocalConstantPointerSuffix`, :option:`LocalConstantPointerIgnoredRegexp`, :option:`LocalConstantPointerHungarianPrefix`
@@ -105,6 +110,12 @@ The following options are described below:
105110
- :option:`VariableCase`, :option:`VariablePrefix`, :option:`VariableSuffix`, :option:`VariableIgnoredRegexp`, :option:`VariableHungarianPrefix`
106111
- :option:`VirtualMethodCase`, :option:`VirtualMethodPrefix`, :option:`VirtualMethodSuffix`, :option:`VirtualMethodIgnoredRegexp`
107112

113+
114+
Options description
115+
-------------------
116+
117+
A detailed description of each option is presented below:
118+
108119
.. option:: AbstractClassCase
109120

110121
When defined, the check will ensure abstract class names conform to the

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ Bug Fixes in This Version
229229
cast chain. (#GH149967).
230230
- Fixed a crash with incompatible pointer to integer conversions in designated
231231
initializers involving string literals. (#GH154046)
232+
- Fixed scope of typedefs present inside a template class. (#GH91451)
232233

233234
Bug Fixes to Compiler Builtins
234235
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

clang/include/clang/Basic/AllDiagnostics.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,20 @@
2323
#include "clang/Basic/DiagnosticInstallAPI.h"
2424
#include "clang/Basic/DiagnosticLex.h"
2525
#include "clang/Basic/DiagnosticParse.h"
26+
#include "clang/Basic/DiagnosticRefactoring.h"
2627
#include "clang/Basic/DiagnosticSema.h"
2728
#include "clang/Basic/DiagnosticSerialization.h"
28-
#include "clang/Basic/DiagnosticRefactoring.h"
2929

3030
namespace clang {
31-
template <size_t SizeOfStr, typename FieldType>
32-
class StringSizerHelper {
31+
template <size_t SizeOfStr, typename FieldType> class StringSizerHelper {
3332
static_assert(SizeOfStr <= FieldType(~0U), "Field too small!");
33+
3434
public:
3535
enum { Size = SizeOfStr };
3636
};
3737
} // end namespace clang
3838

39-
#define STR_SIZE(str, fieldTy) clang::StringSizerHelper<sizeof(str)-1, \
40-
fieldTy>::Size
39+
#define STR_SIZE(str, fieldTy) \
40+
clang::StringSizerHelper<sizeof(str) - 1, fieldTy>::Size
4141

4242
#endif

clang/include/clang/Basic/DiagnosticIDs.h

Lines changed: 75 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -23,76 +23,78 @@
2323
#include <vector>
2424

2525
namespace clang {
26-
class DiagnosticsEngine;
27-
class DiagnosticBuilder;
28-
class LangOptions;
29-
class SourceLocation;
30-
31-
// Import the diagnostic enums themselves.
32-
namespace diag {
33-
enum class Group;
34-
35-
// Size of each of the diagnostic categories.
36-
enum {
37-
DIAG_SIZE_COMMON = 300,
38-
DIAG_SIZE_DRIVER = 400,
39-
DIAG_SIZE_FRONTEND = 200,
40-
DIAG_SIZE_SERIALIZATION = 120,
41-
DIAG_SIZE_LEX = 500,
42-
DIAG_SIZE_PARSE = 800,
43-
DIAG_SIZE_AST = 300,
44-
DIAG_SIZE_COMMENT = 100,
45-
DIAG_SIZE_CROSSTU = 100,
46-
DIAG_SIZE_SEMA = 5000,
47-
DIAG_SIZE_ANALYSIS = 100,
48-
DIAG_SIZE_REFACTORING = 1000,
49-
DIAG_SIZE_INSTALLAPI = 100,
50-
};
51-
// Start position for diagnostics.
52-
enum {
53-
DIAG_START_COMMON = 0,
54-
DIAG_START_DRIVER = DIAG_START_COMMON + static_cast<int>(DIAG_SIZE_COMMON),
55-
DIAG_START_FRONTEND = DIAG_START_DRIVER + static_cast<int>(DIAG_SIZE_DRIVER),
56-
DIAG_START_SERIALIZATION = DIAG_START_FRONTEND + static_cast<int>(DIAG_SIZE_FRONTEND),
57-
DIAG_START_LEX = DIAG_START_SERIALIZATION + static_cast<int>(DIAG_SIZE_SERIALIZATION),
58-
DIAG_START_PARSE = DIAG_START_LEX + static_cast<int>(DIAG_SIZE_LEX),
59-
DIAG_START_AST = DIAG_START_PARSE + static_cast<int>(DIAG_SIZE_PARSE),
60-
DIAG_START_COMMENT = DIAG_START_AST + static_cast<int>(DIAG_SIZE_AST),
61-
DIAG_START_CROSSTU = DIAG_START_COMMENT + static_cast<int>(DIAG_SIZE_COMMENT),
62-
DIAG_START_SEMA = DIAG_START_CROSSTU + static_cast<int>(DIAG_SIZE_CROSSTU),
63-
DIAG_START_ANALYSIS = DIAG_START_SEMA + static_cast<int>(DIAG_SIZE_SEMA),
64-
DIAG_START_REFACTORING = DIAG_START_ANALYSIS + static_cast<int>(DIAG_SIZE_ANALYSIS),
65-
DIAG_START_INSTALLAPI = DIAG_START_REFACTORING + static_cast<int>(DIAG_SIZE_REFACTORING),
66-
DIAG_UPPER_LIMIT = DIAG_START_INSTALLAPI + static_cast<int>(DIAG_SIZE_INSTALLAPI)
67-
};
68-
69-
class CustomDiagInfo;
70-
71-
/// All of the diagnostics that can be emitted by the frontend.
72-
typedef unsigned kind;
73-
74-
/// Enum values that allow the client to map NOTEs, WARNINGs, and EXTENSIONs
75-
/// to either Ignore (nothing), Remark (emit a remark), Warning
76-
/// (emit a warning) or Error (emit as an error). It allows clients to
77-
/// map ERRORs to Error or Fatal (stop emitting diagnostics after this one).
78-
enum class Severity : uint8_t {
79-
// NOTE: 0 means "uncomputed".
80-
Ignored = 1, ///< Do not present this diagnostic, ignore it.
81-
Remark = 2, ///< Present this diagnostic as a remark.
82-
Warning = 3, ///< Present this diagnostic as a warning.
83-
Error = 4, ///< Present this diagnostic as an error.
84-
Fatal = 5 ///< Present this diagnostic as a fatal error.
85-
};
86-
87-
/// Flavors of diagnostics we can emit. Used to filter for a particular
88-
/// kind of diagnostic (for instance, for -W/-R flags).
89-
enum class Flavor {
90-
WarningOrError, ///< A diagnostic that indicates a problem or potential
91-
///< problem. Can be made fatal by -Werror.
92-
Remark ///< A diagnostic that indicates normal progress through
93-
///< compilation.
94-
};
95-
} // end namespace diag
26+
class DiagnosticsEngine;
27+
class DiagnosticBuilder;
28+
class LangOptions;
29+
class SourceLocation;
30+
31+
// Import the diagnostic enums themselves.
32+
namespace diag {
33+
enum class Group;
34+
35+
// Size of each of the diagnostic categories.
36+
enum {
37+
DIAG_SIZE_COMMON = 300,
38+
DIAG_SIZE_DRIVER = 400,
39+
DIAG_SIZE_FRONTEND = 200,
40+
DIAG_SIZE_SERIALIZATION = 120,
41+
DIAG_SIZE_LEX = 500,
42+
DIAG_SIZE_PARSE = 800,
43+
DIAG_SIZE_AST = 300,
44+
DIAG_SIZE_COMMENT = 100,
45+
DIAG_SIZE_CROSSTU = 100,
46+
DIAG_SIZE_SEMA = 5000,
47+
DIAG_SIZE_ANALYSIS = 100,
48+
DIAG_SIZE_REFACTORING = 1000,
49+
DIAG_SIZE_INSTALLAPI = 100,
50+
};
51+
// Start position for diagnostics.
52+
// clang-format off
53+
enum {
54+
DIAG_START_COMMON = 0,
55+
DIAG_START_DRIVER = DIAG_START_COMMON + static_cast<int>(DIAG_SIZE_COMMON),
56+
DIAG_START_FRONTEND = DIAG_START_DRIVER + static_cast<int>(DIAG_SIZE_DRIVER),
57+
DIAG_START_SERIALIZATION = DIAG_START_FRONTEND + static_cast<int>(DIAG_SIZE_FRONTEND),
58+
DIAG_START_LEX = DIAG_START_SERIALIZATION + static_cast<int>(DIAG_SIZE_SERIALIZATION),
59+
DIAG_START_PARSE = DIAG_START_LEX + static_cast<int>(DIAG_SIZE_LEX),
60+
DIAG_START_AST = DIAG_START_PARSE + static_cast<int>(DIAG_SIZE_PARSE),
61+
DIAG_START_COMMENT = DIAG_START_AST + static_cast<int>(DIAG_SIZE_AST),
62+
DIAG_START_CROSSTU = DIAG_START_COMMENT + static_cast<int>(DIAG_SIZE_COMMENT),
63+
DIAG_START_SEMA = DIAG_START_CROSSTU + static_cast<int>(DIAG_SIZE_CROSSTU),
64+
DIAG_START_ANALYSIS = DIAG_START_SEMA + static_cast<int>(DIAG_SIZE_SEMA),
65+
DIAG_START_REFACTORING = DIAG_START_ANALYSIS + static_cast<int>(DIAG_SIZE_ANALYSIS),
66+
DIAG_START_INSTALLAPI = DIAG_START_REFACTORING + static_cast<int>(DIAG_SIZE_REFACTORING),
67+
DIAG_UPPER_LIMIT = DIAG_START_INSTALLAPI + static_cast<int>(DIAG_SIZE_INSTALLAPI)
68+
};
69+
// clang-format on
70+
71+
class CustomDiagInfo;
72+
73+
/// All of the diagnostics that can be emitted by the frontend.
74+
typedef unsigned kind;
75+
76+
/// Enum values that allow the client to map NOTEs, WARNINGs, and EXTENSIONs
77+
/// to either Ignore (nothing), Remark (emit a remark), Warning
78+
/// (emit a warning) or Error (emit as an error). It allows clients to
79+
/// map ERRORs to Error or Fatal (stop emitting diagnostics after this one).
80+
enum class Severity : uint8_t {
81+
// NOTE: 0 means "uncomputed".
82+
Ignored = 1, ///< Do not present this diagnostic, ignore it.
83+
Remark = 2, ///< Present this diagnostic as a remark.
84+
Warning = 3, ///< Present this diagnostic as a warning.
85+
Error = 4, ///< Present this diagnostic as an error.
86+
Fatal = 5 ///< Present this diagnostic as a fatal error.
87+
};
88+
89+
/// Flavors of diagnostics we can emit. Used to filter for a particular
90+
/// kind of diagnostic (for instance, for -W/-R flags).
91+
enum class Flavor {
92+
WarningOrError, ///< A diagnostic that indicates a problem or potential
93+
///< problem. Can be made fatal by -Werror.
94+
Remark ///< A diagnostic that indicates normal progress through
95+
///< compilation.
96+
};
97+
} // end namespace diag
9698
} // end namespace clang
9799

98100
// This has to be included *after* the DIAG_START_ enums above are defined.
@@ -173,7 +175,8 @@ class DiagnosticMapping {
173175

174176
/// Used for handling and querying diagnostic IDs.
175177
///
176-
/// Can be used and shared by multiple Diagnostics for multiple translation units.
178+
/// Can be used and shared by multiple Diagnostics for multiple translation
179+
/// units.
177180
class DiagnosticIDs : public RefCountedBase<DiagnosticIDs> {
178181
public:
179182
/// The level of the diagnostic, after it has been through mapping.
@@ -498,6 +501,6 @@ class DiagnosticIDs : public RefCountedBase<DiagnosticIDs> {
498501
friend class DiagnosticsEngine;
499502
};
500503

501-
} // end namespace clang
504+
} // end namespace clang
502505

503506
#endif

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

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,45 @@ class CIR_UnitAttr<string name, string attrMnemonic, list<Trait> traits = []>
5050
let isOptional = 1;
5151
}
5252

53+
//===----------------------------------------------------------------------===//
54+
// SourceLanguageAttr
55+
//===----------------------------------------------------------------------===//
56+
57+
// TODO: Add cases for other languages that Clang supports.
58+
59+
def CIR_SourceLanguage : CIR_I32EnumAttr<"SourceLanguage", "source language", [
60+
I32EnumAttrCase<"C", 1, "c">,
61+
I32EnumAttrCase<"CXX", 2, "cxx">
62+
]> {
63+
// The enum attr class is defined in `CIR_SourceLanguageAttr` below,
64+
// so that it can define extra class methods.
65+
let genSpecializedAttr = 0;
66+
}
67+
68+
def CIR_SourceLanguageAttr : CIR_EnumAttr<CIR_SourceLanguage, "lang"> {
69+
70+
let summary = "Module source language";
71+
let description = [{
72+
Represents the source language used to generate the module.
73+
74+
Example:
75+
```
76+
// Module compiled from C.
77+
module attributes {cir.lang = cir.lang<c>} {}
78+
// Module compiled from C++.
79+
module attributes {cir.lang = cir.lang<cxx>} {}
80+
```
81+
82+
Module source language attribute name is `cir.lang` is defined by
83+
`getSourceLanguageAttrName` method in CIRDialect class.
84+
}];
85+
86+
let extraClassDeclaration = [{
87+
bool isC() const { return getValue() == SourceLanguage::C; }
88+
bool isCXX() const { return getValue() == SourceLanguage::CXX; }
89+
}];
90+
}
91+
5392
//===----------------------------------------------------------------------===//
5493
// OptInfoAttr
5594
//===----------------------------------------------------------------------===//
@@ -496,6 +535,72 @@ def CIR_GlobalViewAttr : CIR_Attr<"GlobalView", "global_view", [
496535
}];
497536
}
498537

538+
//===----------------------------------------------------------------------===//
539+
// VTableAttr
540+
//===----------------------------------------------------------------------===//
541+
542+
def CIR_VTableAttr : CIR_Attr<"VTable", "vtable", [TypedAttrInterface]> {
543+
let summary = "Represents a C++ vtable";
544+
let description = [{
545+
Wraps a #cir.const_record containing one or more vtable arrays.
546+
547+
In most cases, the anonymous record type wrapped by this attribute will
548+
contain a single array corresponding to the vtable for one class. However,
549+
in the case of multiple inheritence, the anonymous structure may contain
550+
multiple arrays, each of which is a vtable.
551+
552+
Example 1 (single vtable):
553+
```mlir
554+
cir.global linkonce_odr @_ZTV6Mother =
555+
#cir.vtable<{
556+
#cir.const_array<[
557+
#cir.ptr<null> : !cir.ptr<!u8i>,
558+
#cir.global_view<@_ZTI6Mother> : !cir.ptr<!u8i>,
559+
#cir.global_view<@_ZN6Mother9MotherFooEv> : !cir.ptr<!u8i>,
560+
#cir.global_view<@_ZN6Mother10MotherFoo2Ev> : !cir.ptr<!u8i>
561+
]> : !cir.array<!cir.ptr<!u8i> x 4>
562+
}> : !rec_anon_struct1
563+
```
564+
565+
Example 2 (multiple vtables):
566+
```mlir
567+
cir.global linkonce_odr @_ZTV5Child =
568+
#cir.vtable<{
569+
#cir.const_array<[
570+
#cir.ptr<null> : !cir.ptr<!u8i>,
571+
#cir.global_view<@_ZTI5Child> : !cir.ptr<!u8i>,
572+
#cir.global_view<@_ZN5Child9MotherFooEv> : !cir.ptr<!u8i>,
573+
#cir.global_view<@_ZN6Mother10MotherFoo2Ev> : !cir.ptr<!u8i>
574+
]> : !cir.array<!cir.ptr<!u8i> x 4>,
575+
#cir.const_array<[
576+
#cir.ptr<-8 : i64> : !cir.ptr<!u8i>,
577+
#cir.global_view<@_ZTI5Child> : !cir.ptr<!u8i>,
578+
#cir.global_view<@_ZN6Father9FatherFooEv> : !cir.ptr<!u8i>
579+
]> : !cir.array<!cir.ptr<!u8i> x 3>
580+
}> : !rec_anon_struct2
581+
```
582+
}];
583+
584+
// `data` is a const record with one element, containing an array of
585+
// vtable information.
586+
let parameters = (ins
587+
AttributeSelfTypeParameter<"">:$type,
588+
"mlir::ArrayAttr":$data
589+
);
590+
591+
let builders = [
592+
AttrBuilderWithInferredContext<(ins "mlir::Type":$type,
593+
"mlir::ArrayAttr":$data), [{
594+
return $_get(type.getContext(), type, data);
595+
}]>
596+
];
597+
598+
let genVerifyDecl = 1;
599+
let assemblyFormat = [{
600+
`<` custom<RecordMembers>($data) `>`
601+
}];
602+
}
603+
499604
//===----------------------------------------------------------------------===//
500605
// ConstComplexAttr
501606
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)