Skip to content

Commit 275f049

Browse files
author
iclsrc
committed
Merge from 'main' to 'sycl-web' (84 commits)
2 parents c1748c6 + 8a8ea8f commit 275f049

File tree

324 files changed

+5557
-2770
lines changed

Some content is hidden

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

324 files changed

+5557
-2770
lines changed

clang-tools-extra/clang-tidy/modernize/UseIntegerSignComparisonCheck.cpp

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,28 +39,21 @@ intCastExpression(bool IsSigned,
3939
// std::cmp_{} functions trigger a compile-time error if either LHS or RHS
4040
// is a non-integer type, char, enum or bool
4141
// (unsigned char/ signed char are Ok and can be used).
42-
const auto HasIntegerType = hasType(hasCanonicalType(qualType(
42+
auto IntTypeExpr = expr(hasType(hasCanonicalType(qualType(
4343
isInteger(), IsSigned ? isSignedInteger() : isUnsignedInteger(),
44-
unless(isActualChar()), unless(booleanType()), unless(enumType()))));
45-
46-
const auto IntTypeExpr = expr(HasIntegerType);
44+
unless(isActualChar()), unless(booleanType()), unless(enumType())))));
4745

4846
const auto ImplicitCastExpr =
4947
CastBindName.empty() ? implicitCastExpr(hasSourceExpression(IntTypeExpr))
5048
: implicitCastExpr(hasSourceExpression(IntTypeExpr))
5149
.bind(CastBindName);
5250

53-
const auto ExplicitCastExpr =
54-
anyOf(explicitCastExpr(has(ImplicitCastExpr)),
55-
ignoringImpCasts(explicitCastExpr(has(ImplicitCastExpr))));
56-
57-
// Match function calls or variable references not directly wrapped by an
58-
// implicit cast
59-
const auto CallIntExpr = CastBindName.empty()
60-
? callExpr(HasIntegerType)
61-
: callExpr(HasIntegerType).bind(CastBindName);
51+
const auto CStyleCastExpr = cStyleCastExpr(has(ImplicitCastExpr));
52+
const auto StaticCastExpr = cxxStaticCastExpr(has(ImplicitCastExpr));
53+
const auto FunctionalCastExpr = cxxFunctionalCastExpr(has(ImplicitCastExpr));
6254

63-
return expr(anyOf(ImplicitCastExpr, ExplicitCastExpr, CallIntExpr));
55+
return expr(anyOf(ImplicitCastExpr, CStyleCastExpr, StaticCastExpr,
56+
FunctionalCastExpr));
6457
}
6558

