Skip to content

Commit b9b30a3

Browse files
committed
merge main into amd-staging
2 parents e2c2815 + 1b30e49 commit b9b30a3

File tree

74 files changed

+1709
-1140
lines changed

Some content is hidden

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

74 files changed

+1709
-1140
lines changed

clang-tools-extra/clang-tidy/bugprone/SignedCharMisuseCheck.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ static constexpr int UnsignedASCIIUpperBound = 127;
2121
SignedCharMisuseCheck::SignedCharMisuseCheck(StringRef Name,
2222
ClangTidyContext *Context)
2323
: ClangTidyCheck(Name, Context),
24-
CharTypdefsToIgnoreList(Options.get("CharTypdefsToIgnore", "")),
24+
CharTypedefsToIgnoreList(Options.get("CharTypedefsToIgnore", "")),
2525
DiagnoseSignedUnsignedCharComparisons(
2626
Options.get("DiagnoseSignedUnsignedCharComparisons", true)) {}
2727

2828
void SignedCharMisuseCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
29-
Options.store(Opts, "CharTypdefsToIgnore", CharTypdefsToIgnoreList);
29+
Options.store(Opts, "CharTypedefsToIgnore", CharTypedefsToIgnoreList);
3030
Options.store(Opts, "DiagnoseSignedUnsignedCharComparisons",
3131
DiagnoseSignedUnsignedCharComparisons);
3232
}
@@ -39,7 +39,7 @@ BindableMatcher<clang::Stmt> SignedCharMisuseCheck::charCastExpression(
3939
// (e.g. typedef char sal_Int8). In this case, we don't need to
4040
// worry about the misinterpretation of char values.
4141
const auto IntTypedef = qualType(hasDeclaration(typedefDecl(
42-
hasAnyName(utils::options::parseStringList(CharTypdefsToIgnoreList)))));
42+
hasAnyName(utils::options::parseStringList(CharTypedefsToIgnoreList)))));
4343

4444
auto CharTypeExpr = expr();
4545
if (IsSigned) {

clang-tools-extra/clang-tidy/bugprone/SignedCharMisuseCheck.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class SignedCharMisuseCheck : public ClangTidyCheck {
3535
const ast_matchers::internal::Matcher<clang::QualType> &IntegerType,
3636
const std::string &CastBindName) const;
3737

38-
const StringRef CharTypdefsToIgnoreList;
38+
const StringRef CharTypedefsToIgnoreList;
3939
const bool DiagnoseSignedUnsignedCharComparisons;
4040
};
4141

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,17 @@ Potentially Breaking Changes
5454
:program:`clang-tidy-20`. Users should use the check-specific options of the
5555
same name instead.
5656

57-
- Renamed :program:`clang-tidy`'s option name of check
58-
:doc:`bugprone-easily-swappable-parameters
59-
<clang-tidy/checks/bugprone/easily-swappable-parameters>` from
60-
``NamePrefixSuffixSilenceDissimilarityTreshold`` to
61-
``NamePrefixSuffixSilenceDissimilarityThreshold``,
62-
correcting a spelling mistake.
57+
- Renamed a few :program:`clang-tidy` check options, as they
58+
were misspelled:
59+
60+
- `NamePrefixSuffixSilenceDissimilarityTreshold` to
61+
`NamePrefixSuffixSilenceDissimilarityThreshold` in
62+
:doc:`bugprone-easily-swappable-parameters
63+
<clang-tidy/checks/bugprone/easily-swappable-parameters>`
64+
65+
- `CharTypdefsToIgnore` to `CharTypedefsToIgnore` in
66+
:doc:`bugprone-signed-char-misuse
67+
<clang-tidy/checks/bugprone/signed-char-misuse>`
6368

6469
Improvements to clangd
6570
----------------------

clang-tools-extra/docs/clang-tidy/checks/bugprone/signed-char-misuse.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ so both arguments will have the same type.
107107
Options
108108
-------
109109

110-
.. option:: CharTypdefsToIgnore
110+
.. option:: CharTypedefsToIgnore
111111

112112
A semicolon-separated list of typedef names. In this list, we can list
113113
typedefs for ``char`` or ``signed char``, which will be ignored by the

