Skip to content

Commit 84e89ac

Browse files
committed
merge main into amd-staging
Reverts: breaks comgr test 435d4c1 Reapply [RemoveDIs] Read/write DbgRecords directly from/to bitcode (llvm#83251) Change-Id: Ic1423e133e553e0ae22db56b25773f76c8d72bcb
2 parents df817a8 + 435d4c1 commit 84e89ac

File tree

78 files changed

+2919
-2735
lines changed

Some content is hidden

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

78 files changed

+2919
-2735
lines changed

clang/lib/AST/Interp/ByteCodeStmtGen.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,11 @@ bool ByteCodeStmtGen<Emitter>::visitWhileStmt(const WhileStmt *S) {
423423
LoopScope<Emitter> LS(this, EndLabel, CondLabel);
424424

425425
this->emitLabel(CondLabel);
426+
427+
if (const DeclStmt *CondDecl = S->getConditionVariableDeclStmt())
428+
if (!visitDeclStmt(CondDecl))
429+
return false;
430+
426431
if (!this->visitBool(Cond))
427432
return false;
428433
if (!this->jumpFalse(EndLabel))
@@ -487,6 +492,10 @@ bool ByteCodeStmtGen<Emitter>::visitForStmt(const ForStmt *S) {
487492
if (Init && !this->visitStmt(Init))
488493
return false;
489494
this->emitLabel(CondLabel);
495+
496+
if (const DeclStmt *CondDecl = S->getConditionVariableDeclStmt())
497+
if (!visitDeclStmt(CondDecl))
498+
return false;
490499
if (Cond) {
491500
if (!this->visitBool(Cond))
492501
return false;
@@ -585,17 +594,21 @@ bool ByteCodeStmtGen<Emitter>::visitContinueStmt(const ContinueStmt *S) {
585594
template <class Emitter>
586595
bool ByteCodeStmtGen<Emitter>::visitSwitchStmt(const SwitchStmt *S) {
587596
const Expr *Cond = S->getCond();
588-
PrimType CondT = this->classifyPrim(Cond->getType());
589597

590598
LabelTy EndLabel = this->getLabel();
591599
OptLabelTy DefaultLabel = std::nullopt;
592-
unsigned CondVar = this->allocateLocalPrimitive(Cond, CondT, true, false);
593600

594601
if (const auto *CondInit = S->getInit())
595602
if (!visitStmt(CondInit))
596603
return false;
597604

605+
if (const DeclStmt *CondDecl = S->getConditionVariableDeclStmt())
606+
if (!visitDeclStmt(CondDecl))
607+
return false;
608+
598609
// Initialize condition variable.
610+
PrimType CondT = this->classifyPrim(Cond->getType());
611+
unsigned CondVar = this->allocateLocalPrimitive(Cond, CondT, true, false);
599612
if (!this->visit(Cond))
600613
return false;
601614
if (!this->emitSetLocal(CondT, CondVar, S))

clang/test/SemaCXX/decomposed-condition.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// RUN: %clang_cc1 -std=c++1z -Wno-binding-in-condition -verify %s
2+
// RUN: %clang_cc1 -std=c++1z -Wno-binding-in-condition -verify %s -fexperimental-new-constant-interpreter
23

34
struct X {
45
bool flag;

flang/include/flang/Evaluate/tools.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,28 @@ template <typename A> std::optional<CoarrayRef> ExtractCoarrayRef(const A &x) {
430430
}
431431
}
432432

433+
struct ExtractSubstringHelper {
434+
template <typename T> static std::optional<Substring> visit(T &&) {
435+
return std::nullopt;
436+
}
437+
438+
static std::optional<Substring> visit(const Substring &e) { return e; }
439+
440+
template <typename T>
441+
static std::optional<Substring> visit(const Designator<T> &e) {
442+
return std::visit([](auto &&s) { return visit(s); }, e.u);
443+
}
444+
445+
template <typename T>
446+
static std::optional<Substring> visit(const Expr<T> &e) {
447+
return std::visit([](auto &&s) { return visit(s); }, e.u);
448+
}
449+
};
450+
451+
template <typename A> std::optional<Substring> ExtractSubstring(const A &x) {
452+
return ExtractSubstringHelper::visit(x);
453+
}
454+
433455
// If an expression is simply a whole symbol data designator,
434456
// extract and return that symbol, else null.
435457
template <typename A> const Symbol *UnwrapWholeSymbolDataRef(const A &x) {

0 commit comments

Comments
 (0)