6659
static StringRef parseOpCode(BinaryOperator::Opcode Code) {

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,6 @@ Changes in existing checks
237237
<clang-tidy/checks/modernize/use-designated-initializers>` check by avoiding
238238
diagnosing designated initializers for ``std::array`` initializations.
239239

240-
- Improved :doc:`modernize-use-integer-sign-comparison
241-
<clang-tidy/checks/modernize/use-integer-sign-comparison>` check by matching
242-
valid integer expressions not directly wrapped around an implicit cast.
243-
244240
- Improved :doc:`modernize-use-ranges
245241
<clang-tidy/checks/modernize/use-ranges>` check by updating suppress
246242
warnings logic for ``nullptr`` in ``std::find``.

clang-tools-extra/test/clang-tidy/checkers/modernize/use-integer-sign-comparison.cpp

Lines changed: 0 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -121,81 +121,3 @@ int AllComparisons() {
121121

122122
return 0;
123123
}
124-
125-
namespace PR127471 {
126-
int getSignedValue();
127-
unsigned int getUnsignedValue();
128-
129-
void callExprTest() {
130-
131-
if (getSignedValue() < getUnsignedValue())
132-
return;
133-
// CHECK-MESSAGES: :[[@LINE-2]]:13: warning: comparison between 'signed' and 'unsigned' integers [modernize-use-integer-sign-comparison]
134-
// CHECK-FIXES: if (std::cmp_less(getSignedValue() , getUnsignedValue()))
135-
136-
int sVar = 0;
137-
if (getUnsignedValue() > sVar)
138-
return;
139-
// CHECK-MESSAGES: :[[@LINE-2]]:13: warning: comparison between 'signed' and 'unsigned' integers [modernize-use-integer-sign-comparison]
140-
// CHECK-FIXES: if (std::cmp_greater(getUnsignedValue() , sVar))
141-
142-
unsigned int uVar = 0;
143-
if (getSignedValue() > uVar)
144-
return;
145-
// CHECK-MESSAGES: :[[@LINE-2]]:13: warning: comparison between 'signed' and 'unsigned' integers [modernize-use-integer-sign-comparison]
146-
// CHECK-FIXES: if (std::cmp_greater(getSignedValue() , uVar))
147-
148-
}
149-
150-
// Add a class with member functions for testing member function calls
151-
class TestClass {
152-
public:
153-
int getSignedValue() { return -5; }
154-
unsigned int getUnsignedValue() { return 5; }
155-
};
156-
157-
void memberFunctionTests() {
158-
TestClass obj;
159-
160-
if (obj.getSignedValue() < obj.getUnsignedValue())
161-
return;
162-
// CHECK-MESSAGES: :[[@LINE-2]]:13: warning: comparison between 'signed' and 'unsigned' integers [modernize-use-integer-sign-comparison]
163-
// CHECK-FIXES: if (std::cmp_less(obj.getSignedValue() , obj.getUnsignedValue()))
164-
}
165-
166-
void castFunctionTests() {
167-
// C-style casts with function calls
168-
if ((int)getUnsignedValue() < (unsigned int)getSignedValue())
169-
return;
170-
// CHECK-MESSAGES: :[[@LINE-2]]:13: warning: comparison between 'signed' and 'unsigned' integers [modernize-use-integer-sign-comparison]
171-
// CHECK-FIXES: if (std::cmp_less(getUnsignedValue(),getSignedValue()))
172-
173-
174-
// Static casts with function calls
175-
if (static_cast<int>(getUnsignedValue()) < static_cast<unsigned int>(getSignedValue()))
176-
return;
177-
// CHECK-MESSAGES: :[[@LINE-2]]:13: warning: comparison between 'signed' and 'unsigned' integers [modernize-use-integer-sign-comparison]
178-
// CHECK-FIXES: if (std::cmp_less(getUnsignedValue(),getSignedValue()))
179-
}
180-
181-
// Define tests
182-
#define SIGNED_FUNC getSignedValue()
183-
#define UNSIGNED_FUNC getUnsignedValue()
184-
185-
void defineTests() {
186-
if (SIGNED_FUNC < UNSIGNED_FUNC)
187-
return;
188-
// CHECK-MESSAGES: :[[@LINE-2]]:13: warning: comparison between 'signed' and 'unsigned' integers [modernize-use-integer-sign-comparison]
189-
// CHECK-FIXES: if (std::cmp_less(SIGNED_FUNC , UNSIGNED_FUNC))
190-
}
191-
192-
// Template tests (should not warn)
193-
template <typename T1>
194-
void templateFunctionTest(T1 value) {
195-
if (value() < getUnsignedValue())
196-
return;
197-
198-
if (value() < (getSignedValue() || getUnsignedValue()))
199-
return;
200-
}
201-
} // namespace PR127471

clang/docs/SanitizerSpecialCaseList.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,13 @@ precedence. Here are a few examples.
109109
.. code-block:: bash
110110
111111
$ cat ignorelist1.txt
112-
# test.cc will be instrumented.
112+
# test.cc will not be instrumented.
113113
src:*
114114
src:*/mylib/*=sanitize
115115
src:*/mylib/test.cc
116116
117117
$ cat ignorelist2.txt
118-
# test.cc will not be instrumented.
118+
# test.cc will be instrumented.
119119
src:*
120120
src:*/mylib/test.cc
121121
src:*/mylib/*=sanitize

clang/include/clang/Basic/DiagnosticDriverKinds.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,8 @@ def err_drv_cannot_open_randomize_layout_seed_file : Error<
236236
"cannot read randomize layout seed file '%0'">;
237237
def err_drv_invalid_version_number : Error<
238238
"invalid version number in '%0'">;
239+
def err_drv_invalid_version_number_inferred
240+
: Error<"invalid version number '%0' inferred from '%1'">;
239241
def err_drv_missing_version_number : Error<"missing version number in '%0'">;
240242
def err_drv_kcfi_arity_unsupported_target : Error<
241243
"target '%0' is unsupported by -fsanitize-kcfi-arity">;

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2059,6 +2059,7 @@ def VecCreateOp : CIR_Op<"vec.create", [Pure]> {
20592059
}];
20602060

20612061
let hasVerifier = 1;
2062+
let hasFolder = 1;
20622063
}
20632064

20642065
//===----------------------------------------------------------------------===//

clang/include/clang/CIR/MissingFeatures.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ struct MissingFeatures {
8181
static bool opFuncCPUAndFeaturesAttributes() { return false; }
8282
static bool opFuncSection() { return false; }
8383
static bool opFuncSetComdat() { return false; }
84+
static bool opFuncAttributesForDefinition() { return false; }
8485

8586
// CallOp handling
8687
static bool opCallPseudoDtor() { return false; }
@@ -226,6 +227,9 @@ struct MissingFeatures {
226227
static bool implicitConstructorArgs() { return false; }
227228
static bool intrinsics() { return false; }
228229
static bool attributeNoBuiltin() { return false; }
230+
static bool emitCtorPrologue() { return false; }
231+
static bool thunks() { return false; }
232+
static bool runCleanupsScope() { return false; }
229233

230234
// Missing types
231235
static bool dataMemberType() { return false; }
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// This contains code dealing with C++ code generation.
10+
//
11+
//===----------------------------------------------------------------------===//
12+
13+
#include "CIRGenFunction.h"
14+
#include "CIRGenModule.h"
15+
16+
#include "clang/AST/GlobalDecl.h"
17+
#include "clang/CIR/MissingFeatures.h"
18+
19+
using namespace clang;
20+
using namespace clang::CIRGen;
21+
22+
cir::FuncOp CIRGenModule::codegenCXXStructor(GlobalDecl gd) {
23+
const CIRGenFunctionInfo &fnInfo =
24+
getTypes().arrangeCXXStructorDeclaration(gd);
25+
cir::FuncType funcType = getTypes().getFunctionType(fnInfo);
26+
cir::FuncOp fn = getAddrOfCXXStructor(gd, &fnInfo, /*FnType=*/nullptr,
27+
/*DontDefer=*/true, ForDefinition);
28+
assert(!cir::MissingFeatures::opFuncLinkage());
29+
CIRGenFunction cgf{*this, builder};
30+
curCGF = &cgf;
31+
{
32+
mlir::OpBuilder::InsertionGuard guard(builder);
33+
cgf.generateCode(gd, fn, funcType);
34+
}
35+
curCGF = nullptr;
36+
37+
setNonAliasAttributes(gd, fn);
38+
assert(!cir::MissingFeatures::opFuncAttributesForDefinition());
39+
return fn;
40+
}

clang/lib/CIR/CodeGen/CIRGenCXXABI.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ class CIRGenCXXABI {
3737

3838
void setCXXABIThisValue(CIRGenFunction &cgf, mlir::Value thisPtr);
3939

40+
/// Emit a single constructor/destructor with the gen type from a C++
41+
/// constructor/destructor Decl.
42+
virtual void emitCXXStructor(clang::GlobalDecl gd) = 0;
43+
4044
public:
4145
clang::ImplicitParamDecl *getThisDecl(CIRGenFunction &cgf) {
4246
return cgf.cxxabiThisDecl;
@@ -55,12 +59,19 @@ class CIRGenCXXABI {
5559
return md->getParent();
5660
}
5761

62+
/// Return whether the given global decl needs a VTT (virtual table table)
63+
/// parameter.
64+
virtual bool needsVTTParameter(clang::GlobalDecl gd) { return false; }
65+
5866
/// Build a parameter variable suitable for 'this'.
5967
void buildThisParam(CIRGenFunction &cgf, FunctionArgList &params);
6068

6169
/// Loads the incoming C++ this pointer as it was passed by the caller.
6270
mlir::Value loadIncomingCXXThis(CIRGenFunction &cgf);
6371

72+
/// Emit constructor variants required by this ABI.
73+
virtual void emitCXXConstructors(const clang::CXXConstructorDecl *d) = 0;
74+
6475
/// Returns true if the given constructor or destructor is one of the kinds
6576
/// that the ABI says returns 'this' (only applies when called non-virtually
6677
/// for destructors).

clang/lib/CIR/CodeGen/CIRGenCall.cpp

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,47 @@ arrangeCIRFunctionInfo(CIRGenTypes &cgt, SmallVectorImpl<CanQualType> &prefix,
162162
return cgt.arrangeCIRFunctionInfo(resultType, prefix, required);
163163
}
164164

165+
void CIRGenFunction::emitDelegateCallArg(CallArgList &args,
166+
const VarDecl *param,
167+
SourceLocation loc) {
168+
// StartFunction converted the ABI-lowered parameter(s) into a local alloca.
169+
// We need to turn that into an r-value suitable for emitCall
170+
Address local = getAddrOfLocalVar(param);
171+
172+
QualType type = param->getType();
173+
174+
if (type->getAsCXXRecordDecl()) {
175+
cgm.errorNYI(param->getSourceRange(),
176+
"emitDelegateCallArg: record argument");
177+
return;
178+
}
179+
180+
// GetAddrOfLocalVar returns a pointer-to-pointer for references, but the
181+
// argument needs to be the original pointer.
182+
if (type->isReferenceType()) {
183+
args.add(
184+
RValue::get(builder.createLoad(getLoc(param->getSourceRange()), local)),
185+
type);
186+
} else if (getLangOpts().ObjCAutoRefCount) {
187+
cgm.errorNYI(param->getSourceRange(),
188+
"emitDelegateCallArg: ObjCAutoRefCount");
189+
// For the most part, we just need to load the alloca, except that aggregate
190+
// r-values are actually pointers to temporaries.
191+
} else {
192+
cgm.errorNYI(param->getSourceRange(),
193+
"emitDelegateCallArg: convertTempToRValue");
194+
}
195+
196+
// Deactivate the cleanup for the callee-destructed param that was pushed.
197+
assert(!cir::MissingFeatures::thunks());
198+
if (type->isRecordType() &&
199+
type->castAs<RecordType>()->getDecl()->isParamDestroyedInCallee() &&
200+
param->needsDestruction(getContext())) {
201+
cgm.errorNYI(param->getSourceRange(),
202+
"emitDelegateCallArg: callee-destructed param");
203+
}
204+
}
205+
165206
static const CIRGenFunctionInfo &
166207
arrangeFreeFunctionLikeCall(CIRGenTypes &cgt, CIRGenModule &cgm,
167208
const CallArgList &args,

0 commit comments

Comments
 (0)