clang-tools-extra/test/clang-tidy/checkers/bugprone/signed-char-misuse-with-option.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// RUN: %check_clang_tidy %s bugprone-signed-char-misuse %t \
22
// RUN: -config='{CheckOptions: \
3-
// RUN: {bugprone-signed-char-misuse.CharTypdefsToIgnore: "sal_Int8;int8_t"}}' \
3+
// RUN: {bugprone-signed-char-misuse.CharTypedefsToIgnore: "sal_Int8;int8_t"}}' \
44
// RUN: --
55

66
///////////////////////////////////////////////////////////////////

clang/include/clang/CIR/Dialect/Builder/CIRBaseBuilder.h

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#define LLVM_CLANG_CIR_DIALECT_BUILDER_CIRBASEBUILDER_H
1111

1212
#include "clang/AST/CharUnits.h"
13+
#include "clang/Basic/AddressSpaces.h"
1314
#include "clang/CIR/Dialect/IR/CIRAttrs.h"
1415
#include "clang/CIR/Dialect/IR/CIRDialect.h"
1516
#include "clang/CIR/Dialect/IR/CIRTypes.h"
@@ -129,8 +130,30 @@ class CIRBaseBuilderTy : public mlir::OpBuilder {
129130
return cir::PointerType::get(ty);
130131
}
131132

132-
cir::PointerType getVoidPtrTy() {
133-
return getPointerTo(cir::VoidType::get(getContext()));
133+
cir::PointerType getPointerTo(mlir::Type ty, cir::TargetAddressSpaceAttr as) {
134+
return cir::PointerType::get(ty, as);
135+
}
136+
137+
cir::PointerType getPointerTo(mlir::Type ty, clang::LangAS langAS) {
138+
if (langAS == clang::LangAS::Default) // Default address space.
139+
return getPointerTo(ty);
140+
141+
if (clang::isTargetAddressSpace(langAS)) {
142+
unsigned addrSpace = clang::toTargetAddressSpace(langAS);
143+
auto asAttr = cir::TargetAddressSpaceAttr::get(
144+
getContext(), getUI32IntegerAttr(addrSpace));
145+
return getPointerTo(ty, asAttr);
146+
}
147+
148+
llvm_unreachable("language-specific address spaces NYI");
149+
}
150+
151+
cir::PointerType getVoidPtrTy(clang::LangAS langAS = clang::LangAS::Default) {
152+
return getPointerTo(cir::VoidType::get(getContext()), langAS);
153+
}
154+
155+
cir::PointerType getVoidPtrTy(cir::TargetAddressSpaceAttr as) {
156+
return getPointerTo(cir::VoidType::get(getContext()), as);
134157
}
135158

136159
cir::BoolAttr getCIRBoolAttr(bool state) {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
#include "mlir/IR/Attributes.h"
1717
#include "mlir/IR/BuiltinAttributeInterfaces.h"
18+
#include "clang/Basic/AddressSpaces.h"
1819

1920
#include "clang/CIR/Dialect/IR/CIROpsEnums.h"
2021

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,33 @@ def CIR_VTableAttr : CIR_Attr<"VTable", "vtable", [TypedAttrInterface]> {
601601
}];
602602
}
603603

604+
//===----------------------------------------------------------------------===//
605+
// TargetAddressSpaceAttr
606+
//===----------------------------------------------------------------------===//
607+
608+
def CIR_TargetAddressSpaceAttr : CIR_Attr< "TargetAddressSpace",
609+
"target_address_space"> {
610+
let summary = "Represents a target-specific numeric address space";
611+
let description = [{
612+
The TargetAddressSpaceAttr represents a target-specific numeric address space,
613+
corresponding to the LLVM IR `addressspace` qualifier and the clang
614+
`address_space` attribute.
615+
616+
A value of zero represents the default address space. The semantics of non-zero
617+
address spaces are target-specific.
618+
619+
Example:
620+
```mlir
621+
// Target-specific numeric address spaces
622+
!cir.ptr<!s32i, addrspace(target<1>)>
623+
!cir.ptr<!s32i, addrspace(target<10>)>
624+
```
625+
}];
626+
627+
let parameters = (ins "mlir::IntegerAttr":$value);
628+
let assemblyFormat = "`<` `target` `<` $value `>` `>`";
629+
}
630+
604631
//===----------------------------------------------------------------------===//
605632
// ConstComplexAttr
606633
//===----------------------------------------------------------------------===//

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
#include "mlir/IR/BuiltinAttributes.h"
1717
#include "mlir/IR/Types.h"
1818
#include "mlir/Interfaces/DataLayoutInterfaces.h"
19+
#include "clang/Basic/AddressSpaces.h"
20+
#include "clang/CIR/Dialect/IR/CIRAttrs.h"
21+
#include "clang/CIR/Dialect/IR/CIROpsEnums.h"
1922
#include "clang/CIR/Interfaces/CIRTypeInterfaces.h"
2023

