Skip to content

Commit 4103212

Browse files
authored
Merge pull request #545 from Xilinx/bump_to_d70f54f2
[AutoBump] Merge with d70f54f (Jan 20) (7)
2 parents a40b4d1 + cd1fe65 commit 4103212

File tree

141 files changed

+1930
-7192
lines changed

Some content is hidden

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

141 files changed

+1930
-7192
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,8 @@ Improvements to Clang's diagnostics
660660

661661
- Don't emit bogus dangling diagnostics when ``[[gsl::Owner]]`` and `[[clang::lifetimebound]]` are used together (#GH108272).
662662

663+
- Don't emit bogus dignostic about an undefined behavior on ``reinterpret_cast<T>`` for non-instantiated template functions without sufficient knowledge whether it can actually lead to undefined behavior for ``T`` (#GH109430).
664+
663665
- The ``-Wreturn-stack-address`` warning now also warns about addresses of
664666
local variables passed to function calls using the ``[[clang::musttail]]``
665667
attribute.
@@ -860,7 +862,7 @@ Bug Fixes to C++ Support
860862
module imports in those situations. (#GH60336)
861863
- Fix init-capture packs having a size of one before being instantiated. (#GH63677)
862864
- Clang now preserves the unexpanded flag in a lambda transform used for pack expansion. (#GH56852), (#GH85667),
863-
(#GH99877).
865+
(#GH99877), (#GH122417).
864866
- Fixed a bug when diagnosing ambiguous explicit specializations of constrained member functions.
865867
- Fixed an assertion failure when selecting a function from an overload set that includes a
866868
specialization of a conversion function template.

clang/include/clang/Sema/Overload.h

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,8 @@ class Sema;
898898
ConversionFixItGenerator Fix;
899899

900900
/// Viable - True to indicate that this overload candidate is viable.
901-
bool Viable : 1;
901+
LLVM_PREFERRED_TYPE(bool)
902+
unsigned Viable : 1;
902903

903904
/// Whether this candidate is the best viable function, or tied for being
904905
/// the best viable function.
@@ -907,12 +908,14 @@ class Sema;
907908
/// was part of the ambiguity kernel: the minimal non-empty set of viable
908909
/// candidates such that all elements of the ambiguity kernel are better
909910
/// than all viable candidates not in the ambiguity kernel.
910-
bool Best : 1;
911+
LLVM_PREFERRED_TYPE(bool)
912+
unsigned Best : 1;
911913

912914
/// IsSurrogate - True to indicate that this candidate is a
913915
/// surrogate for a conversion to a function pointer or reference
914916
/// (C++ [over.call.object]).
915-
bool IsSurrogate : 1;
917+
LLVM_PREFERRED_TYPE(bool)
918+
unsigned IsSurrogate : 1;
916919

917920
/// IgnoreObjectArgument - True to indicate that the first
918921
/// argument's conversion, which for this function represents the
@@ -921,12 +924,15 @@ class Sema;
921924
/// implicit object argument is just a placeholder) or a
922925
/// non-static member function when the call doesn't have an
923926
/// object argument.
924-
bool IgnoreObjectArgument : 1;
927+
LLVM_PREFERRED_TYPE(bool)
928+
unsigned IgnoreObjectArgument : 1;
925929

926-
bool TookAddressOfOverload : 1;
930+
LLVM_PREFERRED_TYPE(bool)
931+
unsigned TookAddressOfOverload : 1;
927932

928933
/// True if the candidate was found using ADL.
929-
CallExpr::ADLCallKind IsADLCandidate : 1;
934+
LLVM_PREFERRED_TYPE(CallExpr::ADLCallKind)
935+
unsigned IsADLCandidate : 1;
930936

931937
/// Whether this is a rewritten candidate, and if so, of what kind?
932938
LLVM_PREFERRED_TYPE(OverloadCandidateRewriteKind)
@@ -999,7 +1005,8 @@ class Sema;
9991005
friend class OverloadCandidateSet;
10001006
OverloadCandidate()
10011007
: IsSurrogate(false), IgnoreObjectArgument(false),
1002-
TookAddressOfOverload(false), IsADLCandidate(CallExpr::NotADL),
1008+
TookAddressOfOverload(false),
1009+
IsADLCandidate(llvm::to_underlying(CallExpr::NotADL)),
10031010
RewriteKind(CRK_None) {}
10041011
};
10051012

clang/lib/AST/ByteCode/Interp.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ bool CheckLive(InterpState &S, CodePtr OpPC, const Pointer &Ptr,
321321

322322
if (Ptr.isDynamic()) {
323323
S.FFDiag(Src, diag::note_constexpr_access_deleted_object) << AK;
324-
} else {
324+
} else if (!S.checkingPotentialConstantExpression()) {
325325
bool IsTemp = Ptr.isTemporary();
326326
S.FFDiag(Src, diag::note_constexpr_lifetime_ended, 1) << AK << !IsTemp;
327327

@@ -416,9 +416,11 @@ bool CheckRange(InterpState &S, CodePtr OpPC, const Pointer &Ptr,
416416
AccessKinds AK) {
417417
if (!Ptr.isOnePastEnd())
418418
return true;
419-
const SourceInfo &Loc = S.Current->getSource(OpPC);
420-
S.FFDiag(Loc, diag::note_constexpr_access_past_end)
421-
<< AK << S.Current->getRange(OpPC);
419+
if (S.getLangOpts().CPlusPlus) {
420+
const SourceInfo &Loc = S.Current->getSource(OpPC);
421+
S.FFDiag(Loc, diag::note_constexpr_access_past_end)
422+
<< AK << S.Current->getRange(OpPC);
423+
}
422424
return false;
423425
}
424426

@@ -538,7 +540,7 @@ bool CheckInitialized(InterpState &S, CodePtr OpPC, const Pointer &Ptr,
538540
return true;
539541

540542
if (const auto *VD = Ptr.getDeclDesc()->asVarDecl();
541-
VD && VD->hasGlobalStorage()) {
543+
VD && (VD->isConstexpr() || VD->hasGlobalStorage())) {
542544
const SourceInfo &Loc = S.Current->getSource(OpPC);
543545
if (VD->getAnyInitializer()) {
544546
S.FFDiag(Loc, diag::note_constexpr_var_init_non_constant, 1) << VD;

clang/lib/Sema/SemaCast.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2094,6 +2094,10 @@ void Sema::CheckCompatibleReinterpretCast(QualType SrcType, QualType DestType,
20942094
}
20952095
}
20962096

2097+
if (SrcTy->isDependentType() || DestTy->isDependentType()) {
2098+
return;
2099+
}
2100+
20972101
Diag(Range.getBegin(), DiagID) << SrcType << DestType << Range;
20982102
}
20992103

clang/lib/Sema/SemaOverload.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6977,7 +6977,7 @@ void Sema::AddOverloadCandidate(
69776977
Candidate.Viable = true;
69786978
Candidate.RewriteKind =
69796979
CandidateSet.getRewriteInfo().getRewriteKind(Function, PO);
6980-
Candidate.IsADLCandidate = IsADLCandidate;
6980+
Candidate.IsADLCandidate = llvm::to_underlying(IsADLCandidate);
69816981
Candidate.ExplicitCallArguments = Args.size();
69826982

69836983
// Explicit functions are not actually candidates at all if we're not
@@ -7832,7 +7832,7 @@ void Sema::AddTemplateOverloadCandidate(
78327832
Candidate.RewriteKind =
78337833
CandidateSet.getRewriteInfo().getRewriteKind(Candidate.Function, PO);
78347834
Candidate.IsSurrogate = false;
7835-
Candidate.IsADLCandidate = IsADLCandidate;
7835+
Candidate.IsADLCandidate = llvm::to_underlying(IsADLCandidate);
78367836
// Ignore the object argument if there is one, since we don't have an object
78377837
// type.
78387838
Candidate.IgnoreObjectArgument =
@@ -14082,7 +14082,8 @@ static ExprResult FinishOverloadedCallExpr(Sema &SemaRef, Scope *S, Expr *Fn,
1408214082
return ExprError();
1408314083
return SemaRef.BuildResolvedCallExpr(
1408414084
Res.get(), FDecl, LParenLoc, Args, RParenLoc, ExecConfig,
14085-
/*IsExecConfig=*/false, (*Best)->IsADLCandidate);
14085+
/*IsExecConfig=*/false,
14086+
static_cast<CallExpr::ADLCallKind>((*Best)->IsADLCandidate));
1408614087
}
1408714088

1408814089
case OR_No_Viable_Function: {
@@ -14156,7 +14157,8 @@ static ExprResult FinishOverloadedCallExpr(Sema &SemaRef, Scope *S, Expr *Fn,
1415614157
return ExprError();
1415714158
return SemaRef.BuildResolvedCallExpr(
1415814159
Res.get(), FDecl, LParenLoc, Args, RParenLoc, ExecConfig,
14159-
/*IsExecConfig=*/false, (*Best)->IsADLCandidate);
14160+
/*IsExecConfig=*/false,
14161+
static_cast<CallExpr::ADLCallKind>((*Best)->IsADLCandidate));
1416014162
}
1416114163
}
1416214164

@@ -14438,7 +14440,8 @@ Sema::CreateOverloadedUnaryOp(SourceLocation OpLoc, UnaryOperatorKind Opc,
1443814440
Args[0] = Input;
1443914441
CallExpr *TheCall = CXXOperatorCallExpr::Create(
1444014442
Context, Op, FnExpr.get(), ArgsArray, ResultTy, VK, OpLoc,
14441-
CurFPFeatureOverrides(), Best->IsADLCandidate);
14443+
CurFPFeatureOverrides(),
14444+
static_cast<CallExpr::ADLCallKind>(Best->IsADLCandidate));
1444214445

1444314446
if (CheckCallReturnType(FnDecl->getReturnType(), OpLoc, TheCall, FnDecl))
1444414447
return ExprError();
@@ -14833,7 +14836,8 @@ ExprResult Sema::CreateOverloadedBinOp(SourceLocation OpLoc,
1483314836
// members; CodeGen should take care not to emit the this pointer.
1483414837
TheCall = CXXOperatorCallExpr::Create(
1483514838
Context, ChosenOp, FnExpr.get(), Args, ResultTy, VK, OpLoc,
14836-
CurFPFeatureOverrides(), Best->IsADLCandidate);
14839+
CurFPFeatureOverrides(),
14840+
static_cast<CallExpr::ADLCallKind>(Best->IsADLCandidate));
1483714841

1483814842
if (const auto *Method = dyn_cast<CXXMethodDecl>(FnDecl);
1483914843
Method && Method->isImplicitObjectMemberFunction()) {

clang/lib/Sema/TreeTransform.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8499,7 +8499,7 @@ TreeTransform<Derived>::TransformDeclStmt(DeclStmt *S) {
84998499
getSema()
85008500
.getASTContext()
85018501
.getTypeDeclType(TD)
8502-
.getCanonicalType()
8502+
.getSingleStepDesugaredType(getSema().getASTContext())
85038503
->containsUnexpandedParameterPack();
85048504

85058505
if (auto *VD = dyn_cast<VarDecl>(Transformed))

clang/test/AST/ByteCode/c23.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,11 @@ static_assert(arg1[1] == 254);
4949
static_assert(arg1[2] == 186);
5050
static_assert(arg1[3] == 190);
5151
#endif
52+
53+
void ghissue109095() {
54+
constexpr char c[] = { 'a' };
55+
constexpr int i = c[1]; // both-error {{constexpr variable 'i' must be initialized by a constant expression}}\
56+
// both-note {{declared here}}
57+
_Static_assert(i == c[0]); // both-error {{static assertion expression is not an integral constant expression}}\
58+
// both-note {{initializer of 'i' is not a constant expression}}
59+
}

clang/test/AST/ByteCode/lifetimes.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,15 @@ struct Foo {
77
int a;
88
};
99

10-
constexpr int dead1() { // expected-error {{never produces a constant expression}}
10+
constexpr int dead1() {
1111

1212
Foo *F2 = nullptr;
1313
{
14-
Foo F{12}; // expected-note 2{{declared here}}
14+
Foo F{12}; // expected-note {{declared here}}
1515
F2 = &F;
1616
} // Ends lifetime of F.
1717

18-
return F2->a; // expected-note 2{{read of variable whose lifetime has ended}} \
18+
return F2->a; // expected-note {{read of variable whose lifetime has ended}} \
1919
// ref-note {{read of object outside its lifetime is not allowed in a constant expression}}
2020
}
2121
static_assert(dead1() == 1, ""); // both-error {{not an integral constant expression}} \

clang/test/AST/ByteCode/literals.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1315,3 +1315,12 @@ namespace {
13151315
}
13161316
}
13171317
#endif
1318+
1319+
void localConstexpr() {
1320+
constexpr int a = 1/0; // both-error {{must be initialized by a constant expression}} \
1321+
// both-note {{division by zero}} \
1322+
// both-warning {{division by zero is undefined}} \
1323+
// both-note {{declared here}}
1324+
static_assert(a == 0, ""); // both-error {{not an integral constant expression}} \
1325+
// both-note {{initializer of 'a' is not a constant expression}}
1326+
}

clang/test/CodeGen/X86/ms-x86-intrinsics.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ __int64 test_mul128(__int64 Multiplier,
171171
__int64 *HighProduct) {
172172
return _mul128(Multiplier, Multiplicand, HighProduct);
173173
}
174-
// CHECK-X64-LABEL: define dso_local i64 @test_mul128(i64 noundef %Multiplier, i64 noundef %Multiplicand, ptr{{[a-z_ ]*}} initializes((0, 8)) %HighProduct)
174+
// CHECK-X64-LABEL: define dso_local i64 @test_mul128(i64 noundef %Multiplier, i64 noundef %Multiplicand, ptr{{.*}} initializes((0, 8)) %HighProduct)
175175
// CHECK-X64: = sext i64 %Multiplier to i128
176176
// CHECK-X64: = sext i64 %Multiplicand to i128
177177
// CHECK-X64: = mul nsw i128 %
@@ -183,7 +183,7 @@ unsigned __int64 test_umul128(unsigned __int64 Multiplier,
183183
unsigned __int64 *HighProduct) {
184184
return _umul128(Multiplier, Multiplicand, HighProduct);
185185
}
186-
// CHECK-X64-LABEL: define dso_local i64 @test_umul128(i64 noundef %Multiplier, i64 noundef %Multiplicand, ptr{{[a-z_ ]*}} initializes((0, 8)) %HighProduct)
186+
// CHECK-X64-LABEL: define dso_local i64 @test_umul128(i64 noundef %Multiplier, i64 noundef %Multiplicand, ptr{{.*}} initializes((0, 8)) %HighProduct)
187187
// CHECK-X64: = zext i64 %Multiplier to i128
188188
// CHECK-X64: = zext i64 %Multiplicand to i128
189189
// CHECK-X64: = mul nuw i128 %

0 commit comments

Comments
 (0)