Skip to content

Commit 954f797

Browse files
committed
[𝘀𝗽𝗿] changes introduced through rebase
Created using spr 1.3.4 [skip ci]
2 parents b4ae58e + cb8495c commit 954f797

File tree

28 files changed

+507
-175
lines changed

28 files changed

+507
-175
lines changed

clang/lib/AST/ExprConstant.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2232,10 +2232,15 @@ static bool ArePotentiallyOverlappingStringLiterals(const EvalInfo &Info,
22322232
// within RHS. We don't need to look at the characters of one string that
22332233
// would appear before the start of the other string if they were merged.
22342234
CharUnits Offset = RHS.Offset - LHS.Offset;
2235-
if (Offset.isNegative())
2235+
if (Offset.isNegative()) {
2236+
if (LHSString.Bytes.size() < (size_t)-Offset.getQuantity())
2237+
return false;
22362238
LHSString.Bytes = LHSString.Bytes.drop_front(-Offset.getQuantity());
2237-
else
2239+
} else {
2240+
if (RHSString.Bytes.size() < (size_t)Offset.getQuantity())
2241+
return false;
22382242
RHSString.Bytes = RHSString.Bytes.drop_front(Offset.getQuantity());
2243+
}
22392244

22402245
bool LHSIsLonger = LHSString.Bytes.size() > RHSString.Bytes.size();
22412246
StringRef Longer = LHSIsLonger ? LHSString.Bytes : RHSString.Bytes;

clang/lib/Serialization/ASTReaderDecl.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1076,6 +1076,8 @@ void ASTDeclReader::VisitFunctionDecl(FunctionDecl *FD) {
10761076
FD->setFriendConstraintRefersToEnclosingTemplate(
10771077
FunctionDeclBits.getNextBit());
10781078
FD->setUsesSEHTry(FunctionDeclBits.getNextBit());
1079+
FD->setIsDestroyingOperatorDelete(FunctionDeclBits.getNextBit());
1080+
FD->setIsTypeAwareOperatorNewOrDelete(FunctionDeclBits.getNextBit());
10791081

10801082
FD->EndRangeLoc = readSourceLocation();
10811083
if (FD->isExplicitlyDefaulted())

clang/lib/Serialization/ASTWriterDecl.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -847,6 +847,8 @@ void ASTDeclWriter::VisitFunctionDecl(FunctionDecl *D) {
847847
FunctionDeclBits.addBit(D->isInstantiatedFromMemberTemplate());
848848
FunctionDeclBits.addBit(D->FriendConstraintRefersToEnclosingTemplate());
849849
FunctionDeclBits.addBit(D->usesSEHTry());
850+
FunctionDeclBits.addBit(D->isDestroyingOperatorDelete());
851+
FunctionDeclBits.addBit(D->isTypeAwareOperatorNewOrDelete());
850852
Record.push_back(FunctionDeclBits);
851853

852854
Record.AddSourceLocation(D->getEndLoc());

clang/test/AST/ByteCode/cxx20.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,14 @@ constexpr auto b3 = name1() == name1(); // ref-error {{must be initialized by a
119119
constexpr auto b4 = name1() == name2();
120120
static_assert(!b4);
121121

122+
constexpr auto bar(const char *p) { return p + __builtin_strlen(p); }
123+
constexpr auto b5 = bar(p1) == p1;
124+
static_assert(!b5);
125+
constexpr auto b6 = bar(p1) == ""; // ref-error {{must be initialized by a constant expression}} \
126+
// ref-note {{comparison of addresses of potentially overlapping literals}}
127+
constexpr auto b7 = bar(p1) + 1 == ""; // both-error {{must be initialized by a constant expression}} \
128+
// both-note {{comparison against pointer '&"test1"[6]' that points past the end of a complete object has unspecified value}}
129+
122130
namespace UninitializedFields {
123131
class A {
124132
public:

clang/test/Driver/riscv-cpus.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,3 +726,37 @@
726726

727727
// RUN: %clang --target=riscv64 -### -c %s 2>&1 -mtune=andes-nx45 | FileCheck -check-prefix=MTUNE-ANDES-NX45 %s
728728
// MTUNE-ANDES-NX45: "-tune-cpu" "andes-nx45"
729+
730+
// RUN: %clang --target=riscv32 -### -c %s 2>&1 -mcpu=andes-a45 | FileCheck -check-prefix=MCPU-ANDES-A45 %s
731+
// MCPU-ANDES-A45: "-target-cpu" "andes-a45"
732+
// MCPU-ANDES-A45-SAME: "-target-feature" "+m"
733+
// MCPU-ANDES-A45-SAME: "-target-feature" "+a"
734+
// MCPU-ANDES-A45-SAME: "-target-feature" "+f"
735+
// MCPU-ANDES-A45-SAME: "-target-feature" "+d"
736+
// MCPU-ANDES-A45-SAME: "-target-feature" "+c"
737+
// MCPU-ANDES-A45-SAME: "-target-feature" "+zicsr"
738+
// MCPU-ANDES-A45-SAME: "-target-feature" "+zifencei"
739+
// MCPU-ANDES-A45-SAME: "-target-feature" "+zba"
740+
// MCPU-ANDES-A45-SAME: "-target-feature" "+zbb"
741+
// MCPU-ANDES-A45-SAME: "-target-feature" "+zbs"
742+
// MCPU-ANDES-A45-SAME: "-target-abi" "ilp32d"
743+
744+
// RUN: %clang --target=riscv32 -### -c %s 2>&1 -mtune=andes-a45 | FileCheck -check-prefix=MTUNE-ANDES-A45 %s
745+
// MTUNE-ANDES-A45: "-tune-cpu" "andes-a45"
746+
747+
// RUN: %clang --target=riscv64 -### -c %s 2>&1 -mcpu=andes-ax45 | FileCheck -check-prefix=MCPU-ANDES-AX45 %s
748+
// MCPU-ANDES-AX45: "-target-cpu" "andes-ax45"
749+
// MCPU-ANDES-AX45-SAME: "-target-feature" "+m"
750+
// MCPU-ANDES-AX45-SAME: "-target-feature" "+a"
751+
// MCPU-ANDES-AX45-SAME: "-target-feature" "+f"
752+
// MCPU-ANDES-AX45-SAME: "-target-feature" "+d"
753+
// MCPU-ANDES-AX45-SAME: "-target-feature" "+c"
754+
// MCPU-ANDES-AX45-SAME: "-target-feature" "+zicsr"
755+
// MCPU-ANDES-AX45-SAME: "-target-feature" "+zifencei"
756+
// MCPU-ANDES-AX45-SAME: "-target-feature" "+zba"
757+
// MCPU-ANDES-AX45-SAME: "-target-feature" "+zbb"
758+
// MCPU-ANDES-AX45-SAME: "-target-feature" "+zbs"
759+
// MCPU-ANDES-AX45-SAME: "-target-abi" "lp64d"
760+
761+
// RUN: %clang --target=riscv64 -### -c %s 2>&1 -mtune=andes-ax45 | FileCheck -check-prefix=MTUNE-ANDES-AX45 %s
762+
// MTUNE-ANDES-AX45: "-tune-cpu" "andes-ax45"

clang/test/Misc/target-invalid-cpu-note/riscv.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
// RUN: not %clang_cc1 -triple riscv32 -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix RISCV32
66
// RISCV32: error: unknown target CPU 'not-a-cpu'
77
// RISCV32-NEXT: note: valid target CPU values are:
8-
// RISCV32-SAME: {{^}} andes-n45
8+
// RISCV32-SAME: {{^}} andes-a45
9+
// RISCV32-SAME: {{^}}, andes-n45
910
// RISCV32-SAME: {{^}}, generic-rv32
1011
// RISCV32-SAME: {{^}}, rocket-rv32
1112
// RISCV32-SAME: {{^}}, rp2350-hazard3
@@ -25,7 +26,8 @@
2526
// RUN: not %clang_cc1 -triple riscv64 -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix RISCV64
2627
// RISCV64: error: unknown target CPU 'not-a-cpu'
2728
// RISCV64-NEXT: note: valid target CPU values are:
28-
// RISCV64-SAME: {{^}} andes-nx45
29+
// RISCV64-SAME: {{^}} andes-ax45
30+
// RISCV64-SAME: {{^}}, andes-nx45
2931
// RISCV64-SAME: {{^}}, generic-rv64
3032
// RISCV64-SAME: {{^}}, mips-p8700
3133
// RISCV64-SAME: {{^}}, rocket-rv64
@@ -54,7 +56,8 @@
5456
// RUN: not %clang_cc1 -triple riscv32 -tune-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix TUNE-RISCV32
5557
// TUNE-RISCV32: error: unknown target CPU 'not-a-cpu'
5658
// TUNE-RISCV32-NEXT: note: valid target CPU values are:
57-
// TUNE-RISCV32-SAME: {{^}} andes-n45
59+
// TUNE-RISCV32-SAME: {{^}} andes-a45
60+
// TUNE-RISCV32-SAME: {{^}}, andes-n45
5861
// TUNE-RISCV32-SAME: {{^}}, generic-rv32
5962
// TUNE-RISCV32-SAME: {{^}}, rocket-rv32
6063
// TUNE-RISCV32-SAME: {{^}}, rp2350-hazard3
@@ -78,7 +81,8 @@
7881
// RUN: not %clang_cc1 -triple riscv64 -tune-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix TUNE-RISCV64
7982
// TUNE-RISCV64: error: unknown target CPU 'not-a-cpu'
8083
// TUNE-RISCV64-NEXT: note: valid target CPU values are:
81-
// TUNE-RISCV64-SAME: {{^}} andes-nx45
84+
// TUNE-RISCV64-SAME: {{^}} andes-ax45
85+
// TUNE-RISCV64-SAME: {{^}}, andes-nx45
8286
// TUNE-RISCV64-SAME: {{^}}, generic-rv64
8387
// TUNE-RISCV64-SAME: {{^}}, mips-p8700
8488
// TUNE-RISCV64-SAME: {{^}}, rocket-rv64
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module type_aware_destroying_new_delete { header "type_aware_destroying_new_delete.h" export * }
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
2+
namespace std {
3+
struct destroying_delete_t { };
4+
template <class T> struct type_identity {
5+
using type = T;
6+
};
7+
typedef __SIZE_TYPE__ size_t;
8+
enum class align_val_t : size_t;
9+
};
10+
11+
struct A {
12+
A();
13+
void *operator new(std::size_t);
14+
void operator delete(A*, std::destroying_delete_t);
15+
};
16+
17+
struct B {
18+
B();
19+
void *operator new(std::type_identity<B>, std::size_t, std::align_val_t);
20+
void operator delete(std::type_identity<B>, void*, std::size_t, std::align_val_t);
21+
};
22+
23+
struct C {
24+
C();
25+
template <class T> void *operator new(std::type_identity<T>, std::size_t, std::align_val_t);
26+
template <class T> void operator delete(std::type_identity<T>, void*, std::size_t, std::align_val_t);
27+
};
28+
29+
struct D {
30+
D();
31+
};
32+
void *operator new(std::type_identity<D>, std::size_t, std::align_val_t);
33+
void operator delete(std::type_identity<D>, void*, std::size_t, std::align_val_t);
34+
35+
struct E {
36+
E();
37+
};
38+
template <class T> void *operator new(std::type_identity<T>, std::size_t, std::align_val_t);
39+
template <class T> void operator delete(std::type_identity<T>, void*, std::size_t, std::align_val_t);
40+
41+
void in_module_tests() {
42+
A* a = new A;
43+
delete a;
44+
B *b = new B;
45+
delete b;
46+
C *c = new C;
47+
delete c;
48+
D *d = new D;
49+
delete d;
50+
E *e = new E;
51+
delete e;
52+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// RUN: rm -rf %t
2+
// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -x c++ -std=c++26 -fmodules-cache-path=%t -I %S/Inputs/PR137102 -emit-llvm-only %s
3+
// RUN: %clang_cc1 -fmodules -fimplicit-module-maps -x c++ -std=c++26 -fmodules-cache-path=%t -I %S/Inputs/PR137102 -emit-llvm-only %s -triple i686-windows
4+
5+
#include "type_aware_destroying_new_delete.h"
6+
7+
8+
static void call_in_module_function(void) {
9+
in_module_tests();
10+
}
11+
12+
void out_of_module_tests() {
13+
A* a = new A;
14+
delete a;
15+
B *b = new B;
16+
delete b;
17+
C *c = new C;
18+
delete c;
19+
D *d = new D;
20+
delete d;
21+
E *e = new E;
22+
delete e;
23+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
2+
namespace std {
3+
struct destroying_delete_t { };
4+
template <class T> struct type_identity {
5+
using type = T;
6+
};
7+
typedef __SIZE_TYPE__ size_t;
8+
enum class align_val_t : size_t;
9+
};
10+
11+
struct A {
12+
A();
13+
void *operator new(std::size_t);
14+
void operator delete(A*, std::destroying_delete_t);
15+
};
16+
17+
struct B {
18+
B();
19+
void *operator new(std::type_identity<B>, std::size_t, std::align_val_t);
20+
void operator delete(std::type_identity<B>, void*, std::size_t, std::align_val_t);
21+
};
22+
23+
struct C {
24+
C();
25+
template <class T> void *operator new(std::type_identity<T>, std::size_t, std::align_val_t);
26+
template <class T> void operator delete(std::type_identity<T>, void*, std::size_t, std::align_val_t);
27+
};
28+
29+
struct D {
30+
D();
31+
};
32+
void *operator new(std::type_identity<D>, std::size_t, std::align_val_t);
33+
void operator delete(std::type_identity<D>, void*, std::size_t, std::align_val_t);
34+
35+
struct E {
36+
E();
37+
};
38+
template <class T> void *operator new(std::type_identity<T>, std::size_t, std::align_val_t);
39+
template <class T> void operator delete(std::type_identity<T>, void*, std::size_t, std::align_val_t);
40+
41+
void in_pch_tests() {
42+
A* a = new A;
43+
delete a;
44+
B *b = new B;
45+
delete b;
46+
C *c = new C;
47+
delete c;
48+
D *d = new D;
49+
delete d;
50+
E *e = new E;
51+
delete e;
52+
}

0 commit comments

Comments
 (0)