2124
namespace cir {

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

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,12 @@
1414
#define CLANG_CIR_DIALECT_IR_CIRTYPES_TD
1515

1616
include "clang/CIR/Dialect/IR/CIRDialect.td"
17+
include "clang/CIR/Dialect/IR/CIREnumAttr.td"
1718
include "clang/CIR/Dialect/IR/CIRTypeConstraints.td"
1819
include "clang/CIR/Interfaces/CIRTypeInterfaces.td"
1920
include "mlir/Interfaces/DataLayoutInterfaces.td"
2021
include "mlir/IR/AttrTypeBase.td"
22+
include "mlir/IR/EnumAttr.td"
2123

2224
//===----------------------------------------------------------------------===//
2325
// CIR Types
@@ -226,32 +228,54 @@ def CIR_PointerType : CIR_Type<"Pointer", "ptr", [
226228
]> {
227229
let summary = "CIR pointer type";
228230
let description = [{
229-
The `!cir.ptr` type represents C and C++ pointer types and C++ reference
230-
types, other than pointers-to-members. The `pointee` type is the type
231-
pointed to.
231+
The `!cir.ptr` type is a typed pointer type. It is used to represent
232+
pointers to objects in C/C++. The type of the pointed-to object is given by
233+
the `pointee` parameter. The `addrSpace` parameter is an optional address
234+
space attribute that specifies the address space of the pointer. If not
235+
specified, the pointer is assumed to be in the default address space.
232236

233-
TODO(CIR): The address space attribute is not yet implemented.
237+
The `!cir.ptr` type can point to any type, including fundamental types,
238+
records, arrays, vectors, functions, and other pointers. It can also point
239+
to incomplete types, such as incomplete records.
240+
241+
Examples:
242+
243+
```mlir
244+
!cir.ptr<!cir.int<u, 8>>
245+
!cir.ptr<!cir.float>
246+
!cir.ptr<!cir.record<struct "MyStruct">>
247+
!cir.ptr<!cir.int<u, 8>, target_address_space(1)>
248+
!cir.ptr<!cir.record<struct "MyStruct">, target_address_space(5)>
249+
```
234250
}];
235251

236-
let parameters = (ins "mlir::Type":$pointee);
252+
let parameters = (ins
253+
"mlir::Type":$pointee,
254+
OptionalParameter<
255+
"cir::TargetAddressSpaceAttr">:$addrSpace
256+
);
237257

258+
let skipDefaultBuilders = 1;
238259
let builders = [
239-
TypeBuilderWithInferredContext<(ins "mlir::Type":$pointee), [{
240-
return $_get(pointee.getContext(), pointee);
260+
TypeBuilderWithInferredContext<(ins
261+
"mlir::Type":$pointee,
262+
CArg<"cir::TargetAddressSpaceAttr", "nullptr">:$addrSpace), [{
263+
return $_get(pointee.getContext(), pointee, addrSpace);
241264
}]>,
242-
TypeBuilder<(ins "mlir::Type":$pointee), [{
243-
return $_get($_ctxt, pointee);
265+
TypeBuilder<(ins
266+
"mlir::Type":$pointee,
267+
CArg<"cir::TargetAddressSpaceAttr", "nullptr">:$addrSpace), [{
268+
return $_get($_ctxt, pointee, addrSpace);
244269
}]>
245270
];
246271

247272
let assemblyFormat = [{
248-
`<` $pointee `>`
273+
`<`
274+
$pointee
275+
( `,` ` ` custom<TargetAddressSpace>($addrSpace)^ )?
276+
`>`
249277
}];
250278

251-
let genVerifyDecl = 1;
252-
253-
let skipDefaultBuilders = 1;
254-
255279
let extraClassDeclaration = [{
256280
template <typename ...Types>
257281
bool isPtrTo() const {

0 commit comments

Comments
 (0)