Skip to content

Commit 1484da0

Browse files
committed
merge main into amd-staging
2 parents bf04df7 + 63b8f1c commit 1484da0

File tree

104 files changed

+1654
-570
lines changed

Some content is hidden

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

104 files changed

+1654
-570
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,10 @@ Improvements to Clang's diagnostics
407407

408408
Fixes #GH131127
409409

410+
- ``-Wuninitialized`` now diagnoses when a class does not declare any
411+
constructors to initialize their non-modifiable members. The diagnostic is
412+
not new; being controlled via a warning group is what's new. Fixes #GH41104
413+
410414
Improvements to Clang's time-trace
411415
----------------------------------
412416

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2266,7 +2266,8 @@ def err_constructor_byvalue_arg : Error<
22662266
"copy constructor must pass its first argument by reference">;
22672267
def warn_no_constructor_for_refconst : Warning<
22682268
"%select{struct|interface|union|class|enum}0 %1 does not declare any "
2269-
"constructor to initialize its non-modifiable members">;
2269+
"constructor to initialize its non-modifiable members">,
2270+
InGroup<Uninitialized>;
22702271
def note_refconst_member_not_initialized : Note<
22712272
"%select{const|reference}0 member %1 will never be initialized">;
22722273
def ext_ms_explicit_constructor_call : ExtWarn<

clang/include/clang/Sema/Overload.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,6 +1350,9 @@ class Sema;
13501350
iterator end() { return Candidates.end(); }
13511351

13521352
size_t size() const { return Candidates.size() + DeferredCandidatesCount; }
1353+
1354+
size_t nonDeferredCandidatesCount() const { return Candidates.size(); }
1355+
13531356
bool empty() const {
13541357
return Candidates.empty() && DeferredCandidatesCount == 0;
13551358
}

clang/lib/AST/ByteCode/Interp.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -790,6 +790,8 @@ bool CheckStore(InterpState &S, CodePtr OpPC, const Pointer &Ptr) {
790790
return false;
791791
if (!CheckConst(S, OpPC, Ptr))
792792
return false;
793+
if (!S.inConstantContext() && isConstexprUnknown(Ptr))
794+
return false;
793795
return true;
794796
}
795797

