Skip to content

Commit c9307a3

Browse files

File tree

220 files changed

+2458
-379
lines changed

Some content is hidden

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

220 files changed

+2458
-379
lines changed

clang-tools-extra/clang-tidy/readability/RedundantTypenameCheck.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include "clang/ASTMatchers/ASTMatchers.h"
1313
#include "clang/Basic/Diagnostic.h"
1414
#include "clang/Lex/Lexer.h"
15-
#include "clang/Sema/DeclSpec.h"
1615

1716
using namespace clang::ast_matchers;
1817

clang/docs/SafeBuffers.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ You can achieve this by refactoring the function to accept a ``std::span``
262262
as a parameter::
263263

264264
int get_last_element(std::span<int> sp) {
265-
return sp[size - 1];
265+
return sp[sp.size() - 1];
266266
}
267267

268268
This solution puts the responsibility for making sure the span is well-formed
@@ -411,7 +411,7 @@ backwards compatibility -- in terms of both API and ABI -- by adding
411411
a "compatibility overload"::
412412

413413
int get_last_element(std::span<int> sp) {
414-
return sp[size - 1];
414+
return sp[sp.size() - 1];
415415
}
416416

417417
[[clang::unsafe_buffer_usage]] // Please use the new function.

clang/include/clang/Basic/BuiltinsAMDGPU.def

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -177,15 +177,15 @@ BUILTIN(__builtin_amdgcn_raw_buffer_load_b64, "V2UiQbiiIi", "n")
177177
BUILTIN(__builtin_amdgcn_raw_buffer_load_b96, "V3UiQbiiIi", "n")
178178
BUILTIN(__builtin_amdgcn_raw_buffer_load_b128, "V4UiQbiiIi", "n")
179179

180-
BUILTIN(__builtin_amdgcn_raw_ptr_buffer_atomic_add_i32, "iiQbiiIi", "t")
180+
BUILTIN(__builtin_amdgcn_raw_ptr_buffer_atomic_add_i32, "iiQbiiIi", "")
181181

182-
TARGET_BUILTIN(__builtin_amdgcn_raw_ptr_buffer_atomic_fadd_f32, "ffQbiiIi", "t", "atomic-fadd-rtn-insts")
182+
TARGET_BUILTIN(__builtin_amdgcn_raw_ptr_buffer_atomic_fadd_f32, "ffQbiiIi", "", "atomic-fadd-rtn-insts")
183183
TARGET_BUILTIN(__builtin_amdgcn_raw_ptr_buffer_atomic_fadd_v2f16, "V2hV2hQbiiIi", "t", "atomic-buffer-global-pk-add-f16-insts")
184184

185-
TARGET_BUILTIN(__builtin_amdgcn_raw_ptr_buffer_atomic_fmin_f32, "ffQbiiIi", "t", "atomic-fmin-fmax-global-f32")
186-
TARGET_BUILTIN(__builtin_amdgcn_raw_ptr_buffer_atomic_fmax_f32, "ffQbiiIi", "t", "atomic-fmin-fmax-global-f32")
187-
TARGET_BUILTIN(__builtin_amdgcn_raw_ptr_buffer_atomic_fmin_f64, "ddQbiiIi", "t", "atomic-fmin-fmax-global-f64")
188-
TARGET_BUILTIN(__builtin_amdgcn_raw_ptr_buffer_atomic_fmax_f64, "ddQbiiIi", "t", "atomic-fmin-fmax-global-f64")
185+
TARGET_BUILTIN(__builtin_amdgcn_raw_ptr_buffer_atomic_fmin_f32, "ffQbiiIi", "", "atomic-fmin-fmax-global-f32")
186+
TARGET_BUILTIN(__builtin_amdgcn_raw_ptr_buffer_atomic_fmax_f32, "ffQbiiIi", "", "atomic-fmin-fmax-global-f32")
187+
TARGET_BUILTIN(__builtin_amdgcn_raw_ptr_buffer_atomic_fmin_f64, "ddQbiiIi", "", "atomic-fmin-fmax-global-f64")
188+
TARGET_BUILTIN(__builtin_amdgcn_raw_ptr_buffer_atomic_fmax_f64, "ddQbiiIi", "", "atomic-fmin-fmax-global-f64")
189189

