Skip to content

Commit aa066f2

Browse files
committed
Merge branch 'main' into hgh/libcxx/nodiscard-to-any
2 parents 6f2551e + 6b75b44 commit aa066f2

File tree

126 files changed

+2182
-2104
lines changed

Some content is hidden

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

126 files changed

+2182
-2104
lines changed

.ci/premerge_advisor_explain.py

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,6 @@ def main(
7979
pr_number: The number of the PR associated with this run.
8080
return_code: The numerical return code of ninja/CMake.
8181
"""
82-
if return_code == 0:
83-
with open("comment", "w") as comment_file_handle:
84-
comment = get_comment(
85-
github_token,
86-
pr_number,
87-
":white_check_mark: With the latest revision this PR passed "
88-
"the premerge checks.",
89-
)
90-
if "id" in comment:
91-
json.dump([comment], comment_file_handle)
9282
junit_objects, ninja_logs = generate_test_report_lib.load_info_from_files(
9383
build_log_files
9484
)
@@ -105,34 +95,42 @@ def main(
10595
explanation_request["failures"].append(
10696
{"name": name, "message": failure_messsage}
10797
)
108-
else:
98+
elif return_code != 0:
10999
ninja_failures = generate_test_report_lib.find_failure_in_ninja_logs(ninja_logs)
110100
for name, failure_message in ninja_failures:
111101
explanation_request["failures"].append(
112102
{"name": name, "message": failure_message}
113103
)
114-
advisor_response = requests.get(
115-
PREMERGE_ADVISOR_URL, json=explanation_request, timeout=5
104+
comments = []
105+
advisor_explanations = []
106+
if return_code != 0:
107+
advisor_response = requests.get(
108+
PREMERGE_ADVISOR_URL, json=explanation_request, timeout=5
109+
)
110+
if advisor_response.status_code == 200:
111+
print(advisor_response.json())
112+
advisor_explanations = advisor_response.json()
113+
else:
114+
print(advisor_response.reason)
115+
comments.append(
116+
get_comment(
117+
github_token,
118+
pr_number,
119+
generate_test_report_lib.generate_report(
120+
generate_test_report_lib.compute_platform_title(),
121+
return_code,
122+
junit_objects,
123+
ninja_logs,
124+
failure_explanations_list=advisor_explanations,
125+
),
126+
)
116127
)
117-
if advisor_response.status_code == 200:
118-
print(advisor_response.json())
119-
comments = [
120-
get_comment(
121-
github_token,
122-
pr_number,
123-
generate_test_report_lib.generate_report(
124-
generate_test_report_lib.compute_platform_title(),
125-
return_code,
126-
junit_objects,
127-
ninja_logs,
128-
failure_explanations_list=advisor_response.json(),
129-
),
130-
)
131-
]
132-
with open("comments", "w") as comment_file_handle:
133-
json.dump(comments, comment_file_handle)
134-
else:
135-
print(advisor_response.reason)
128+
if return_code == 0 and "id" not in comments[0]:
129+
# If the job succeeds and there is not an existing comment, we
130+
# should not write one to reduce noise.
131+
comments = []
132+
with open("comments", "w") as comment_file_handle:
133+
json.dump(comments, comment_file_handle)
136134

137135

138136
if __name__ == "__main__":

clang-tools-extra/include-cleaner/test/lit.cfg.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,25 @@
1+
import os
2+
13
import lit.llvm
24

35
lit.llvm.initialize(lit_config, config)
46
lit.llvm.llvm_config.use_default_substitutions()
57

8+
# TODO: Consolidate the logic for turning on the internal shell by default for all LLVM test suites.
9+
# See https://github.com/llvm/llvm-project/issues/106636 for more details.
10+
#
11+
# We prefer the lit internal shell which provides a better user experience on failures
12+
# and is faster unless the user explicitly disables it with LIT_USE_INTERNAL_SHELL=0
13+
# env var.
14+
use_lit_shell = True
15+
lit_shell_env = os.environ.get("LIT_USE_INTERNAL_SHELL")
16+
if lit_shell_env:
17+
use_lit_shell = lit.util.pythonize_bool(lit_shell_env)
18+
619
config.name = "ClangIncludeCleaner"
720
config.suffixes = [".test", ".c", ".cpp"]
821
config.excludes = ["Inputs"]
9-
config.test_format = lit.formats.ShTest(not lit.llvm.llvm_config.use_lit_shell)
22+
config.test_format = lit.formats.ShTest(not use_lit_shell)
1023
config.test_source_root = config.clang_include_cleaner_source_dir + "/test"
1124
config.test_exec_root = config.clang_include_cleaner_binary_dir + "/test"
1225

clang/docs/ReleaseNotes.rst

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,6 @@ Potentially Breaking Changes
8484
- Downstream projects that previously linked only against ``clangDriver`` may
8585
now (also) need to link against the new ``clangOptions`` library, since
8686
options-related code has been moved out of the Driver into a separate library.
87-
- Clang now supports MSVC vector deleting destructors when targeting Windows.
88-
This means that vtables of classes with virtual destructors will contain a
89-
pointer to vector deleting destructor (instead of scalar deleting destructor)
90-
which in fact is a different symbol with different name and linkage. This
91-
may cause runtime failures if two binaries using the same class defining a
92-
virtual destructor are compiled with different versions of clang.
9387

9488
C/C++ Language Potentially Breaking Changes
9589
-------------------------------------------
@@ -621,8 +615,6 @@ Windows Support
621615
- clang-cl now supports /arch:AVX10.1 and /arch:AVX10.2.
622616
- clang-cl now supports /vlen, /vlen=256 and /vlen=512.
623617

624-
- Clang now supports MSVC vector deleting destructors (GH19772).
625-
626618
LoongArch Support
627619
^^^^^^^^^^^^^^^^^
628620
- Enable linker relaxation by default for loongarch64.

clang/include/clang/AST/ASTContext.h

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -370,18 +370,6 @@ class ASTContext : public RefCountedBase<ASTContext> {
370370
mutable llvm::DenseSet<const FunctionDecl *> DestroyingOperatorDeletes;
371371
mutable llvm::DenseSet<const FunctionDecl *> TypeAwareOperatorNewAndDeletes;
372372

373-
/// Global and array operators delete are only required for MSVC deleting
374-
/// destructors support. Store them here to avoid keeping 4 pointers that are
375-
/// not always used in each redeclaration of the destructor.
376-
mutable llvm::DenseMap<const CXXDestructorDecl *, FunctionDecl *>
377-
OperatorDeletesForVirtualDtor;
378-
mutable llvm::DenseMap<const CXXDestructorDecl *, FunctionDecl *>
379-
GlobalOperatorDeletesForVirtualDtor;
380-
mutable llvm::DenseMap<const CXXDestructorDecl *, FunctionDecl *>
381-
ArrayOperatorDeletesForVirtualDtor;
382-
mutable llvm::DenseMap<const CXXDestructorDecl *, FunctionDecl *>
383-
GlobalArrayOperatorDeletesForVirtualDtor;
384-
385373
/// The next string literal "version" to allocate during constant evaluation.
386374
/// This is used to distinguish between repeated evaluations of the same
387375
/// string literal.
@@ -3485,16 +3473,6 @@ class ASTContext : public RefCountedBase<ASTContext> {
34853473
bool IsTypeAware);
34863474
bool isTypeAwareOperatorNewOrDelete(const FunctionDecl *FD) const;
34873475

3488-
enum OperatorDeleteKind { Regular, GlobalRegular, Array, ArrayGlobal };
3489-
3490-
void addOperatorDeleteForVDtor(const CXXDestructorDecl *Dtor,
3491-
FunctionDecl *OperatorDelete,
3492-
OperatorDeleteKind K) const;
3493-
FunctionDecl *getOperatorDeleteForVDtor(const CXXDestructorDecl *Dtor,
3494-
OperatorDeleteKind K) const;
3495-
bool dtorHasOperatorDelete(const CXXDestructorDecl *Dtor,
3496-
OperatorDeleteKind K) const;
3497-
34983476
/// Retrieve the context for computing mangling numbers in the given
34993477
/// DeclContext.
35003478
MangleNumberingContext &getManglingNumberContext(const DeclContext *DC);

clang/include/clang/AST/ASTMutationListener.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,6 @@ class ASTMutationListener {
9090
virtual void ResolvedOperatorGlobDelete(const CXXDestructorDecl *DD,
9191
const FunctionDecl *GlobDelete) {}
9292

93-
/// A virtual destructor's operator array delete has been resolved.
94-
virtual void ResolvedOperatorArrayDelete(const CXXDestructorDecl *DD,
95-
const FunctionDecl *ArrayDelete) {}
96-
97-
/// A virtual destructor's operator global array delete has been resolved.
98-
virtual void
99-
ResolvedOperatorGlobArrayDelete(const CXXDestructorDecl *DD,
100-
const FunctionDecl *GlobArrayDelete) {}
101-
10293
/// An implicit member got a definition.
10394
virtual void CompletedImplicitDefinition(const FunctionDecl *D) {}
10495

clang/include/clang/AST/DeclCXX.h

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2872,6 +2872,8 @@ class CXXDestructorDecl : public CXXMethodDecl {
28722872

28732873
// FIXME: Don't allocate storage for these except in the first declaration
28742874
// of a virtual destructor.
2875+
FunctionDecl *OperatorDelete = nullptr;
2876+
FunctionDecl *OperatorGlobalDelete = nullptr;
28752877
Expr *OperatorDeleteThisArg = nullptr;
28762878

28772879
CXXDestructorDecl(ASTContext &C, CXXRecordDecl *RD, SourceLocation StartLoc,
@@ -2898,12 +2900,14 @@ class CXXDestructorDecl : public CXXMethodDecl {
28982900

28992901
void setOperatorDelete(FunctionDecl *OD, Expr *ThisArg);
29002902
void setOperatorGlobalDelete(FunctionDecl *OD);
2901-
void setOperatorArrayDelete(FunctionDecl *OD);
2902-
void setGlobalOperatorArrayDelete(FunctionDecl *OD);
2903-
const FunctionDecl *getOperatorDelete() const;
2904-
const FunctionDecl *getOperatorGlobalDelete() const;
2905-
const FunctionDecl *getArrayOperatorDelete() const;
2906-
const FunctionDecl *getGlobalArrayOperatorDelete() const;
2903+
2904+
const FunctionDecl *getOperatorDelete() const {
2905+
return getCanonicalDecl()->OperatorDelete;
2906+
}
2907+
2908+
const FunctionDecl *getOperatorGlobalDelete() const {
2909+
return getCanonicalDecl()->OperatorGlobalDelete;
2910+
}
29072911

29082912
Expr *getOperatorDeleteThisArg() const {
29092913
return getCanonicalDecl()->OperatorDeleteThisArg;

clang/include/clang/AST/VTableBuilder.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ class VTableComponent {
150150

151151
bool isRTTIKind() const { return isRTTIKind(getKind()); }
152152

153-
GlobalDecl getGlobalDecl(bool HasVectorDeletingDtors) const {
153+
GlobalDecl getGlobalDecl() const {
154154
assert(isUsedFunctionPointerKind() &&
155155
"GlobalDecl can be created only from virtual function");
156156

@@ -161,9 +161,7 @@ class VTableComponent {
161161
case CK_CompleteDtorPointer:
162162
return GlobalDecl(DtorDecl, CXXDtorType::Dtor_Complete);
163163
case CK_DeletingDtorPointer:
164-
return GlobalDecl(DtorDecl, (HasVectorDeletingDtors)
165-
? CXXDtorType::Dtor_VectorDeleting
166-
: CXXDtorType::Dtor_Deleting);
164+
return GlobalDecl(DtorDecl, CXXDtorType::Dtor_Deleting);
167165
case CK_VCallOffset:
168166
case CK_VBaseOffset:
169167
case CK_OffsetToTop:

clang/include/clang/Basic/ABI.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,11 @@ enum CXXCtorType {
3232

3333
/// C++ destructor types.
3434
enum CXXDtorType {
35-
Dtor_Deleting, ///< Deleting dtor
36-
Dtor_Complete, ///< Complete object dtor
37-
Dtor_Base, ///< Base object dtor
38-
Dtor_Comdat, ///< The COMDAT used for dtors
39-
Dtor_Unified, ///< GCC-style unified dtor
40-
Dtor_VectorDeleting, ///< Vector deleting dtor
35+
Dtor_Deleting, ///< Deleting dtor
36+
Dtor_Complete, ///< Complete object dtor
37+
Dtor_Base, ///< Base object dtor
38+
Dtor_Comdat, ///< The COMDAT used for dtors
39+
Dtor_Unified, ///< GCC-style unified dtor
4140
};
4241

4342
} // end namespace clang

clang/include/clang/Basic/TargetInfo.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1796,11 +1796,6 @@ class TargetInfo : public TransferrableTargetInfo,
17961796
/// destructor body.
17971797
virtual bool callGlobalDeleteInDeletingDtor(const LangOptions &) const;
17981798

1799-
/// Controls whether to emit MSVC vector deleting destructors. The support for
1800-
/// vector deleting affects vtable layout and therefore is an ABI breaking
1801-
/// change. The support was only implemented at Clang 22 timeframe.
1802-
virtual bool emitVectorDeletingDtors(const LangOptions &) const;
1803-
18041799
/// Controls if __builtin_longjmp / __builtin_setjmp can be lowered to
18051800
/// llvm.eh.sjlj.longjmp / llvm.eh.sjlj.setjmp.
18061801
virtual bool hasSjLjLowering() const {

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

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1640,6 +1640,82 @@ def CIR_CmpOp : CIR_Op<"cmp", [Pure, SameTypeOperands]> {
16401640
let isLLVMLoweringRecursive = true;
16411641
}
16421642

1643+
//===----------------------------------------------------------------------===//
1644+
// BinOpOverflowOp
1645+
//===----------------------------------------------------------------------===//
1646+
1647+
def CIR_BinOpOverflowKind : CIR_I32EnumAttr<
1648+
"BinOpOverflowKind", "checked binary arithmetic operation kind", [
1649+
I32EnumAttrCase<"Add", 0, "add">,
1650+
I32EnumAttrCase<"Sub", 1, "sub">,
1651+
I32EnumAttrCase<"Mul", 2, "mul">
1652+
]>;
1653+
1654+
def CIR_BinOpOverflowOp : CIR_Op<"binop.overflow", [Pure, SameTypeOperands]> {
1655+
let summary = "Perform binary integral arithmetic with overflow checking";
1656+
let description = [{
1657+
`cir.binop.overflow` performs binary arithmetic operations with overflow
1658+
checking on integral operands.
1659+
1660+
The `kind` argument specifies the kind of arithmetic operation to perform.
1661+
It can be either `add`, `sub`, or `mul`. The `lhs` and `rhs` arguments
1662+
specify the input operands of the arithmetic operation. The types of `lhs`
1663+
and `rhs` must be the same.
1664+
1665+
`cir.binop.overflow` produces two SSA values. `result` is the result of the
1666+
arithmetic operation truncated to its specified type. `overflow` is a
1667+
boolean value indicating whether overflow happens during the operation.
1668+
1669+
The exact semantic of this operation is as follows:
1670+
1671+
- `lhs` and `rhs` are promoted to an imaginary integral type that has
1672+
infinite precision.
1673+
- The arithmetic operation is performed on the promoted operands.
1674+
- The infinite-precision result is truncated to the type of `result`. The
1675+
truncated result is assigned to `result`.
1676+
- If the truncated result is equal to the un-truncated result, `overflow`
1677+
is assigned to false. Otherwise, `overflow` is assigned to true.
1678+
}];
1679+
1680+
let arguments = (ins
1681+
CIR_BinOpOverflowKind:$kind,
1682+
CIR_IntType:$lhs,
1683+
CIR_IntType:$rhs
1684+
);
1685+
1686+
let results = (outs CIR_IntType:$result, CIR_BoolType:$overflow);
1687+
1688+
let assemblyFormat = [{
1689+
`(` $kind `,` $lhs `,` $rhs `)` `:` qualified(type($lhs)) `,`
1690+
`(` qualified(type($result)) `,` qualified(type($overflow)) `)`
1691+
attr-dict
1692+
}];
1693+
1694+
let builders = [
1695+
OpBuilder<(ins "cir::IntType":$resultTy,
1696+
"cir::BinOpOverflowKind":$kind,
1697+
"mlir::Value":$lhs,
1698+
"mlir::Value":$rhs), [{
1699+
auto overflowTy = cir::BoolType::get($_builder.getContext());
1700+
build($_builder, $_state, resultTy, overflowTy, kind, lhs, rhs);
1701+
}]>
1702+
];
1703+
1704+
let extraLLVMLoweringPatternDecl = [{
1705+
static std::string getLLVMIntrinName(cir::BinOpOverflowKind opKind,
1706+
bool isSigned, unsigned width);
1707+
1708+
struct EncompassedTypeInfo {
1709+
bool sign;
1710+
unsigned width;
1711+
};
1712+
1713+
static EncompassedTypeInfo computeEncompassedTypeWidth(cir::IntType operandTy,
1714+
cir::IntType resultTy);
1715+
}];
1716+
}
1717+
1718+
16431719
//===----------------------------------------------------------------------===//
16441720
// BinOp
16451721
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)