clang/lib/AST/Decl.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -400,9 +400,9 @@ void LinkageComputer::mergeTemplateLV(
400400
FunctionTemplateDecl *temp = specInfo->getTemplate();
401401
// Merge information from the template declaration.
402402
LinkageInfo tempLV = getLVForDecl(temp, computation);
403-
// The linkage of the specialization should be consistent with the
404-
// template declaration.
405-
LV.setLinkage(tempLV.getLinkage());
403+
// The linkage and visibility of the specialization should be
404+
// consistent with the template declaration.
405+
LV.mergeMaybeWithVisibility(tempLV, considerVisibility);
406406

407407
// Merge information from the template parameters.
408408
LinkageInfo paramsLV =
@@ -1051,6 +1051,13 @@ LinkageComputer::getLVForClassMember(const NamedDecl *D,
10511051
if (const auto *redeclTemp = dyn_cast<RedeclarableTemplateDecl>(temp)) {
10521052
if (isExplicitMemberSpecialization(redeclTemp)) {
10531053
explicitSpecSuppressor = temp->getTemplatedDecl();
1054+
} else if (const RedeclarableTemplateDecl *from =
1055+
redeclTemp->getInstantiatedFromMemberTemplate()) {
1056+
// If no explicit visibility is specified yet, and this is an
1057+
// instantiated member of a template, look up visibility there
1058+
// as well.
1059+
LinkageInfo fromLV = from->getLinkageAndVisibility();
1060+
LV.mergeMaybeWithVisibility(fromLV, considerVisibility);
10541061
}
10551062
}
10561063
}

clang/lib/CodeGen/TargetBuiltins/AMDGPU.cpp

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -171,16 +171,6 @@ static Value *emitFPIntBuiltin(CodeGenFunction &CGF,
171171
return CGF.Builder.CreateCall(F, {Src0, Src1});
172172
}
173173

174-
static Value *emitRangedBuiltin(CodeGenFunction &CGF, unsigned IntrinsicID,
175-
int low, int high) {
176-
Function *F = CGF.CGM.getIntrinsic(IntrinsicID, {});
177-
llvm::CallInst *Call = CGF.Builder.CreateCall(F);
178-
llvm::ConstantRange CR(APInt(32, low), APInt(32, high));
179-
Call->addRangeRetAttr(CR);
180-
Call->addRetAttr(llvm::Attribute::AttrKind::NoUndef);
181-
return Call;
182-
}
183-
184174
// For processing memory ordering and memory scope arguments of various
185175
// amdgcn builtins.
186176
// \p Order takes a C++11 comptabile memory-ordering specifier and converts
@@ -963,15 +953,6 @@ Value *CodeGenFunction::EmitAMDGPUBuiltinExpr(unsigned BuiltinID,
963953
Function *F = CGM.getIntrinsic(BuiltinWMMAOp, ArgTypes);
964954
return Builder.CreateCall(F, Args);
965955
}
966-
967-
// amdgcn workitem
968-
case AMDGPU::BI__builtin_amdgcn_workitem_id_x:
969-
return emitRangedBuiltin(*this, Intrinsic::amdgcn_workitem_id_x, 0, 1024);
970-
case AMDGPU::BI__builtin_amdgcn_workitem_id_y:
971-
return emitRangedBuiltin(*this, Intrinsic::amdgcn_workitem_id_y, 0, 1024);
972-
case AMDGPU::BI__builtin_amdgcn_workitem_id_z:
973-
return emitRangedBuiltin(*this, Intrinsic::amdgcn_workitem_id_z, 0, 1024);
974-
975956
// amdgcn workgroup size
976957
case AMDGPU::BI__builtin_amdgcn_workgroup_size_x:
977958
return EmitAMDGPUWorkGroupSize(*this, 0);
@@ -993,12 +974,6 @@ Value *CodeGenFunction::EmitAMDGPUBuiltinExpr(unsigned BuiltinID,
993974
case AMDGPU::BI__builtin_r600_recipsqrt_ieeef:
994975
return emitBuiltinWithOneOverloadedType<1>(*this, E,
995976
Intrinsic::r600_recipsqrt_ieee);
996-
case AMDGPU::BI__builtin_r600_read_tidig_x:
997-
return emitRangedBuiltin(*this, Intrinsic::r600_read_tidig_x, 0, 1024);
998-
case AMDGPU::BI__builtin_r600_read_tidig_y:
999-
return emitRangedBuiltin(*this, Intrinsic::r600_read_tidig_y, 0, 1024);
1000-
case AMDGPU::BI__builtin_r600_read_tidig_z:
1001-
return emitRangedBuiltin(*this, Intrinsic::r600_read_tidig_z, 0, 1024);
1002977
case AMDGPU::BI__builtin_amdgcn_alignbit: {
1003978
llvm::Value *Src0 = EmitScalarExpr(E->getArg(0));
1004979
llvm::Value *Src1 = EmitScalarExpr(E->getArg(1));

clang/lib/Parse/ParseExpr.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2239,8 +2239,6 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) {
22392239
if (PP.isCodeCompletionReached() && !CalledSignatureHelp)
22402240
RunSignatureHelp();
22412241
LHS = ExprError();
2242-
} else if (!HasError && HasTrailingComma) {
2243-
Diag(Tok, diag::err_expected_expression);
22442242
} else if (LHS.isInvalid()) {
22452243
for (auto &E : ArgExprs)
22462244
Actions.CorrectDelayedTyposInExpr(E);
@@ -3750,7 +3748,6 @@ bool Parser::ParseExpressionList(SmallVectorImpl<Expr *> &Exprs,
37503748
if (Tok.is(tok::r_paren)) {
37513749
if (HasTrailingComma)
37523750
*HasTrailingComma = true;
3753-
break;
37543751
}
37553752
}
37563753
if (SawError) {

clang/lib/Sema/SemaOverload.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,7 +1108,7 @@ bool OverloadCandidateSet::OperatorRewriteInfo::shouldAddReversed(
11081108
}
11091109

11101110
void OverloadCandidateSet::destroyCandidates() {
1111-
for (iterator i = begin(), e = end(); i != e; ++i) {
1111+
for (iterator i = Candidates.begin(), e = Candidates.end(); i != e; ++i) {
11121112
for (auto &C : i->Conversions)
11131113
C.~ImplicitConversionSequence();
11141114
if (!i->Viable && i->FailureKind == ovl_fail_bad_deduction)
@@ -11237,7 +11237,7 @@ void OverloadCandidateSet::PerfectViableFunction(
1123711237
Sema &S, SourceLocation Loc, OverloadCandidateSet::iterator &Best) {
1123811238

1123911239
Best = end();
11240-
for (auto It = begin(); It != end(); ++It) {
11240+
for (auto It = Candidates.begin(); It != Candidates.end(); ++It) {
1124111241

1124211242
if (!It->isPerfectMatch(S.getASTContext()))
1124311243
continue;
@@ -11277,7 +11277,8 @@ OverloadingResult OverloadCandidateSet::BestViableFunctionImpl(
1127711277

1127811278
llvm::SmallVector<OverloadCandidate *, 16> Candidates;
1127911279
Candidates.reserve(this->Candidates.size());
11280-
std::transform(begin(), end(), std::back_inserter(Candidates),
11280+
std::transform(this->Candidates.begin(), this->Candidates.end(),
11281+
std::back_inserter(Candidates),
1128111282
[](OverloadCandidate &Cand) { return &Cand; });
1128211283

1128311284
if (S.getLangOpts().CUDA)
@@ -13050,7 +13051,8 @@ SmallVector<OverloadCandidate *, 32> OverloadCandidateSet::CompleteCandidates(
1305013051
// be prohibitive, so we make a set of pointers and sort those.
1305113052
SmallVector<OverloadCandidate*, 32> Cands;
1305213053
if (OCD == OCD_AllCandidates) Cands.reserve(size());
13053-
for (iterator Cand = begin(), LastCand = end(); Cand != LastCand; ++Cand) {
13054+
for (iterator Cand = Candidates.begin(), LastCand = Candidates.end();
13055+
Cand != LastCand; ++Cand) {
1305413056
if (!Filter(*Cand))
1305513057
continue;
1305613058
switch (OCD) {
@@ -13127,7 +13129,8 @@ void OverloadCandidateSet::NoteCandidates(
1312713129
NoteCandidates(S, Args, Cands, Opc, OpLoc);
1312813130

1312913131
if (OCD == OCD_AmbiguousCandidates)
13130-
MaybeDiagnoseAmbiguousConstraints(S, {begin(), end()});
13132+
MaybeDiagnoseAmbiguousConstraints(S,
13133+
{Candidates.begin(), Candidates.end()});
1313113134
}
1313213135

1313313136
void OverloadCandidateSet::NoteCandidates(Sema &S, ArrayRef<Expr *> Args,
@@ -16255,7 +16258,8 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Obj,
1625516258
// we filter them out to produce better error diagnostics, ie to avoid
1625616259
// showing 2 failed overloads instead of one.
1625716260
bool IgnoreSurrogateFunctions = false;
16258-
if (CandidateSet.size() == 1 && Record->getAsCXXRecordDecl()->isLambda()) {
16261+
if (CandidateSet.nonDeferredCandidatesCount() == 1 &&
16262+
Record->getAsCXXRecordDecl()->isLambda()) {
1625916263
const OverloadCandidate &Candidate = *CandidateSet.begin();
1626016264
if (!Candidate.Viable &&
1626116265
Candidate.FailureKind == ovl_fail_constraints_not_satisfied)

clang/test/CodeGen/p0963r3.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
// RUN: %clang_cc1 -std=c++2c -verify -emit-llvm -triple=x86_64-pc-linux-gnu %s -o - | FileCheck %s
2-
// RUN: %clang_cc1 -std=c++2c -verify -fsyntax-only -fexperimental-new-constant-interpreter -triple=x86_64-pc-linux-gnu %s
1+
// RUN: %clang_cc1 -std=c++2c -verify -emit-llvm -triple=x86_64-pc-linux-gnu %s -o - | FileCheck %s
2+
// RUN: %clang_cc1 -std=c++2c -verify -emit-llvm -triple=x86_64-pc-linux-gnu %s -o - -fexperimental-new-constant-interpreter | FileCheck %s
33
// expected-no-diagnostics
44

55
namespace std {

clang/test/CodeGenCXX/visibility.cpp

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1457,9 +1457,45 @@ namespace test71 {
14571457
// CHECK-LABEL: declare hidden noundef i32 @_ZN6test713fooIiE3zedEv(
14581458
// CHECK-LABEL: define linkonce_odr noundef i32 @_ZN6test713fooIiE3barIiEET_v(
14591459
// CHECK-LABEL: define linkonce_odr hidden noundef i64 @_ZN6test713fooIlE3zedEv(
1460-
// CHECK-LABEL: define linkonce_odr noundef i32 @_ZN6test713fooIlE3barIiEET_v(
1460+
// CHECK-LABEL: define linkonce_odr hidden noundef i32 @_ZN6test713fooIlE3barIiEET_v(
14611461
// CHECK-HIDDEN-LABEL: declare hidden noundef i32 @_ZN6test713fooIiE3zedEv(
14621462
// CHECK-HIDDEN-LABEL: define linkonce_odr noundef i32 @_ZN6test713fooIiE3barIiEET_v(
14631463
// CHECK-HIDDEN-LABEL: define linkonce_odr hidden noundef i64 @_ZN6test713fooIlE3zedEv(
14641464
// CHECK-HIDDEN-LABEL: define linkonce_odr hidden noundef i32 @_ZN6test713fooIlE3barIiEET_v(
14651465
}
1466+
1467+
// https://github.com/llvm/llvm-project/issues/103477
1468+
namespace test72 {
1469+
template <class a>
1470+
struct t {
1471+
template <int>
1472+
static HIDDEN void bar() {}
1473+
};
1474+
1475+
void test() {
1476+
t<char>::bar<1>();
1477+
}
1478+
// CHECK-LABEL: define linkonce_odr hidden void @_ZN6test721tIcE3barILi1EEEvv(
1479+
// CHECK-HIDDEN-LABEL: define linkonce_odr hidden void @_ZN6test721tIcE3barILi1EEEvv(
1480+
}
1481+
1482+
// https://github.com/llvm/llvm-project/issues/31462
1483+
namespace test73 {
1484+
template <class T> struct s {
1485+
template <class U>
1486+
__attribute__((__visibility__("hidden"))) U should_not_be_exported();
1487+
};
1488+
1489+
template <class T> template <class U> U s<T>::should_not_be_exported() {
1490+
return U();
1491+
}
1492+
1493+
extern template struct __attribute__((__visibility__("default"))) s<int>;
1494+
1495+
int f() {
1496+
s<int> o;
1497+
return o.should_not_be_exported<int>();
1498+
}
1499+
// CHECK-LABEL: define linkonce_odr noundef i32 @_ZN6test731sIiE22should_not_be_exportedIiEET_v(
1500+
// CHECK-HIDDEN-LABEL: define linkonce_odr noundef i32 @_ZN6test731sIiE22should_not_be_exportedIiEET_v(
1501+
}

0 commit comments

Comments
 (0)