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);
}
}
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());
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())
return;
}
- SaveAndRestore<bool> PHVal(HasEmptyPlaceHolder, PlaceHolder.empty());
+ SaveAndRestore PHVal(HasEmptyPlaceHolder, PlaceHolder.empty());
printBefore(T, Quals, OS);
OS << PlaceHolder;
if (Policy.SuppressSpecifiers && T->isSpecifierType())
return;
- SaveAndRestore<bool> PrevPHIsEmpty(HasEmptyPlaceHolder);
+ SaveAndRestore PrevPHIsEmpty(HasEmptyPlaceHolder);
// Print qualifiers as appropriate.
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.
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()))
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);
}
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.
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.
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.
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.
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.
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()))
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 << '(';
// 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 << '(';
{
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 << '(';
// 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);
// 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);
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
// 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())
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.
{
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
// 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;
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");
// 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.
// 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;
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
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.
// 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);
// 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
// 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.
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.
// 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());
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");
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
// 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())
} 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
// 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.
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");
// 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.
// }
// 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())
// 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.
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.
// 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);
// 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 =
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.
// 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());
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)) {
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());
}
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.
// 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?");
/// 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
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);
/// 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
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);
// 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.
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());
}
// 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);
// 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());
}
// 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;
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);
}
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
// 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);
// 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
//
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);
// 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)
// 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;
// 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;
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();
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();
}
static void InfoSignalHandler(int Sig) {
- SaveAndRestore<int> SaveErrnoDuringASignalHandler(errno);
+ SaveAndRestore SaveErrnoDuringASignalHandler(errno);
if (SignalHandlerFunctionType CurrentInfoFunction = InfoSignalFunction)
CurrentInfoFunction();
}
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
// 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;
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";
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;
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;
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;
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))
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;
}
// 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);
}