Skip to content

Commit 7bfad56

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:e9c8d42b895f into amd-gfx:0060f297760d
Local branch amd-gfx 0060f29 [AMDGPU] Add option to disable VALU sinking and hoisting with WWM (llvm#875) Remote branch main e9c8d42 [clang-tidy] `misc-unused-using-decls`: add correct handling of `operator""` with template parametes (llvm#129392)
2 parents 0060f29 + e9c8d42 commit 7bfad56

File tree

79 files changed

+2036
-921
lines changed

Some content is hidden

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

79 files changed

+2036
-921
lines changed

clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,16 @@ void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) {
184184
return;
185185
}
186186
// Check user-defined literals
187-
if (const auto *UDL = Result.Nodes.getNodeAs<UserDefinedLiteral>("used"))
188-
removeFromFoundDecls(UDL->getCalleeDecl());
187+
if (const auto *UDL = Result.Nodes.getNodeAs<UserDefinedLiteral>("used")) {
188+
const Decl *CalleeDecl = UDL->getCalleeDecl();
189+
if (const auto *FD = dyn_cast<FunctionDecl>(CalleeDecl)) {
190+
if (const FunctionTemplateDecl *FPT = FD->getPrimaryTemplate()) {
191+
removeFromFoundDecls(FPT);
192+
return;
193+
}
194+
}
195+
removeFromFoundDecls(CalleeDecl);
196+
}
189197
}
190198

191199
void UnusedUsingDeclsCheck::removeFromFoundDecls(const Decl *D) {

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@ Changes in existing checks
138138
<clang-tidy/checks/performance/move-const-arg>` check by fixing false negatives
139139
on ternary operators calling ``std::move``.
140140

141+
- Improved :doc:`misc-unused-using-decls
142+
<clang-tidy/checks/misc/unused-using-decls>` check by fixing false positives
143+
on ``operator""`` with template parameters.
144+
141145
Removed checks
142146
^^^^^^^^^^^^^^
143147

clang-tools-extra/test/clang-tidy/checkers/misc/unused-using-decls.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,3 +222,19 @@ using gh69714::StructGH69714_1;
222222
using gh69714::StructGH69714_2;
223223
struct StructGH69714_1 a;
224224
struct StructGH69714_2 *b;
225+
226+
namespace gh53444 {
227+
namespace my_literals {
228+
template <char... Ts>
229+
int operator""_r() {
230+
return {};
231+
}
232+
}
233+
234+
using my_literals::operator"" _r;
235+
236+
int foo() {
237+
auto x2 = 123_r;
238+
}
239+
240+
}

clang/include/clang-c/Index.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3061,6 +3061,18 @@ enum CXCallingConv {
30613061
CXCallingConv_M68kRTD = 19,
30623062
CXCallingConv_PreserveNone = 20,
30633063
CXCallingConv_RISCVVectorCall = 21,
3064+
CXCallingConv_RISCVVLSCall_32 = 22,
3065+
CXCallingConv_RISCVVLSCall_64 = 23,
3066+
CXCallingConv_RISCVVLSCall_128 = 24,
3067+
CXCallingConv_RISCVVLSCall_256 = 25,
3068+
CXCallingConv_RISCVVLSCall_512 = 26,
3069+
CXCallingConv_RISCVVLSCall_1024 = 27,
3070+
CXCallingConv_RISCVVLSCall_2048 = 28,
3071+
CXCallingConv_RISCVVLSCall_4096 = 29,
3072+
CXCallingConv_RISCVVLSCall_8192 = 30,
3073+
CXCallingConv_RISCVVLSCall_16384 = 31,
3074+
CXCallingConv_RISCVVLSCall_32768 = 32,
3075+
CXCallingConv_RISCVVLSCall_65536 = 33,
30643076

30653077
CXCallingConv_Invalid = 100,
30663078
CXCallingConv_Unexposed = 200

clang/include/clang/AST/Type.h

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1946,7 +1946,7 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
19461946
/// Extra information which affects how the function is called, like
19471947
/// regparm and the calling convention.
19481948
LLVM_PREFERRED_TYPE(CallingConv)
1949-
unsigned ExtInfo : 13;
1949+
unsigned ExtInfo : 14;
19501950

19511951
/// The ref-qualifier associated with a \c FunctionProtoType.
19521952
///
@@ -4438,19 +4438,16 @@ class FunctionType : public Type {
44384438
// Type::FunctionTypeBitfields::ExtInfo as well.
44394439

44404440
// | CC |noreturn|produces|nocallersavedregs|regparm|nocfcheck|cmsenscall|
4441-
// |0 .. 4| 5 | 6 | 7 |8 .. 10| 11 | 12 |
4441+
// |0 .. 5| 6 | 7 | 8 |9 .. 11| 12 | 13 |
44424442
//
44434443
// regparm is either 0 (no regparm attribute) or the regparm value+1.
4444-
enum { CallConvMask = 0x1F };
4445-
enum { NoReturnMask = 0x20 };
4446-
enum { ProducesResultMask = 0x40 };
4447-
enum { NoCallerSavedRegsMask = 0x80 };
4448-
enum {
4449-
RegParmMask = 0x700,
4450-
RegParmOffset = 8
4451-
};
4452-
enum { NoCfCheckMask = 0x800 };
4453-
enum { CmseNSCallMask = 0x1000 };
4444+
enum { CallConvMask = 0x3F };
4445+
enum { NoReturnMask = 0x40 };
4446+
enum { ProducesResultMask = 0x80 };
4447+
enum { NoCallerSavedRegsMask = 0x100 };
4448+
enum { RegParmMask = 0xe00, RegParmOffset = 9 };
4449+
enum { NoCfCheckMask = 0x1000 };
4450+
enum { CmseNSCallMask = 0x2000 };
44544451
uint16_t Bits = CC_C;
44554452

44564453
ExtInfo(unsigned Bits) : Bits(static_cast<uint16_t>(Bits)) {}

clang/include/clang/Basic/Attr.td

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3316,6 +3316,14 @@ def RISCVVectorCC: DeclOrTypeAttr, TargetSpecificAttr<TargetRISCV> {
33163316
let Documentation = [RISCVVectorCCDocs];
33173317
}
33183318

3319+
def RISCVVLSCC: DeclOrTypeAttr, TargetSpecificAttr<TargetRISCV> {
3320+
let Spellings = [CXX11<"riscv", "vls_cc">,
3321+
C23<"riscv", "vls_cc">,
3322+
Clang<"riscv_vls_cc">];
3323+
let Args = [UnsignedArgument<"VectorWidth", /*opt*/1>];
3324+
let Documentation = [RISCVVLSCCDocs];
3325+
}
3326+
33193327
def Target : InheritableAttr {
33203328
let Spellings = [GCC<"target">];
33213329
let Args = [StringArgument<"featuresStr">];

clang/include/clang/Basic/AttrDocs.td

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6214,6 +6214,17 @@ them if they use them.
62146214
}];
62156215
}
62166216

6217+
def RISCVVLSCCDocs : Documentation {
6218+
let Category = DocCatCallingConvs;
6219+
let Heading = "riscv::vls_cc, riscv_vls_cc, clang::riscv_vls_cc";
6220+
let Content = [{
6221+
The ``riscv_vls_cc`` attribute can be applied to a function. Functions
6222+
declared with this attribute will utilize the standard fixed-length vector
6223+
calling convention variant instead of the default calling convention defined by
6224+
the ABI. This variant aims to pass fixed-length vectors via vector registers,
6225+
if possible, rather than through general-purpose registers.}];
6226+
}
6227+
62176228
def PreferredNameDocs : Documentation {
62186229
let Category = DocCatDecl;
62196230
let Content = [{

clang/include/clang/Basic/Specifiers.h

Lines changed: 37 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -276,30 +276,43 @@ namespace clang {
276276

277277
/// CallingConv - Specifies the calling convention that a function uses.
278278
enum CallingConv {
279-
CC_C, // __attribute__((cdecl))
280-
CC_X86StdCall, // __attribute__((stdcall))
281-
CC_X86FastCall, // __attribute__((fastcall))
282-
CC_X86ThisCall, // __attribute__((thiscall))
283-
CC_X86VectorCall, // __attribute__((vectorcall))
284-
CC_X86Pascal, // __attribute__((pascal))
285-
CC_Win64, // __attribute__((ms_abi))
286-
CC_X86_64SysV, // __attribute__((sysv_abi))
287-
CC_X86RegCall, // __attribute__((regcall))
288-
CC_AAPCS, // __attribute__((pcs("aapcs")))
289-
CC_AAPCS_VFP, // __attribute__((pcs("aapcs-vfp")))
290-
CC_IntelOclBicc, // __attribute__((intel_ocl_bicc))
291-
CC_SpirFunction, // default for OpenCL functions on SPIR target
292-
CC_OpenCLKernel, // inferred for OpenCL kernels
293-
CC_Swift, // __attribute__((swiftcall))
294-
CC_SwiftAsync, // __attribute__((swiftasynccall))
295-
CC_PreserveMost, // __attribute__((preserve_most))
296-
CC_PreserveAll, // __attribute__((preserve_all))
297-
CC_AArch64VectorCall, // __attribute__((aarch64_vector_pcs))
298-
CC_AArch64SVEPCS, // __attribute__((aarch64_sve_pcs))
299-
CC_AMDGPUKernelCall, // __attribute__((amdgpu_kernel))
300-
CC_M68kRTD, // __attribute__((m68k_rtd))
301-
CC_PreserveNone, // __attribute__((preserve_none))
302-
CC_RISCVVectorCall, // __attribute__((riscv_vector_cc))
279+
CC_C, // __attribute__((cdecl))
280+
CC_X86StdCall, // __attribute__((stdcall))
281+
CC_X86FastCall, // __attribute__((fastcall))
282+
CC_X86ThisCall, // __attribute__((thiscall))
283+
CC_X86VectorCall, // __attribute__((vectorcall))
284+
CC_X86Pascal, // __attribute__((pascal))
285+
CC_Win64, // __attribute__((ms_abi))
286+
CC_X86_64SysV, // __attribute__((sysv_abi))
287+
CC_X86RegCall, // __attribute__((regcall))
288+
CC_AAPCS, // __attribute__((pcs("aapcs")))
289+
CC_AAPCS_VFP, // __attribute__((pcs("aapcs-vfp")))
290+
CC_IntelOclBicc, // __attribute__((intel_ocl_bicc))
291+
CC_SpirFunction, // default for OpenCL functions on SPIR target
292+
CC_OpenCLKernel, // inferred for OpenCL kernels
293+
CC_Swift, // __attribute__((swiftcall))
294+
CC_SwiftAsync, // __attribute__((swiftasynccall))
295+
CC_PreserveMost, // __attribute__((preserve_most))
296+
CC_PreserveAll, // __attribute__((preserve_all))
297+
CC_AArch64VectorCall, // __attribute__((aarch64_vector_pcs))
298+
CC_AArch64SVEPCS, // __attribute__((aarch64_sve_pcs))
299+
CC_AMDGPUKernelCall, // __attribute__((amdgpu_kernel))
300+
CC_M68kRTD, // __attribute__((m68k_rtd))
301+
CC_PreserveNone, // __attribute__((preserve_none))
302+
CC_RISCVVectorCall, // __attribute__((riscv_vector_cc))
303+
CC_RISCVVLSCall_32, // __attribute__((riscv_vls_cc(32)))
304+
CC_RISCVVLSCall_64, // __attribute__((riscv_vls_cc(64)))
305+
CC_RISCVVLSCall_128, // __attribute__((riscv_vls_cc)) or
306+
// __attribute__((riscv_vls_cc(128)))
307+
CC_RISCVVLSCall_256, // __attribute__((riscv_vls_cc(256)))
308+
CC_RISCVVLSCall_512, // __attribute__((riscv_vls_cc(512)))
309+
CC_RISCVVLSCall_1024, // __attribute__((riscv_vls_cc(1024)))
310+
CC_RISCVVLSCall_2048, // __attribute__((riscv_vls_cc(2048)))
311+
CC_RISCVVLSCall_4096, // __attribute__((riscv_vls_cc(4096)))
312+
CC_RISCVVLSCall_8192, // __attribute__((riscv_vls_cc(8192)))
313+
CC_RISCVVLSCall_16384, // __attribute__((riscv_vls_cc(16384)))
314+
CC_RISCVVLSCall_32768, // __attribute__((riscv_vls_cc(32768)))
315+
CC_RISCVVLSCall_65536, // __attribute__((riscv_vls_cc(65536)))
303316
};
304317

305318
/// Checks whether the given calling convention supports variadic

clang/lib/AST/ItaniumMangle.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3489,6 +3489,20 @@ StringRef CXXNameMangler::getCallingConvQualifierName(CallingConv CC) {
34893489
case CC_M68kRTD:
34903490
case CC_PreserveNone:
34913491
case CC_RISCVVectorCall:
3492+
#define CC_VLS_CASE(ABI_VLEN) case CC_RISCVVLSCall_##ABI_VLEN:
3493+
CC_VLS_CASE(32)
3494+
CC_VLS_CASE(64)
3495+
CC_VLS_CASE(128)
3496+
CC_VLS_CASE(256)
3497+
CC_VLS_CASE(512)
3498+
CC_VLS_CASE(1024)
3499+
CC_VLS_CASE(2048)
3500+
CC_VLS_CASE(4096)
3501+
CC_VLS_CASE(8192)
3502+
CC_VLS_CASE(16384)
3503+
CC_VLS_CASE(32768)
3504+
CC_VLS_CASE(65536)
3505+
#undef CC_VLS_CASE
34923506
// FIXME: we should be mangling all of the above.
34933507
return "";
34943508

clang/lib/AST/Type.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3559,6 +3559,21 @@ StringRef FunctionType::getNameForCallConv(CallingConv CC) {
35593559
case CC_PreserveNone: return "preserve_none";
35603560
// clang-format off
35613561
case CC_RISCVVectorCall: return "riscv_vector_cc";
3562+
#define CC_VLS_CASE(ABI_VLEN) \
3563+
case CC_RISCVVLSCall_##ABI_VLEN: return "riscv_vls_cc(" #ABI_VLEN ")";
3564+
CC_VLS_CASE(32)
3565+
CC_VLS_CASE(64)
3566+
CC_VLS_CASE(128)
3567+
CC_VLS_CASE(256)
3568+
CC_VLS_CASE(512)
3569+
CC_VLS_CASE(1024)
3570+
CC_VLS_CASE(2048)
3571+
CC_VLS_CASE(4096)
3572+
CC_VLS_CASE(8192)
3573+
CC_VLS_CASE(16384)
3574+
CC_VLS_CASE(32768)
3575+
CC_VLS_CASE(65536)
3576+
#undef CC_VLS_CASE
35623577
// clang-format on
35633578
}
35643579

@@ -4226,6 +4241,7 @@ bool AttributedType::isCallingConv() const {
42264241
case attr::M68kRTD:
42274242
case attr::PreserveNone:
42284243
case attr::RISCVVectorCC:
4244+
case attr::RISCVVLSCC:
42294245
return true;
42304246
}
42314247
llvm_unreachable("invalid attr kind");

0 commit comments

Comments
 (0)