190190
TARGET_BUILTIN(__builtin_amdgcn_raw_ptr_buffer_load_lds, "vQbv*3IUiiiIiIi", "t", "vmem-to-lds-load-insts")
191191
TARGET_BUILTIN(__builtin_amdgcn_struct_ptr_buffer_load_lds, "vQbv*3IUiiiiIiIi", "t", "vmem-to-lds-load-insts")

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3948,6 +3948,8 @@ bool Compiler<Emitter>::VisitRecoveryExpr(const RecoveryExpr *E) {
39483948
template <class Emitter>
39493949
bool Compiler<Emitter>::VisitAddrLabelExpr(const AddrLabelExpr *E) {
39503950
assert(E->getType()->isVoidPointerType());
3951+
if (DiscardResult)
3952+
return true;
39513953

39523954
return this->emitDummyPtr(E, E);
39533955
}

clang/lib/AST/ByteCode/Interp.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -832,6 +832,8 @@ bool CheckLoad(InterpState &S, CodePtr OpPC, const Pointer &Ptr,
832832
return false;
833833
if (!CheckVolatile(S, OpPC, Ptr, AK))
834834
return false;
835+
if (!Ptr.isConst() && !S.inConstantContext() && isConstexprUnknown(Ptr))
836+
return false;
835837
return true;
836838
}
837839

clang/lib/AST/ByteCode/InterpBuiltin.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -749,7 +749,7 @@ static bool interp__builtin_overflowop(InterpState &S, CodePtr OpPC,
749749
const CallExpr *Call,
750750
unsigned BuiltinOp) {
751751
const Pointer &ResultPtr = S.Stk.pop<Pointer>();
752-
if (ResultPtr.isDummy())
752+
if (ResultPtr.isDummy() || !ResultPtr.isBlockPointer())
753753
return false;
754754

755755
PrimType RHST = *S.getContext().classify(Call->getArg(1)->getType());
@@ -1941,6 +1941,9 @@ static bool interp__builtin_memcmp(InterpState &S, CodePtr OpPC,
19411941
return true;
19421942
}
19431943

1944+
if (!PtrA.isBlockPointer() || !PtrB.isBlockPointer())
1945+
return false;
1946+
19441947
bool IsWide =
19451948
(ID == Builtin::BIwmemcmp || ID == Builtin::BI__builtin_wmemcmp);
19461949

clang/lib/CodeGen/CGDebugInfo.cpp

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,33 @@ static bool IsArtificial(VarDecl const *VD) {
110110
cast<Decl>(VD->getDeclContext())->isImplicit());
111111
}
112112

113+
/// Returns \c true if the specified variable \c VD is an explicit parameter of
114+
/// a synthesized Objective-C property accessor. E.g., a synthesized property
115+
/// setter method will have a single explicit parameter which is the property to
116+
/// set.
117+
static bool IsObjCSynthesizedPropertyExplicitParameter(VarDecl const *VD) {
118+
assert(VD);
119+
120+
if (!llvm::isa<ParmVarDecl>(VD))
121+
return false;
122+
123+
// Not a property method.
124+
const auto *Method =
125+
llvm::dyn_cast_or_null<ObjCMethodDecl>(VD->getDeclContext());
126+
if (!Method)
127+
return false;
128+
129+
// Not a synthesized property accessor.
130+
if (!Method->isImplicit() || !Method->isPropertyAccessor())
131+
return false;
132+
133+
// Not an explicit parameter.
134+
if (VD->isImplicit())
135+
return false;
136+
137+
return true;
138+
}
139+
113140
CGDebugInfo::CGDebugInfo(CodeGenModule &CGM)
114141
: CGM(CGM), DebugKind(CGM.getCodeGenOpts().getDebugInfo()),
115142
DebugTypeExtRefs(CGM.getCodeGenOpts().DebugTypeExtRefs),
@@ -5226,7 +5253,12 @@ llvm::DILocalVariable *CGDebugInfo::EmitDeclare(const VarDecl *VD,
52265253
}
52275254
SmallVector<uint64_t, 13> Expr;
52285255
llvm::DINode::DIFlags Flags = llvm::DINode::FlagZero;
5229-
if (VarIsArtificial)
5256+
5257+
// While synthesized Objective-C property setters are "artificial" (i.e., they
5258+
// are not spelled out in source), we want to pretend they are just like a
5259+
// regular non-compiler generated method. Hence, don't mark explicitly passed
5260+
// parameters of such methods as artificial.
5261+
if (VarIsArtificial && !IsObjCSynthesizedPropertyExplicitParameter(VD))
52305262
Flags |= llvm::DINode::FlagArtificial;
52315263

52325264
auto Align = getDeclAlignIfRequired(VD, CGM.getContext());

clang/test/AST/ByteCode/builtin-functions.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1510,6 +1510,8 @@ namespace Memcmp {
15101510
static_assert(f());
15111511
#endif
15121512

1513+
int unknown;
1514+
void foo(void) { unknown *= __builtin_memcmp(0, 0, 2); }
15131515
}
15141516

15151517
namespace Memchr {
@@ -1853,3 +1855,8 @@ namespace InitParam {
18531855
}
18541856

18551857
#endif
1858+
1859+
namespace SAddOverflowInt {
1860+
int a;
1861+
void foo(void) { a *= __builtin_sadd_overflow(1, 2, 0); }
1862+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// RUN: %clang_cc1 -triple x86_64-linux -emit-llvm -o - %s -fcxx-exceptions | FileCheck %s
2+
// RUN: %clang_cc1 -triple x86_64-linux -emit-llvm -o - %s -fcxx-exceptions -fexperimental-new-constant-interpreter | FileCheck %s
3+
4+
5+
/// The read from a used to succeed, causing the entire if statement to vanish.
6+
extern void e();
7+
int somefunc() {
8+
auto foo = [a = false]() mutable {
9+
if (a)
10+
e();
11+
};
12+
foo();
13+
}
14+
15+
// CHECK: call void @_Z1ev()

clang/test/AST/ByteCode/cxx11.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,3 +370,12 @@ namespace GH150709 {
370370
static_assert((e2[0].*mp)() == 1, ""); // ref-error {{constant expression}}
371371
static_assert((g.*mp)() == 1, ""); // ref-error {{constant expression}}
372372
}
373+
374+
namespace DiscardedAddrLabel {
375+
void foo(void) {
376+
L:
377+
*&&L; // both-error {{indirection not permitted}} \
378+
// both-warning {{expression result unused}}
379+
}
380+
}
381+

0 commit comments

Comments
 (0)