Use CTAD on llvm::SaveAndRestore
Reviewed By: dblaikie Differential Revision: https://reviews.llvm.org/D139229
This commit is contained in:
parent
bc83d1c655
commit
abf0c6c0c0
|
@ -567,7 +567,7 @@ public:
|
|||
if (Check->reportDeMorgan(Context, Op, BinaryOp, !IsProcessing, parent(),
|
||||
Parens) &&
|
||||
!Check->areDiagsSelfContained()) {
|
||||
llvm::SaveAndRestore<bool> RAII(IsProcessing, true);
|
||||
llvm::SaveAndRestore RAII(IsProcessing, true);
|
||||
return Base::TraverseUnaryOperator(Op);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ public:
|
|||
if (!D || D->isImplicit())
|
||||
return true;
|
||||
|
||||
SaveAndRestore<bool> Save(FullyMigratable, isMigratable(D));
|
||||
SaveAndRestore Save(FullyMigratable, isMigratable(D));
|
||||
|
||||
if (ObjCPropertyDecl *PropD = dyn_cast<ObjCPropertyDecl>(D)) {
|
||||
lookForAttribute(PropD, PropD->getTypeSourceInfo());
|
||||
|
|
|
@ -7961,8 +7961,8 @@ public:
|
|||
bool VisitStmtExpr(const StmtExpr *E) {
|
||||
// We will have checked the full-expressions inside the statement expression
|
||||
// when they were completed, and don't need to check them again now.
|
||||
llvm::SaveAndRestore<bool> NotCheckingForUB(
|
||||
Info.CheckingForUndefinedBehavior, false);
|
||||
llvm::SaveAndRestore NotCheckingForUB(Info.CheckingForUndefinedBehavior,
|
||||
false);
|
||||
|
||||
const CompoundStmt *CS = E->getSubStmt();
|
||||
if (CS->body_empty())
|
||||
|
|
|
@ -195,7 +195,7 @@ void TypePrinter::print(const Type *T, Qualifiers Quals, raw_ostream &OS,
|
|||
return;
|
||||
}
|
||||
|
||||
SaveAndRestore<bool> PHVal(HasEmptyPlaceHolder, PlaceHolder.empty());
|
||||
SaveAndRestore PHVal(HasEmptyPlaceHolder, PlaceHolder.empty());
|
||||
|
||||
printBefore(T, Quals, OS);
|
||||
OS << PlaceHolder;
|
||||
|
@ -319,7 +319,7 @@ void TypePrinter::printBefore(const Type *T,Qualifiers Quals, raw_ostream &OS) {
|
|||
if (Policy.SuppressSpecifiers && T->isSpecifierType())
|
||||
return;
|
||||
|
||||
SaveAndRestore<bool> PrevPHIsEmpty(HasEmptyPlaceHolder);
|
||||
SaveAndRestore PrevPHIsEmpty(HasEmptyPlaceHolder);
|
||||
|
||||
// Print qualifiers as appropriate.
|
||||
|
||||
|
@ -396,7 +396,7 @@ void TypePrinter::printComplexAfter(const ComplexType *T, raw_ostream &OS) {
|
|||
|
||||
void TypePrinter::printPointerBefore(const PointerType *T, raw_ostream &OS) {
|
||||
IncludeStrongLifetimeRAII Strong(Policy);
|
||||
SaveAndRestore<bool> NonEmptyPH(HasEmptyPlaceHolder, false);
|
||||
SaveAndRestore NonEmptyPH(HasEmptyPlaceHolder, false);
|
||||
printBefore(T->getPointeeType(), OS);
|
||||
// Handle things like 'int (*A)[4];' correctly.
|
||||
// FIXME: this should include vectors, but vectors use attributes I guess.
|
||||
|
@ -407,7 +407,7 @@ void TypePrinter::printPointerBefore(const PointerType *T, raw_ostream &OS) {
|
|||
|
||||
void TypePrinter::printPointerAfter(const PointerType *T, raw_ostream &OS) {
|
||||
IncludeStrongLifetimeRAII Strong(Policy);
|
||||
SaveAndRestore<bool> NonEmptyPH(HasEmptyPlaceHolder, false);
|
||||
SaveAndRestore NonEmptyPH(HasEmptyPlaceHolder, false);
|
||||
// Handle things like 'int (*A)[4];' correctly.
|
||||
// FIXME: this should include vectors, but vectors use attributes I guess.
|
||||
if (isa<ArrayType>(T->getPointeeType()))
|
||||
|
@ -417,14 +417,14 @@ void TypePrinter::printPointerAfter(const PointerType *T, raw_ostream &OS) {
|
|||
|
||||
void TypePrinter::printBlockPointerBefore(const BlockPointerType *T,
|
||||
raw_ostream &OS) {
|
||||
SaveAndRestore<bool> NonEmptyPH(HasEmptyPlaceHolder, false);
|
||||
SaveAndRestore NonEmptyPH(HasEmptyPlaceHolder, false);
|
||||
printBefore(T->getPointeeType(), OS);
|
||||
OS << '^';
|
||||
}
|
||||
|
||||
void TypePrinter::printBlockPointerAfter(const BlockPointerType *T,
|
||||
raw_ostream &OS) {
|
||||
SaveAndRestore<bool> NonEmptyPH(HasEmptyPlaceHolder, false);
|
||||
SaveAndRestore NonEmptyPH(HasEmptyPlaceHolder, false);
|
||||
printAfter(T->getPointeeType(), OS);
|
||||
}
|
||||
|
||||
|
@ -439,7 +439,7 @@ static QualType skipTopLevelReferences(QualType T) {
|
|||
void TypePrinter::printLValueReferenceBefore(const LValueReferenceType *T,
|
||||
raw_ostream &OS) {
|
||||
IncludeStrongLifetimeRAII Strong(Policy);
|
||||
SaveAndRestore<bool> NonEmptyPH(HasEmptyPlaceHolder, false);
|
||||
SaveAndRestore NonEmptyPH(HasEmptyPlaceHolder, false);
|
||||
QualType Inner = skipTopLevelReferences(T->getPointeeTypeAsWritten());
|
||||
printBefore(Inner, OS);
|
||||
// Handle things like 'int (&A)[4];' correctly.
|
||||
|
@ -452,7 +452,7 @@ void TypePrinter::printLValueReferenceBefore(const LValueReferenceType *T,
|
|||
void TypePrinter::printLValueReferenceAfter(const LValueReferenceType *T,
|
||||
raw_ostream &OS) {
|
||||
IncludeStrongLifetimeRAII Strong(Policy);
|
||||
SaveAndRestore<bool> NonEmptyPH(HasEmptyPlaceHolder, false);
|
||||
SaveAndRestore NonEmptyPH(HasEmptyPlaceHolder, false);
|
||||
QualType Inner = skipTopLevelReferences(T->getPointeeTypeAsWritten());
|
||||
// Handle things like 'int (&A)[4];' correctly.
|
||||
// FIXME: this should include vectors, but vectors use attributes I guess.
|
||||
|
@ -464,7 +464,7 @@ void TypePrinter::printLValueReferenceAfter(const LValueReferenceType *T,
|
|||
void TypePrinter::printRValueReferenceBefore(const RValueReferenceType *T,
|
||||
raw_ostream &OS) {
|
||||
IncludeStrongLifetimeRAII Strong(Policy);
|
||||
SaveAndRestore<bool> NonEmptyPH(HasEmptyPlaceHolder, false);
|
||||
SaveAndRestore NonEmptyPH(HasEmptyPlaceHolder, false);
|
||||
QualType Inner = skipTopLevelReferences(T->getPointeeTypeAsWritten());
|
||||
printBefore(Inner, OS);
|
||||
// Handle things like 'int (&&A)[4];' correctly.
|
||||
|
@ -477,7 +477,7 @@ void TypePrinter::printRValueReferenceBefore(const RValueReferenceType *T,
|
|||
void TypePrinter::printRValueReferenceAfter(const RValueReferenceType *T,
|
||||
raw_ostream &OS) {
|
||||
IncludeStrongLifetimeRAII Strong(Policy);
|
||||
SaveAndRestore<bool> NonEmptyPH(HasEmptyPlaceHolder, false);
|
||||
SaveAndRestore NonEmptyPH(HasEmptyPlaceHolder, false);
|
||||
QualType Inner = skipTopLevelReferences(T->getPointeeTypeAsWritten());
|
||||
// Handle things like 'int (&&A)[4];' correctly.
|
||||
// FIXME: this should include vectors, but vectors use attributes I guess.
|
||||
|
@ -489,7 +489,7 @@ void TypePrinter::printRValueReferenceAfter(const RValueReferenceType *T,
|
|||
void TypePrinter::printMemberPointerBefore(const MemberPointerType *T,
|
||||
raw_ostream &OS) {
|
||||
IncludeStrongLifetimeRAII Strong(Policy);
|
||||
SaveAndRestore<bool> NonEmptyPH(HasEmptyPlaceHolder, false);
|
||||
SaveAndRestore NonEmptyPH(HasEmptyPlaceHolder, false);
|
||||
printBefore(T->getPointeeType(), OS);
|
||||
// Handle things like 'int (Cls::*A)[4];' correctly.
|
||||
// FIXME: this should include vectors, but vectors use attributes I guess.
|
||||
|
@ -506,7 +506,7 @@ void TypePrinter::printMemberPointerBefore(const MemberPointerType *T,
|
|||
void TypePrinter::printMemberPointerAfter(const MemberPointerType *T,
|
||||
raw_ostream &OS) {
|
||||
IncludeStrongLifetimeRAII Strong(Policy);
|
||||
SaveAndRestore<bool> NonEmptyPH(HasEmptyPlaceHolder, false);
|
||||
SaveAndRestore NonEmptyPH(HasEmptyPlaceHolder, false);
|
||||
// Handle things like 'int (Cls::*A)[4];' correctly.
|
||||
// FIXME: this should include vectors, but vectors use attributes I guess.
|
||||
if (isa<ArrayType>(T->getPointeeType()))
|
||||
|
@ -848,7 +848,7 @@ void TypePrinter::printFunctionProtoBefore(const FunctionProtoType *T,
|
|||
OS << '(';
|
||||
} else {
|
||||
// If needed for precedence reasons, wrap the inner part in grouping parens.
|
||||
SaveAndRestore<bool> PrevPHIsEmpty(HasEmptyPlaceHolder, false);
|
||||
SaveAndRestore PrevPHIsEmpty(HasEmptyPlaceHolder, false);
|
||||
printBefore(T->getReturnType(), OS);
|
||||
if (!PrevPHIsEmpty.get())
|
||||
OS << '(';
|
||||
|
@ -876,7 +876,7 @@ void TypePrinter::printFunctionProtoAfter(const FunctionProtoType *T,
|
|||
// If needed for precedence reasons, wrap the inner part in grouping parens.
|
||||
if (!HasEmptyPlaceHolder)
|
||||
OS << ')';
|
||||
SaveAndRestore<bool> NonEmptyPH(HasEmptyPlaceHolder, false);
|
||||
SaveAndRestore NonEmptyPH(HasEmptyPlaceHolder, false);
|
||||
|
||||
OS << '(';
|
||||
{
|
||||
|
@ -1027,7 +1027,7 @@ void TypePrinter::printFunctionAfter(const FunctionType::ExtInfo &Info,
|
|||
void TypePrinter::printFunctionNoProtoBefore(const FunctionNoProtoType *T,
|
||||
raw_ostream &OS) {
|
||||
// If needed for precedence reasons, wrap the inner part in grouping parens.
|
||||
SaveAndRestore<bool> PrevPHIsEmpty(HasEmptyPlaceHolder, false);
|
||||
SaveAndRestore PrevPHIsEmpty(HasEmptyPlaceHolder, false);
|
||||
printBefore(T->getReturnType(), OS);
|
||||
if (!PrevPHIsEmpty.get())
|
||||
OS << '(';
|
||||
|
@ -1038,7 +1038,7 @@ void TypePrinter::printFunctionNoProtoAfter(const FunctionNoProtoType *T,
|
|||
// If needed for precedence reasons, wrap the inner part in grouping parens.
|
||||
if (!HasEmptyPlaceHolder)
|
||||
OS << ')';
|
||||
SaveAndRestore<bool> NonEmptyPH(HasEmptyPlaceHolder, false);
|
||||
SaveAndRestore NonEmptyPH(HasEmptyPlaceHolder, false);
|
||||
|
||||
OS << "()";
|
||||
printFunctionAfter(T->getExtInfo(), OS);
|
||||
|
@ -1676,7 +1676,7 @@ void TypePrinter::printAttributedAfter(const AttributedType *T,
|
|||
|
||||
// If this is a calling convention attribute, don't print the implicit CC from
|
||||
// the modified type.
|
||||
SaveAndRestore<bool> MaybeSuppressCC(InsideCCAttribute, T->isCallingConv());
|
||||
SaveAndRestore MaybeSuppressCC(InsideCCAttribute, T->isCallingConv());
|
||||
|
||||
printAfter(T->getModifiedType(), OS);
|
||||
|
||||
|
|
|
@ -231,8 +231,7 @@ CFG *AnalysisDeclContext::getCFG() {
|
|||
|
||||
CFG *AnalysisDeclContext::getUnoptimizedCFG() {
|
||||
if (!builtCompleteCFG) {
|
||||
SaveAndRestore<bool> NotPrune(cfgBuildOptions.PruneTriviallyFalseEdges,
|
||||
false);
|
||||
SaveAndRestore NotPrune(cfgBuildOptions.PruneTriviallyFalseEdges, false);
|
||||
completeCFG =
|
||||
CFG::buildCFG(D, getBody(), &D->getASTContext(), cfgBuildOptions);
|
||||
// Even when the cfg is not successfully built, we don't
|
||||
|
|
|
@ -3073,7 +3073,7 @@ CFGBlock *CFGBuilder::VisitIfStmt(IfStmt *I) {
|
|||
|
||||
// Save local scope position because in case of condition variable ScopePos
|
||||
// won't be restored when traversing AST.
|
||||
SaveAndRestore<LocalScope::const_iterator> save_scope_pos(ScopePos);
|
||||
SaveAndRestore save_scope_pos(ScopePos);
|
||||
|
||||
// Create local scope for C++17 if init-stmt if one exists.
|
||||
if (Stmt *Init = I->getInit())
|
||||
|
@ -3098,7 +3098,7 @@ CFGBlock *CFGBuilder::VisitIfStmt(IfStmt *I) {
|
|||
CFGBlock *ElseBlock = Succ;
|
||||
|
||||
if (Stmt *Else = I->getElse()) {
|
||||
SaveAndRestore<CFGBlock*> sv(Succ);
|
||||
SaveAndRestore sv(Succ);
|
||||
|
||||
// NULL out Block so that the recursive call to Visit will
|
||||
// create a new basic block.
|
||||
|
@ -3124,7 +3124,7 @@ CFGBlock *CFGBuilder::VisitIfStmt(IfStmt *I) {
|
|||
{
|
||||
Stmt *Then = I->getThen();
|
||||
assert(Then);
|
||||
SaveAndRestore<CFGBlock*> sv(Succ);
|
||||
SaveAndRestore sv(Succ);
|
||||
Block = nullptr;
|
||||
|
||||
// If branch is not a compound statement create implicit scope
|
||||
|
@ -3274,7 +3274,7 @@ CFGBlock *CFGBuilder::VisitSEHExceptStmt(SEHExceptStmt *ES) {
|
|||
|
||||
// Save local scope position because in case of exception variable ScopePos
|
||||
// won't be restored when traversing AST.
|
||||
SaveAndRestore<LocalScope::const_iterator> save_scope_pos(ScopePos);
|
||||
SaveAndRestore save_scope_pos(ScopePos);
|
||||
|
||||
addStmt(ES->getBlock());
|
||||
CFGBlock *SEHExceptBlock = Block;
|
||||
|
@ -3364,13 +3364,13 @@ CFGBlock *CFGBuilder::VisitSEHTryStmt(SEHTryStmt *Terminator) {
|
|||
Succ = SEHTrySuccessor;
|
||||
|
||||
// Save the current "__try" context.
|
||||
SaveAndRestore<CFGBlock *> SaveTry(TryTerminatedBlock, NewTryTerminatedBlock);
|
||||
SaveAndRestore SaveTry(TryTerminatedBlock, NewTryTerminatedBlock);
|
||||
cfg->addTryDispatchBlock(TryTerminatedBlock);
|
||||
|
||||
// Save the current value for the __leave target.
|
||||
// All __leaves should go to the code following the __try
|
||||
// (FIXME: or if the __try has a __finally, to the __finally.)
|
||||
SaveAndRestore<JumpTarget> save_break(SEHLeaveJumpTarget);
|
||||
SaveAndRestore save_break(SEHLeaveJumpTarget);
|
||||
SEHLeaveJumpTarget = JumpTarget(SEHTrySuccessor, ScopePos);
|
||||
|
||||
assert(Terminator->getTryBlock() && "__try must contain a non-NULL body");
|
||||
|
@ -3493,7 +3493,7 @@ CFGBlock *CFGBuilder::VisitForStmt(ForStmt *F) {
|
|||
|
||||
// Save local scope position because in case of condition variable ScopePos
|
||||
// won't be restored when traversing AST.
|
||||
SaveAndRestore<LocalScope::const_iterator> save_scope_pos(ScopePos);
|
||||
SaveAndRestore save_scope_pos(ScopePos);
|
||||
|
||||
// Create local scope for init statement and possible condition variable.
|
||||
// Add destructor for init statement and condition variable.
|
||||
|
@ -3521,7 +3521,7 @@ CFGBlock *CFGBuilder::VisitForStmt(ForStmt *F) {
|
|||
|
||||
// Save the current value for the break targets.
|
||||
// All breaks should go to the code following the loop.
|
||||
SaveAndRestore<JumpTarget> save_break(BreakJumpTarget);
|
||||
SaveAndRestore save_break(BreakJumpTarget);
|
||||
BreakJumpTarget = JumpTarget(LoopSuccessor, ScopePos);
|
||||
|
||||
CFGBlock *BodyBlock = nullptr, *TransitionBlock = nullptr;
|
||||
|
@ -3531,8 +3531,8 @@ CFGBlock *CFGBuilder::VisitForStmt(ForStmt *F) {
|
|||
assert(F->getBody());
|
||||
|
||||
// Save the current values for Block, Succ, continue and break targets.
|
||||
SaveAndRestore<CFGBlock*> save_Block(Block), save_Succ(Succ);
|
||||
SaveAndRestore<JumpTarget> save_continue(ContinueJumpTarget);
|
||||
SaveAndRestore save_Block(Block), save_Succ(Succ);
|
||||
SaveAndRestore save_continue(ContinueJumpTarget);
|
||||
|
||||
// Create an empty block to represent the transition block for looping back
|
||||
// to the head of the loop. If we have increment code, it will
|
||||
|
@ -3587,7 +3587,7 @@ CFGBlock *CFGBuilder::VisitForStmt(ForStmt *F) {
|
|||
|
||||
do {
|
||||
Expr *C = F->getCond();
|
||||
SaveAndRestore<LocalScope::const_iterator> save_scope_pos(ScopePos);
|
||||
SaveAndRestore save_scope_pos(ScopePos);
|
||||
|
||||
// Specially handle logical operators, which have a slightly
|
||||
// more optimal CFG representation.
|
||||
|
@ -3653,7 +3653,7 @@ CFGBlock *CFGBuilder::VisitForStmt(ForStmt *F) {
|
|||
// If the loop contains initialization, create a new block for those
|
||||
// statements. This block can also contain statements that precede the loop.
|
||||
if (Stmt *I = F->getInit()) {
|
||||
SaveAndRestore<LocalScope::const_iterator> save_scope_pos(ScopePos);
|
||||
SaveAndRestore save_scope_pos(ScopePos);
|
||||
ScopePos = LoopBeginScopePos;
|
||||
Block = createBlock();
|
||||
return addStmt(I);
|
||||
|
@ -3756,9 +3756,9 @@ CFGBlock *CFGBuilder::VisitObjCForCollectionStmt(ObjCForCollectionStmt *S) {
|
|||
// Now create the true branch.
|
||||
{
|
||||
// Save the current values for Succ, continue and break targets.
|
||||
SaveAndRestore<CFGBlock*> save_Block(Block), save_Succ(Succ);
|
||||
SaveAndRestore<JumpTarget> save_continue(ContinueJumpTarget),
|
||||
save_break(BreakJumpTarget);
|
||||
SaveAndRestore save_Block(Block), save_Succ(Succ);
|
||||
SaveAndRestore save_continue(ContinueJumpTarget),
|
||||
save_break(BreakJumpTarget);
|
||||
|
||||
// Add an intermediate block between the BodyBlock and the
|
||||
// EntryConditionBlock to represent the "loop back" transition, for looping
|
||||
|
@ -3852,7 +3852,7 @@ CFGBlock *CFGBuilder::VisitWhileStmt(WhileStmt *W) {
|
|||
|
||||
// Save local scope position because in case of condition variable ScopePos
|
||||
// won't be restored when traversing AST.
|
||||
SaveAndRestore<LocalScope::const_iterator> save_scope_pos(ScopePos);
|
||||
SaveAndRestore save_scope_pos(ScopePos);
|
||||
|
||||
// Create local scope for possible condition variable.
|
||||
// Store scope position for continue statement.
|
||||
|
@ -3881,9 +3881,9 @@ CFGBlock *CFGBuilder::VisitWhileStmt(WhileStmt *W) {
|
|||
assert(W->getBody());
|
||||
|
||||
// Save the current values for Block, Succ, continue and break targets.
|
||||
SaveAndRestore<CFGBlock*> save_Block(Block), save_Succ(Succ);
|
||||
SaveAndRestore<JumpTarget> save_continue(ContinueJumpTarget),
|
||||
save_break(BreakJumpTarget);
|
||||
SaveAndRestore save_Block(Block), save_Succ(Succ);
|
||||
SaveAndRestore save_continue(ContinueJumpTarget),
|
||||
save_break(BreakJumpTarget);
|
||||
|
||||
// Create an empty block to represent the transition block for looping back
|
||||
// to the head of the loop.
|
||||
|
@ -4009,7 +4009,7 @@ CFGBlock *CFGBuilder::VisitObjCAtCatchStmt(ObjCAtCatchStmt *CS) {
|
|||
|
||||
// Save local scope position because in case of exception variable ScopePos
|
||||
// won't be restored when traversing AST.
|
||||
SaveAndRestore<LocalScope::const_iterator> save_scope_pos(ScopePos);
|
||||
SaveAndRestore save_scope_pos(ScopePos);
|
||||
|
||||
if (CS->getCatchBody())
|
||||
addStmt(CS->getCatchBody());
|
||||
|
@ -4104,7 +4104,7 @@ CFGBlock *CFGBuilder::VisitObjCAtTryStmt(ObjCAtTryStmt *Terminator) {
|
|||
Succ = TrySuccessor;
|
||||
|
||||
// Save the current "try" context.
|
||||
SaveAndRestore<CFGBlock *> SaveTry(TryTerminatedBlock, NewTryTerminatedBlock);
|
||||
SaveAndRestore SaveTry(TryTerminatedBlock, NewTryTerminatedBlock);
|
||||
cfg->addTryDispatchBlock(TryTerminatedBlock);
|
||||
|
||||
assert(Terminator->getTryBody() && "try must contain a non-NULL body");
|
||||
|
@ -4207,8 +4207,8 @@ CFGBlock *CFGBuilder::VisitDoStmt(DoStmt *D) {
|
|||
assert(D->getBody());
|
||||
|
||||
// Save the current values for Block, Succ, and continue and break targets
|
||||
SaveAndRestore<CFGBlock*> save_Block(Block), save_Succ(Succ);
|
||||
SaveAndRestore<JumpTarget> save_continue(ContinueJumpTarget),
|
||||
SaveAndRestore save_Block(Block), save_Succ(Succ);
|
||||
SaveAndRestore save_continue(ContinueJumpTarget),
|
||||
save_break(BreakJumpTarget);
|
||||
|
||||
// All continues within this loop should go to the condition block
|
||||
|
@ -4326,7 +4326,7 @@ CFGBlock *CFGBuilder::VisitSwitchStmt(SwitchStmt *Terminator) {
|
|||
|
||||
// Save local scope position because in case of condition variable ScopePos
|
||||
// won't be restored when traversing AST.
|
||||
SaveAndRestore<LocalScope::const_iterator> save_scope_pos(ScopePos);
|
||||
SaveAndRestore save_scope_pos(ScopePos);
|
||||
|
||||
// Create local scope for C++17 switch init-stmt if one exists.
|
||||
if (Stmt *Init = Terminator->getInit())
|
||||
|
@ -4346,9 +4346,9 @@ CFGBlock *CFGBuilder::VisitSwitchStmt(SwitchStmt *Terminator) {
|
|||
} else SwitchSuccessor = Succ;
|
||||
|
||||
// Save the current "switch" context.
|
||||
SaveAndRestore<CFGBlock*> save_switch(SwitchTerminatedBlock),
|
||||
save_default(DefaultCaseBlock);
|
||||
SaveAndRestore<JumpTarget> save_break(BreakJumpTarget);
|
||||
SaveAndRestore save_switch(SwitchTerminatedBlock),
|
||||
save_default(DefaultCaseBlock);
|
||||
SaveAndRestore save_break(BreakJumpTarget);
|
||||
|
||||
// Set the "default" case to be the block after the switch statement. If the
|
||||
// switch statement contains a "default:", this value will be overwritten with
|
||||
|
@ -4371,15 +4371,13 @@ CFGBlock *CFGBuilder::VisitSwitchStmt(SwitchStmt *Terminator) {
|
|||
|
||||
// For pruning unreachable case statements, save the current state
|
||||
// for tracking the condition value.
|
||||
SaveAndRestore<bool> save_switchExclusivelyCovered(switchExclusivelyCovered,
|
||||
false);
|
||||
SaveAndRestore save_switchExclusivelyCovered(switchExclusivelyCovered, false);
|
||||
|
||||
// Determine if the switch condition can be explicitly evaluated.
|
||||
assert(Terminator->getCond() && "switch condition must be non-NULL");
|
||||
Expr::EvalResult result;
|
||||
bool b = tryEvaluate(Terminator->getCond(), result);
|
||||
SaveAndRestore<Expr::EvalResult*> save_switchCond(switchCond,
|
||||
b ? &result : nullptr);
|
||||
SaveAndRestore save_switchCond(switchCond, b ? &result : nullptr);
|
||||
|
||||
// If body is not a compound statement create implicit scope
|
||||
// and add destructors.
|
||||
|
@ -4606,7 +4604,7 @@ CFGBlock *CFGBuilder::VisitCXXTryStmt(CXXTryStmt *Terminator) {
|
|||
Succ = TrySuccessor;
|
||||
|
||||
// Save the current "try" context.
|
||||
SaveAndRestore<CFGBlock *> SaveTry(TryTerminatedBlock, NewTryTerminatedBlock);
|
||||
SaveAndRestore SaveTry(TryTerminatedBlock, NewTryTerminatedBlock);
|
||||
cfg->addTryDispatchBlock(TryTerminatedBlock);
|
||||
|
||||
assert(Terminator->getTryBlock() && "try must contain a non-NULL body");
|
||||
|
@ -4620,7 +4618,7 @@ CFGBlock *CFGBuilder::VisitCXXCatchStmt(CXXCatchStmt *CS) {
|
|||
|
||||
// Save local scope position because in case of exception variable ScopePos
|
||||
// won't be restored when traversing AST.
|
||||
SaveAndRestore<LocalScope::const_iterator> save_scope_pos(ScopePos);
|
||||
SaveAndRestore save_scope_pos(ScopePos);
|
||||
|
||||
// Create local scope for possible exception variable.
|
||||
// Store scope position. Add implicit destructor.
|
||||
|
@ -4672,7 +4670,7 @@ CFGBlock *CFGBuilder::VisitCXXForRangeStmt(CXXForRangeStmt *S) {
|
|||
// }
|
||||
|
||||
// Save local scope position before the addition of the implicit variables.
|
||||
SaveAndRestore<LocalScope::const_iterator> save_scope_pos(ScopePos);
|
||||
SaveAndRestore save_scope_pos(ScopePos);
|
||||
|
||||
// Create local scopes and destructors for range, begin and end variables.
|
||||
if (Stmt *Range = S->getRangeStmt())
|
||||
|
@ -4697,7 +4695,7 @@ CFGBlock *CFGBuilder::VisitCXXForRangeStmt(CXXForRangeStmt *S) {
|
|||
|
||||
// Save the current value for the break targets.
|
||||
// All breaks should go to the code following the loop.
|
||||
SaveAndRestore<JumpTarget> save_break(BreakJumpTarget);
|
||||
SaveAndRestore save_break(BreakJumpTarget);
|
||||
BreakJumpTarget = JumpTarget(LoopSuccessor, ScopePos);
|
||||
|
||||
// The block for the __begin != __end expression.
|
||||
|
@ -4730,8 +4728,8 @@ CFGBlock *CFGBuilder::VisitCXXForRangeStmt(CXXForRangeStmt *S) {
|
|||
assert(S->getBody());
|
||||
|
||||
// Save the current values for Block, Succ, and continue targets.
|
||||
SaveAndRestore<CFGBlock*> save_Block(Block), save_Succ(Succ);
|
||||
SaveAndRestore<JumpTarget> save_continue(ContinueJumpTarget);
|
||||
SaveAndRestore save_Block(Block), save_Succ(Succ);
|
||||
SaveAndRestore save_continue(ContinueJumpTarget);
|
||||
|
||||
// Generate increment code in its own basic block. This is the target of
|
||||
// continue statements.
|
||||
|
|
|
@ -1016,8 +1016,7 @@ void CodeGenFunction::PopCleanupBlock(bool FallthroughIsBranchThrough) {
|
|||
// throwing cleanups. For funclet EH personalities, the cleanupendpad models
|
||||
// program termination when cleanups throw.
|
||||
bool PushedTerminate = false;
|
||||
SaveAndRestore<llvm::Instruction *> RestoreCurrentFuncletPad(
|
||||
CurrentFuncletPad);
|
||||
SaveAndRestore RestoreCurrentFuncletPad(CurrentFuncletPad);
|
||||
llvm::CleanupPadInst *CPI = nullptr;
|
||||
|
||||
const EHPersonality &Personality = EHPersonality::get(*this);
|
||||
|
|
|
@ -1223,8 +1223,7 @@ void CodeGenFunction::ExitCXXTryStmt(const CXXTryStmt &S, bool IsFnTryBlock) {
|
|||
// Wasm uses Windows-style EH instructions, but merges all catch clauses into
|
||||
// one big catchpad. So we save the old funclet pad here before we traverse
|
||||
// each catch handler.
|
||||
SaveAndRestore<llvm::Instruction *> RestoreCurrentFuncletPad(
|
||||
CurrentFuncletPad);
|
||||
SaveAndRestore RestoreCurrentFuncletPad(CurrentFuncletPad);
|
||||
llvm::BasicBlock *WasmCatchStartBlock = nullptr;
|
||||
if (EHPersonality::get(*this).isWasmPersonality()) {
|
||||
auto *CatchSwitch =
|
||||
|
@ -1257,8 +1256,7 @@ void CodeGenFunction::ExitCXXTryStmt(const CXXTryStmt &S, bool IsFnTryBlock) {
|
|||
RunCleanupsScope CatchScope(*this);
|
||||
|
||||
// Initialize the catch variable and set up the cleanups.
|
||||
SaveAndRestore<llvm::Instruction *> RestoreCurrentFuncletPad(
|
||||
CurrentFuncletPad);
|
||||
SaveAndRestore RestoreCurrentFuncletPad(CurrentFuncletPad);
|
||||
CGM.getCXXABI().emitBeginCatch(*this, C);
|
||||
|
||||
// Emit the PGO counter increment.
|
||||
|
@ -1582,8 +1580,7 @@ llvm::BasicBlock *CodeGenFunction::getTerminateFunclet() {
|
|||
|
||||
// Create the cleanuppad using the current parent pad as its token. Use 'none'
|
||||
// if this is a top-level terminate scope, which is the common case.
|
||||
SaveAndRestore<llvm::Instruction *> RestoreCurrentFuncletPad(
|
||||
CurrentFuncletPad);
|
||||
SaveAndRestore RestoreCurrentFuncletPad(CurrentFuncletPad);
|
||||
llvm::Value *ParentPad = CurrentFuncletPad;
|
||||
if (!ParentPad)
|
||||
ParentPad = llvm::ConstantTokenNone::get(CGM.getLLVMContext());
|
||||
|
|
|
@ -230,7 +230,7 @@ void CGObjCRuntime::EmitTryCatchStmt(CodeGenFunction &CGF,
|
|||
CGF.EmitBlock(Handler.Block);
|
||||
|
||||
CodeGenFunction::LexicalScope Cleanups(CGF, Handler.Body->getSourceRange());
|
||||
SaveAndRestore<llvm::Instruction *> RevertAfterScope(CGF.CurrentFuncletPad);
|
||||
SaveAndRestore RevertAfterScope(CGF.CurrentFuncletPad);
|
||||
if (useFunclets) {
|
||||
llvm::Instruction *CPICandidate = Handler.Block->getFirstNonPHI();
|
||||
if (auto *CPI = dyn_cast_or_null<llvm::CatchPadInst>(CPICandidate)) {
|
||||
|
|
|
@ -721,11 +721,10 @@ void CodeGenFunction::EmitAttributedStmt(const AttributedStmt &S) {
|
|||
break;
|
||||
}
|
||||
}
|
||||
SaveAndRestore<bool> save_nomerge(InNoMergeAttributedStmt, nomerge);
|
||||
SaveAndRestore<bool> save_noinline(InNoInlineAttributedStmt, noinline);
|
||||
SaveAndRestore<bool> save_alwaysinline(InAlwaysInlineAttributedStmt,
|
||||
alwaysinline);
|
||||
SaveAndRestore<const CallExpr *> save_musttail(MustTailCall, musttail);
|
||||
SaveAndRestore save_nomerge(InNoMergeAttributedStmt, nomerge);
|
||||
SaveAndRestore save_noinline(InNoInlineAttributedStmt, noinline);
|
||||
SaveAndRestore save_alwaysinline(InAlwaysInlineAttributedStmt, alwaysinline);
|
||||
SaveAndRestore save_musttail(MustTailCall, musttail);
|
||||
EmitStmt(S.getSubStmt(), S.getAttrs());
|
||||
}
|
||||
|
||||
|
|
|
@ -169,7 +169,7 @@ const std::vector<Token> &MacroArgs::getPreExpArgument(unsigned Arg,
|
|||
std::vector<Token> &Result = PreExpArgTokens[Arg];
|
||||
if (!Result.empty()) return Result;
|
||||
|
||||
SaveAndRestore<bool> PreExpandingMacroArgs(PP.InMacroArgPreExpansion, true);
|
||||
SaveAndRestore PreExpandingMacroArgs(PP.InMacroArgPreExpansion, true);
|
||||
|
||||
const Token *AT = getUnexpArgument(Arg);
|
||||
unsigned NumToks = getArgLength(AT)+1; // Include the EOF.
|
||||
|
|
|
@ -491,8 +491,7 @@ void Preprocessor::SkipExcludedConditionalBlock(SourceLocation HashTokenLoc,
|
|||
// lookup pointer.
|
||||
assert(!SkippingExcludedConditionalBlock &&
|
||||
"calling SkipExcludedConditionalBlock recursively");
|
||||
llvm::SaveAndRestore<bool> SARSkipping(SkippingExcludedConditionalBlock,
|
||||
true);
|
||||
llvm::SaveAndRestore SARSkipping(SkippingExcludedConditionalBlock, true);
|
||||
|
||||
++NumSkipped;
|
||||
assert(!CurTokenLexer && CurPPLexer && "Lexing a macro, not a file?");
|
||||
|
|
|
@ -869,7 +869,7 @@ static bool EvaluateDirectiveSubExpr(PPValue &LHS, unsigned MinPrec,
|
|||
/// to "!defined(X)" return X in IfNDefMacro.
|
||||
Preprocessor::DirectiveEvalResult
|
||||
Preprocessor::EvaluateDirectiveExpression(IdentifierInfo *&IfNDefMacro) {
|
||||
SaveAndRestore<bool> PPDir(ParsingIfOrElifDirective, true);
|
||||
SaveAndRestore PPDir(ParsingIfOrElifDirective, true);
|
||||
// Save the current state of 'DisableMacroExpansion' and reset it to false. If
|
||||
// 'DisableMacroExpansion' is true, then we must be in a macro argument list
|
||||
// in which case a directive is undefined behavior. We want macros to be able
|
||||
|
|
|
@ -15584,8 +15584,8 @@ void Sema::CheckUnsequencedOperations(const Expr *E) {
|
|||
|
||||
void Sema::CheckCompletedExpr(Expr *E, SourceLocation CheckLoc,
|
||||
bool IsConstexpr) {
|
||||
llvm::SaveAndRestore<bool> ConstantContext(
|
||||
isConstantEvaluatedOverride, IsConstexpr || isa<ConstantExpr>(E));
|
||||
llvm::SaveAndRestore ConstantContext(isConstantEvaluatedOverride,
|
||||
IsConstexpr || isa<ConstantExpr>(E));
|
||||
CheckImplicitConversions(E, CheckLoc);
|
||||
if (!E->isInstantiationDependent())
|
||||
CheckUnsequencedOperations(E);
|
||||
|
|
|
@ -17697,7 +17697,7 @@ HandleImmediateInvocations(Sema &SemaRef,
|
|||
|
||||
/// Prevent sema calls during the tree transform from adding pointers that
|
||||
/// are already in the sets.
|
||||
llvm::SaveAndRestore<bool> DisableIITracking(
|
||||
llvm::SaveAndRestore DisableIITracking(
|
||||
SemaRef.RebuildingImmediateInvocation, true);
|
||||
|
||||
/// Prevent diagnostic during tree transfrom as they are duplicates
|
||||
|
|
|
@ -4257,8 +4257,7 @@ ASTReader::ASTReadResult ASTReader::ReadAST(StringRef FileName,
|
|||
SmallVectorImpl<ImportedSubmodule> *Imported) {
|
||||
llvm::TimeTraceScope scope("ReadAST", FileName);
|
||||
|
||||
llvm::SaveAndRestore<SourceLocation>
|
||||
SetCurImportLocRAII(CurrentImportLoc, ImportLoc);
|
||||
llvm::SaveAndRestore SetCurImportLocRAII(CurrentImportLoc, ImportLoc);
|
||||
llvm::SaveAndRestore<Optional<ModuleKind>> SetCurModuleKindRAII(
|
||||
CurrentDeserializingModuleKind, Type);
|
||||
|
||||
|
|
|
@ -3966,8 +3966,7 @@ void ASTReader::PassInterestingDeclsToConsumer() {
|
|||
|
||||
// Guard variable to avoid recursively redoing the process of passing
|
||||
// decls to consumer.
|
||||
SaveAndRestore<bool> GuardPassingDeclsToConsumer(PassingDeclsToConsumer,
|
||||
true);
|
||||
SaveAndRestore GuardPassingDeclsToConsumer(PassingDeclsToConsumer, true);
|
||||
|
||||
// Ensure that we've loaded all potentially-interesting declarations
|
||||
// that need to be eagerly loaded.
|
||||
|
|
|
@ -38,17 +38,17 @@ public:
|
|||
llvm::DenseSet<const VarDecl *> &S;
|
||||
|
||||
bool TraverseObjCAtFinallyStmt(ObjCAtFinallyStmt *S) {
|
||||
SaveAndRestore<bool> inFinally(inEH, true);
|
||||
SaveAndRestore inFinally(inEH, true);
|
||||
return ::RecursiveASTVisitor<EHCodeVisitor>::TraverseObjCAtFinallyStmt(S);
|
||||
}
|
||||
|
||||
bool TraverseObjCAtCatchStmt(ObjCAtCatchStmt *S) {
|
||||
SaveAndRestore<bool> inCatch(inEH, true);
|
||||
SaveAndRestore inCatch(inEH, true);
|
||||
return ::RecursiveASTVisitor<EHCodeVisitor>::TraverseObjCAtCatchStmt(S);
|
||||
}
|
||||
|
||||
bool TraverseCXXCatchStmt(CXXCatchStmt *S) {
|
||||
SaveAndRestore<bool> inCatch(inEH, true);
|
||||
SaveAndRestore inCatch(inEH, true);
|
||||
return TraverseStmt(S->getHandlerBlock());
|
||||
}
|
||||
|
||||
|
|
|
@ -391,9 +391,8 @@ void ExprEngine::processCallExit(ExplodedNode *CEBNode) {
|
|||
// result onto the work list.
|
||||
// CEENode -> Dst -> WorkList
|
||||
NodeBuilderContext Ctx(Engine, calleeCtx->getCallSiteBlock(), CEENode);
|
||||
SaveAndRestore<const NodeBuilderContext*> NBCSave(currBldrCtx,
|
||||
&Ctx);
|
||||
SaveAndRestore<unsigned> CBISave(currStmtIdx, calleeCtx->getIndex());
|
||||
SaveAndRestore<const NodeBuilderContext *> NBCSave(currBldrCtx, &Ctx);
|
||||
SaveAndRestore CBISave(currStmtIdx, calleeCtx->getIndex());
|
||||
|
||||
CallEventRef<> UpdatedCall = Call.cloneWithState(CEEState);
|
||||
|
||||
|
|
|
@ -63,14 +63,14 @@ public:
|
|||
// Avoid traversing the semantic expressions. They should be handled by
|
||||
// looking through the appropriate opaque expressions in order to build
|
||||
// a meaningful selection tree.
|
||||
llvm::SaveAndRestore<bool> LookThrough(LookThroughOpaqueValueExprs, true);
|
||||
llvm::SaveAndRestore LookThrough(LookThroughOpaqueValueExprs, true);
|
||||
return TraverseStmt(E->getSyntacticForm());
|
||||
}
|
||||
|
||||
bool TraverseOpaqueValueExpr(OpaqueValueExpr *E) {
|
||||
if (!LookThroughOpaqueValueExprs)
|
||||
return true;
|
||||
llvm::SaveAndRestore<bool> LookThrough(LookThroughOpaqueValueExprs, false);
|
||||
llvm::SaveAndRestore LookThrough(LookThroughOpaqueValueExprs, false);
|
||||
return TraverseStmt(E->getSourceExpr());
|
||||
}
|
||||
|
||||
|
|
|
@ -628,8 +628,8 @@ bool CursorVisitor::VisitDeclContext(DeclContext *DC) {
|
|||
|
||||
// FIXME: Eventually remove. This part of a hack to support proper
|
||||
// iteration over all Decls contained lexically within an ObjC container.
|
||||
SaveAndRestore<DeclContext::decl_iterator *> DI_saved(DI_current, &I);
|
||||
SaveAndRestore<DeclContext::decl_iterator> DE_saved(DE_current, E);
|
||||
SaveAndRestore DI_saved(DI_current, &I);
|
||||
SaveAndRestore DE_saved(DE_current, E);
|
||||
|
||||
for (; I != E; ++I) {
|
||||
Decl *D = *I;
|
||||
|
|
|
@ -1041,19 +1041,19 @@ SymbolAssignment *ScriptParser::readAssignment(StringRef tok) {
|
|||
const StringRef op = peek();
|
||||
if (op.startswith("=")) {
|
||||
// Support = followed by an expression without whitespace.
|
||||
SaveAndRestore<bool> saved(inExpr, true);
|
||||
SaveAndRestore saved(inExpr, true);
|
||||
cmd = readSymbolAssignment(tok);
|
||||
} else if ((op.size() == 2 && op[1] == '=' && strchr("*/+-&|", op[0])) ||
|
||||
op == "<<=" || op == ">>=") {
|
||||
cmd = readSymbolAssignment(tok);
|
||||
} else if (tok == "PROVIDE") {
|
||||
SaveAndRestore<bool> saved(inExpr, true);
|
||||
SaveAndRestore saved(inExpr, true);
|
||||
cmd = readProvideHidden(true, false);
|
||||
} else if (tok == "HIDDEN") {
|
||||
SaveAndRestore<bool> saved(inExpr, true);
|
||||
SaveAndRestore saved(inExpr, true);
|
||||
cmd = readProvideHidden(false, true);
|
||||
} else if (tok == "PROVIDE_HIDDEN") {
|
||||
SaveAndRestore<bool> saved(inExpr, true);
|
||||
SaveAndRestore saved(inExpr, true);
|
||||
cmd = readProvideHidden(true, true);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,11 @@ private:
|
|||
T OldValue;
|
||||
};
|
||||
|
||||
// User-defined CTAD guides.
|
||||
template <typename T> SaveAndRestore(T &) -> SaveAndRestore<T>;
|
||||
template <typename T> SaveAndRestore(T &, const T &) -> SaveAndRestore<T>;
|
||||
template <typename T> SaveAndRestore(T &, T &&) -> SaveAndRestore<T>;
|
||||
|
||||
} // namespace llvm
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1399,7 +1399,7 @@ AliasResult BasicAAResult::aliasPHI(const PHINode *PN, LocationSize PNSize,
|
|||
|
||||
// In the recursive alias queries below, we may compare values from two
|
||||
// different loop iterations.
|
||||
SaveAndRestore<bool> SavedMayBeCrossIteration(AAQI.MayBeCrossIteration, true);
|
||||
SaveAndRestore SavedMayBeCrossIteration(AAQI.MayBeCrossIteration, true);
|
||||
|
||||
AliasResult Alias = AAQI.AAR.alias(MemoryLocation(V1Srcs[0], PNSize),
|
||||
MemoryLocation(V2, V2Size), AAQI);
|
||||
|
|
|
@ -11170,7 +11170,7 @@ bool ScalarEvolution::isKnownPredicateViaSplitting(ICmpInst::Predicate Pred,
|
|||
|
||||
// Allowing arbitrary number of activations of isKnownPredicateViaSplitting on
|
||||
// the stack can result in exponential time complexity.
|
||||
SaveAndRestore<bool> Restore(ProvingSplitPredicate, true);
|
||||
SaveAndRestore Restore(ProvingSplitPredicate, true);
|
||||
|
||||
// If L >= 0 then I `ult` L <=> I >= 0 && I `slt` L
|
||||
//
|
||||
|
@ -11239,7 +11239,7 @@ ScalarEvolution::isLoopBackedgeGuardedByCond(const Loop *L,
|
|||
if (WalkingBEDominatingConds)
|
||||
return false;
|
||||
|
||||
SaveAndRestore<bool> ClearOnExit(WalkingBEDominatingConds, true);
|
||||
SaveAndRestore ClearOnExit(WalkingBEDominatingConds, true);
|
||||
|
||||
// See if we can exploit a trip count to prove the predicate.
|
||||
const auto &BETakenInfo = getBackedgeTakenInfo(L);
|
||||
|
|
|
@ -6072,7 +6072,7 @@ bool LLParser::parseFunctionBody(Function &Fn) {
|
|||
// within this function.
|
||||
if (PFS.resolveForwardRefBlockAddresses())
|
||||
return true;
|
||||
SaveAndRestore<PerFunctionState *> ScopeExit(BlockAddressPFS, &PFS);
|
||||
SaveAndRestore ScopeExit(BlockAddressPFS, &PFS);
|
||||
|
||||
// We need at least one basic block.
|
||||
if (Lex.getKind() == lltok::rbrace || Lex.getKind() == lltok::kw_uselistorder)
|
||||
|
|
|
@ -240,8 +240,8 @@ void CCState::analyzeMustTailForwardedRegisters(
|
|||
// Oftentimes calling conventions will not user register parameters for
|
||||
// variadic functions, so we need to assume we're not variadic so that we get
|
||||
// all the registers that might be used in a non-variadic call.
|
||||
SaveAndRestore<bool> SavedVarArg(IsVarArg, false);
|
||||
SaveAndRestore<bool> SavedMustTail(AnalyzingMustTailForwardedRegs, true);
|
||||
SaveAndRestore SavedVarArg(IsVarArg, false);
|
||||
SaveAndRestore SavedMustTail(AnalyzingMustTailForwardedRegs, true);
|
||||
|
||||
for (MVT RegVT : RegParmTypes) {
|
||||
SmallVector<MCPhysReg, 8> RemainingRegs;
|
||||
|
|
|
@ -1059,13 +1059,13 @@ bool TargetPassConfig::addCoreISelPasses() {
|
|||
// pass manager into two. GlobalISel with the fallback path disabled
|
||||
// and -run-pass seem to be unaffected. The majority of GlobalISel
|
||||
// testing uses -run-pass so this probably isn't too bad.
|
||||
SaveAndRestore<bool> SavedDebugifyIsSafe(DebugifyIsSafe);
|
||||
SaveAndRestore SavedDebugifyIsSafe(DebugifyIsSafe);
|
||||
if (Selector != SelectorType::GlobalISel || !isGlobalISelAbortEnabled())
|
||||
DebugifyIsSafe = false;
|
||||
|
||||
// Add instruction selector passes.
|
||||
if (Selector == SelectorType::GlobalISel) {
|
||||
SaveAndRestore<bool> SavedAddingMachinePasses(AddingMachinePasses, true);
|
||||
SaveAndRestore SavedAddingMachinePasses(AddingMachinePasses, true);
|
||||
if (addIRTranslator())
|
||||
return true;
|
||||
|
||||
|
|
|
@ -2494,7 +2494,7 @@ static void WriteAsOperandInternal(raw_ostream &Out, const Metadata *MD,
|
|||
|
||||
if (const MDNode *N = dyn_cast<MDNode>(MD)) {
|
||||
std::unique_ptr<SlotTracker> MachineStorage;
|
||||
SaveAndRestore<SlotTracker *> SARMachine(WriterCtx.Machine);
|
||||
SaveAndRestore SARMachine(WriterCtx.Machine);
|
||||
if (!WriterCtx.Machine) {
|
||||
MachineStorage = std::make_unique<SlotTracker>(WriterCtx.Context);
|
||||
WriterCtx.Machine = MachineStorage.get();
|
||||
|
|
|
@ -684,12 +684,12 @@ StringRef AsmLexer::LexUntilEndOfLine() {
|
|||
|
||||
size_t AsmLexer::peekTokens(MutableArrayRef<AsmToken> Buf,
|
||||
bool ShouldSkipSpace) {
|
||||
SaveAndRestore<const char *> SavedTokenStart(TokStart);
|
||||
SaveAndRestore<const char *> SavedCurPtr(CurPtr);
|
||||
SaveAndRestore<bool> SavedAtStartOfLine(IsAtStartOfLine);
|
||||
SaveAndRestore<bool> SavedAtStartOfStatement(IsAtStartOfStatement);
|
||||
SaveAndRestore<bool> SavedSkipSpace(SkipSpace, ShouldSkipSpace);
|
||||
SaveAndRestore<bool> SavedIsPeeking(IsPeeking, true);
|
||||
SaveAndRestore SavedTokenStart(TokStart);
|
||||
SaveAndRestore SavedCurPtr(CurPtr);
|
||||
SaveAndRestore SavedAtStartOfLine(IsAtStartOfLine);
|
||||
SaveAndRestore SavedAtStartOfStatement(IsAtStartOfStatement);
|
||||
SaveAndRestore SavedSkipSpace(SkipSpace, ShouldSkipSpace);
|
||||
SaveAndRestore SavedIsPeeking(IsPeeking, true);
|
||||
std::string SavedErr = getErr();
|
||||
SMLoc SavedErrLoc = getErrLoc();
|
||||
|
||||
|
|
|
@ -412,7 +412,7 @@ static void SignalHandler(int Sig) {
|
|||
}
|
||||
|
||||
static void InfoSignalHandler(int Sig) {
|
||||
SaveAndRestore<int> SaveErrnoDuringASignalHandler(errno);
|
||||
SaveAndRestore SaveErrnoDuringASignalHandler(errno);
|
||||
if (SignalHandlerFunctionType CurrentInfoFunction = InfoSignalFunction)
|
||||
CurrentInfoFunction();
|
||||
}
|
||||
|
|
|
@ -1266,9 +1266,9 @@ private:
|
|||
|
||||
SSANameState::SSANameState(Operation *op, const OpPrintingFlags &printerFlags)
|
||||
: printerFlags(printerFlags) {
|
||||
llvm::SaveAndRestore<unsigned> valueIDSaver(nextValueID);
|
||||
llvm::SaveAndRestore<unsigned> argumentIDSaver(nextArgumentID);
|
||||
llvm::SaveAndRestore<unsigned> conflictIDSaver(nextConflictID);
|
||||
llvm::SaveAndRestore valueIDSaver(nextValueID);
|
||||
llvm::SaveAndRestore argumentIDSaver(nextArgumentID);
|
||||
llvm::SaveAndRestore conflictIDSaver(nextConflictID);
|
||||
|
||||
// The naming context includes `nextValueID`, `nextArgumentID`,
|
||||
// `nextConflictID` and `usedNames` scoped HashTable. This information is
|
||||
|
|
|
@ -1389,8 +1389,7 @@ Value spirv::Deserializer::materializeSpecConstantOperation(
|
|||
// SpecConstantOperation in the module, we simply re-use the fake ID since the
|
||||
// previous Value assigned to it isn't visible in the current scope anyway.
|
||||
DenseMap<uint32_t, Value> newValueMap;
|
||||
llvm::SaveAndRestore<DenseMap<uint32_t, Value>> valueMapGuard(valueMap,
|
||||
newValueMap);
|
||||
llvm::SaveAndRestore valueMapGuard(valueMap, newValueMap);
|
||||
constexpr uint32_t fakeID = static_cast<uint32_t>(-3);
|
||||
|
||||
SmallVector<uint32_t, 4> enclosedOpResultTypeAndOperands;
|
||||
|
|
|
@ -62,7 +62,7 @@ private:
|
|||
if (range.empty())
|
||||
return;
|
||||
elementIndentStack.reserve(elementIndentStack.size() + 1);
|
||||
llvm::SaveAndRestore<bool> lastElement(elementIndentStack.back(), true);
|
||||
llvm::SaveAndRestore lastElement(elementIndentStack.back(), true);
|
||||
|
||||
printIndent();
|
||||
os << label << "`\n";
|
||||
|
|
|
@ -1293,7 +1293,7 @@ FailureOr<T *> Parser::parseUserConstraintOrRewriteDecl(
|
|||
StringRef anonymousNamePrefix, bool isInline) {
|
||||
SMRange loc = curToken.getLoc();
|
||||
consumeToken();
|
||||
llvm::SaveAndRestore<ParserContext> saveCtx(parserContext, declContext);
|
||||
llvm::SaveAndRestore saveCtx(parserContext, declContext);
|
||||
|
||||
// Parse the name of the decl.
|
||||
const ast::Name *name = nullptr;
|
||||
|
@ -1466,8 +1466,7 @@ FailureOr<ast::CompoundStmt *> Parser::parsePatternLambdaBody() {
|
|||
FailureOr<ast::Decl *> Parser::parsePatternDecl() {
|
||||
SMRange loc = curToken.getLoc();
|
||||
consumeToken(Token::kw_Pattern);
|
||||
llvm::SaveAndRestore<ParserContext> saveCtx(parserContext,
|
||||
ParserContext::PatternMatch);
|
||||
llvm::SaveAndRestore saveCtx(parserContext, ParserContext::PatternMatch);
|
||||
|
||||
// Check for an optional identifier for the pattern name.
|
||||
const ast::Name *name = nullptr;
|
||||
|
@ -2377,8 +2376,7 @@ FailureOr<ast::ReplaceStmt *> Parser::parseReplaceStmt() {
|
|||
return failure();
|
||||
|
||||
// The replacement portion of this statement is within a rewrite context.
|
||||
llvm::SaveAndRestore<ParserContext> saveCtx(parserContext,
|
||||
ParserContext::Rewrite);
|
||||
llvm::SaveAndRestore saveCtx(parserContext, ParserContext::Rewrite);
|
||||
|
||||
// Parse the replacement values.
|
||||
SmallVector<ast::Expr *> replValues;
|
||||
|
@ -2445,8 +2443,7 @@ FailureOr<ast::RewriteStmt *> Parser::parseRewriteStmt() {
|
|||
return emitError("expected `{` to start rewrite body");
|
||||
|
||||
// The rewrite body of this statement is within a rewrite context.
|
||||
llvm::SaveAndRestore<ParserContext> saveCtx(parserContext,
|
||||
ParserContext::Rewrite);
|
||||
llvm::SaveAndRestore saveCtx(parserContext, ParserContext::Rewrite);
|
||||
|
||||
FailureOr<ast::CompoundStmt *> rewriteBody = parseCompoundStmt();
|
||||
if (failed(rewriteBody))
|
||||
|
|
|
@ -1690,8 +1690,8 @@ ConversionPattern::matchAndRewrite(Operation *op,
|
|||
auto &rewriterImpl = dialectRewriter.getImpl();
|
||||
|
||||
// Track the current conversion pattern type converter in the rewriter.
|
||||
llvm::SaveAndRestore<TypeConverter *> currentConverterGuard(
|
||||
rewriterImpl.currentTypeConverter, getTypeConverter());
|
||||
llvm::SaveAndRestore currentConverterGuard(rewriterImpl.currentTypeConverter,
|
||||
getTypeConverter());
|
||||
|
||||
// Remap the operands of the operation.
|
||||
SmallVector<Value, 4> operands;
|
||||
|
|
|
@ -864,8 +864,8 @@ void DefFormat::genOptionalGroupPrinter(OptionalElement *el, FmtContext &ctx,
|
|||
}
|
||||
// Generate the printer for the contained elements.
|
||||
{
|
||||
llvm::SaveAndRestore<bool> shouldEmitSpaceFlag(shouldEmitSpace);
|
||||
llvm::SaveAndRestore<bool> lastWasPunctuationFlag(lastWasPunctuation);
|
||||
llvm::SaveAndRestore shouldEmitSpaceFlag(shouldEmitSpace);
|
||||
llvm::SaveAndRestore lastWasPunctuationFlag(lastWasPunctuation);
|
||||
for (FormatElement *element : el->getThenElements())
|
||||
genElementPrinter(element, ctx, os);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue