Skip to content

Commit 0026335

Browse files
Merge branch 'main' into constexpr-ranges-stable_sort
2 parents 02800f5 + 77cf6ec commit 0026335

File tree

53 files changed

+4828
-3181
lines changed

Some content is hidden

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

53 files changed

+4828
-3181
lines changed

bolt/runtime/hugify.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ static bool hasPagecacheTHPSupport() {
8585
KernelVersionTy KernelVersion;
8686

8787
getKernelVersion((uint32_t *)&KernelVersion);
88-
if (KernelVersion.major >= 5 && KernelVersion.minor >= 10)
88+
if (KernelVersion.major >= 6 ||
89+
(KernelVersion.major == 5 && KernelVersion.minor >= 10))
8990
return true;
9091

9192
return false;

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,8 @@ Bug Fixes to C++ Support
264264
- Clang is now better at keeping track of friend function template instance contexts. (#GH55509)
265265
- Clang now prints the correct instantiation context for diagnostics suppressed
266266
by template argument deduction.
267+
- Clang is now better at instantiating the function definition after its use inside
268+
of a constexpr lambda. (#GH125747)
267269
- The initialization kind of elements of structured bindings
268270
direct-list-initialized from an array is corrected to direct-initialization.
269271
- Clang no longer crashes when a coroutine is declared ``[[noreturn]]``. (#GH127327)

clang/include/clang/Sema/Sema.h

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13657,12 +13657,16 @@ class Sema final : public SemaBase {
1365713657

1365813658
class LocalEagerInstantiationScope {
1365913659
public:
13660-
LocalEagerInstantiationScope(Sema &S) : S(S) {
13660+
LocalEagerInstantiationScope(Sema &S, bool AtEndOfTU)
13661+
: S(S), AtEndOfTU(AtEndOfTU) {
1366113662
SavedPendingLocalImplicitInstantiations.swap(
1366213663
S.PendingLocalImplicitInstantiations);
1366313664
}
1366413665

13665-
void perform() { S.PerformPendingInstantiations(/*LocalOnly=*/true); }
13666+
void perform() {
13667+
S.PerformPendingInstantiations(/*LocalOnly=*/true,
13668+
/*AtEndOfTU=*/AtEndOfTU);
13669+
}
1366613670

1366713671
~LocalEagerInstantiationScope() {
1366813672
assert(S.PendingLocalImplicitInstantiations.empty() &&
@@ -13673,6 +13677,7 @@ class Sema final : public SemaBase {
1367313677

1367413678
private:
1367513679
Sema &S;
13680+
bool AtEndOfTU;
1367613681
std::deque<PendingImplicitInstantiation>
1367713682
SavedPendingLocalImplicitInstantiations;
1367813683
};
@@ -13695,8 +13700,8 @@ class Sema final : public SemaBase {
1369513700

1369613701
class GlobalEagerInstantiationScope {
1369713702
public:
13698-
GlobalEagerInstantiationScope(Sema &S, bool Enabled)
13699-
: S(S), Enabled(Enabled) {
13703+
GlobalEagerInstantiationScope(Sema &S, bool Enabled, bool AtEndOfTU)
13704+
: S(S), Enabled(Enabled), AtEndOfTU(AtEndOfTU) {
1370013705
if (!Enabled)
1370113706
return;
1370213707

@@ -13710,7 +13715,8 @@ class Sema final : public SemaBase {
1371013715
void perform() {
1371113716
if (Enabled) {
1371213717
S.DefineUsedVTables();
13713-
S.PerformPendingInstantiations();
13718+
S.PerformPendingInstantiations(/*LocalOnly=*/false,
13719+
/*AtEndOfTU=*/AtEndOfTU);
1371413720
}
1371513721
}
1371613722

@@ -13725,7 +13731,8 @@ class Sema final : public SemaBase {
1372513731
S.SavedVTableUses.pop_back();
1372613732

1372713733
// Restore the set of pending implicit instantiations.
13728-
if (S.TUKind != TU_Prefix || !S.LangOpts.PCHInstantiateTemplates) {
13734+
if ((S.TUKind != TU_Prefix || !S.LangOpts.PCHInstantiateTemplates) &&
13735+
AtEndOfTU) {
1372913736
assert(S.PendingInstantiations.empty() &&
1373013737
"PendingInstantiations should be empty before it is discarded.");
1373113738
S.PendingInstantiations.swap(S.SavedPendingInstantiations.back());
@@ -13744,6 +13751,7 @@ class Sema final : public SemaBase {
1374413751
private:
1374513752
Sema &S;
1374613753
bool Enabled;
13754+
bool AtEndOfTU;
1374713755
};
1374813756

1374913757
ExplicitSpecifier instantiateExplicitSpecifier(
@@ -13929,7 +13937,8 @@ class Sema final : public SemaBase {
1392913937

1393013938
/// Performs template instantiation for all implicit template
1393113939
/// instantiations we have seen until this point.
13932-
void PerformPendingInstantiations(bool LocalOnly = false);
13940+
void PerformPendingInstantiations(bool LocalOnly = false,
13941+
bool AtEndOfTU = true);
1393313942

1393413943
TemplateParameterList *
1393513944
SubstTemplateParams(TemplateParameterList *Params, DeclContext *Owner,

clang/lib/AST/ExprConstant.cpp

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3628,8 +3628,6 @@ static bool evaluateVarDeclInit(EvalInfo &Info, const Expr *E,
36283628
if (AllowConstexprUnknown) {
36293629
if (!Result)
36303630
Result = &Info.CurrentCall->createConstexprUnknownAPValues(VD, Base);
3631-
else
3632-
Result->setConstexprUnknown();
36333631
}
36343632
return true;
36353633
}
@@ -16995,6 +16993,18 @@ bool Expr::EvaluateAsInitializer(APValue &Value, const ASTContext &Ctx,
1699516993

1699616994
if (!Info.discardCleanups())
1699716995
llvm_unreachable("Unhandled cleanup; missing full expression marker?");
16996+
16997+
if (Value.allowConstexprUnknown()) {
16998+
assert(Value.isLValue() && "Expected an lvalue");
16999+
auto Base = Value.getLValueBase();
17000+
const auto *NewVD = Base.dyn_cast<const ValueDecl *>();
17001+
if (!NewVD)
17002+
NewVD = VD;
17003+
Info.FFDiag(getExprLoc(), diag::note_constexpr_var_init_non_constant, 1)
17004+
<< NewVD;
17005+
NoteLValueLocation(Info, Base);
17006+
return false;
17007+
}
1699817008
}
1699917009

1700017010
return CheckConstantExpression(Info, DeclLoc, DeclTy, Value,

clang/lib/CodeGen/CGExprConstant.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1883,8 +1883,11 @@ llvm::Constant *ConstantEmitter::tryEmitPrivateForVarInit(const VarDecl &D) {
18831883

18841884
// Try to emit the initializer. Note that this can allow some things that
18851885
// are not allowed by tryEmitPrivateForMemory alone.
1886-
if (APValue *value = D.evaluateValue())
1886+
if (APValue *value = D.evaluateValue()) {
1887+
assert(!value->allowConstexprUnknown() &&
1888+
"Constexpr unknown values are not allowed in CodeGen");
18871889
return tryEmitPrivateForMemory(*value, destType);
1890+
}
18881891

18891892
return nullptr;
18901893
}

clang/lib/Format/TokenAnnotator.cpp

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4845,16 +4845,11 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
48454845
return Style.SpaceBeforeParensOptions.AfterControlStatements ||
48464846
spaceRequiredBeforeParens(Right);
48474847
}
4848-
if (Left.isOneOf(tok::kw_new, tok::kw_delete)) {
4849-
return ((!Line.MightBeFunctionDecl || !BeforeLeft) &&
4850-
Style.SpaceBeforeParens != FormatStyle::SBPO_Never) ||
4851-
spaceRequiredBeforeParens(Right);
4852-
}
4853-
4854-
if (Left.is(tok::r_square) && Left.MatchingParen &&
4855-
Left.MatchingParen->Previous &&
4856-
Left.MatchingParen->Previous->is(tok::kw_delete)) {
4857-
return (Style.SpaceBeforeParens != FormatStyle::SBPO_Never) ||
4848+
if (Left.isOneOf(tok::kw_new, tok::kw_delete) ||
4849+
(Left.is(tok::r_square) && Left.MatchingParen &&
4850+
Left.MatchingParen->Previous &&
4851+
Left.MatchingParen->Previous->is(tok::kw_delete))) {
4852+
return Style.SpaceBeforeParens != FormatStyle::SBPO_Never ||
48584853
spaceRequiredBeforeParens(Right);
48594854
}
48604855
}

clang/lib/Headers/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ set(hlsl_h
8686
)
8787
set(hlsl_subdir_files
8888
hlsl/hlsl_basic_types.h
89+
hlsl/hlsl_alias_intrinsics.h
8990
hlsl/hlsl_intrinsics.h
9091
hlsl/hlsl_detail.h
9192
)

0 commit comments

Comments
 (0)