diff --git a/clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp b/clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp --- a/clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp +++ b/clang-tools-extra/clang-tidy/readability/SimplifyBooleanExprCheck.cpp @@ -567,7 +567,7 @@ if (Check->reportDeMorgan(Context, Op, BinaryOp, !IsProcessing, parent(), Parens) && !Check->areDiagsSelfContained()) { - llvm::SaveAndRestore RAII(IsProcessing, true); + llvm::SaveAndRestore RAII(IsProcessing, true); return Base::TraverseUnaryOperator(Op); } } diff --git a/clang/lib/ARCMigrate/TransGCAttrs.cpp b/clang/lib/ARCMigrate/TransGCAttrs.cpp --- a/clang/lib/ARCMigrate/TransGCAttrs.cpp +++ b/clang/lib/ARCMigrate/TransGCAttrs.cpp @@ -46,7 +46,7 @@ if (!D || D->isImplicit()) return true; - SaveAndRestore Save(FullyMigratable, isMigratable(D)); + SaveAndRestore Save(FullyMigratable, isMigratable(D)); if (ObjCPropertyDecl *PropD = dyn_cast(D)) { lookForAttribute(PropD, PropD->getTypeSourceInfo()); diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -7961,8 +7961,8 @@ 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 NotCheckingForUB( - Info.CheckingForUndefinedBehavior, false); + llvm::SaveAndRestore NotCheckingForUB(Info.CheckingForUndefinedBehavior, + false); const CompoundStmt *CS = E->getSubStmt(); if (CS->body_empty()) diff --git a/clang/lib/AST/TypePrinter.cpp b/clang/lib/AST/TypePrinter.cpp --- a/clang/lib/AST/TypePrinter.cpp +++ b/clang/lib/AST/TypePrinter.cpp @@ -195,7 +195,7 @@ return; } - SaveAndRestore PHVal(HasEmptyPlaceHolder, PlaceHolder.empty()); + SaveAndRestore PHVal(HasEmptyPlaceHolder, PlaceHolder.empty()); printBefore(T, Quals, OS); OS << PlaceHolder; @@ -319,7 +319,7 @@ if (Policy.SuppressSpecifiers && T->isSpecifierType()) return; - SaveAndRestore PrevPHIsEmpty(HasEmptyPlaceHolder); + SaveAndRestore PrevPHIsEmpty(HasEmptyPlaceHolder); // Print qualifiers as appropriate. @@ -396,7 +396,7 @@ void TypePrinter::printPointerBefore(const PointerType *T, raw_ostream &OS) { IncludeStrongLifetimeRAII Strong(Policy); - SaveAndRestore 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::printPointerAfter(const PointerType *T, raw_ostream &OS) { IncludeStrongLifetimeRAII Strong(Policy); - SaveAndRestore 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(T->getPointeeType())) @@ -417,14 +417,14 @@ void TypePrinter::printBlockPointerBefore(const BlockPointerType *T, raw_ostream &OS) { - SaveAndRestore NonEmptyPH(HasEmptyPlaceHolder, false); + SaveAndRestore NonEmptyPH(HasEmptyPlaceHolder, false); printBefore(T->getPointeeType(), OS); OS << '^'; } void TypePrinter::printBlockPointerAfter(const BlockPointerType *T, raw_ostream &OS) { - SaveAndRestore NonEmptyPH(HasEmptyPlaceHolder, false); + SaveAndRestore NonEmptyPH(HasEmptyPlaceHolder, false); printAfter(T->getPointeeType(), OS); } @@ -439,7 +439,7 @@ void TypePrinter::printLValueReferenceBefore(const LValueReferenceType *T, raw_ostream &OS) { IncludeStrongLifetimeRAII Strong(Policy); - SaveAndRestore 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::printLValueReferenceAfter(const LValueReferenceType *T, raw_ostream &OS) { IncludeStrongLifetimeRAII Strong(Policy); - SaveAndRestore 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::printRValueReferenceBefore(const RValueReferenceType *T, raw_ostream &OS) { IncludeStrongLifetimeRAII Strong(Policy); - SaveAndRestore 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::printRValueReferenceAfter(const RValueReferenceType *T, raw_ostream &OS) { IncludeStrongLifetimeRAII Strong(Policy); - SaveAndRestore 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::printMemberPointerBefore(const MemberPointerType *T, raw_ostream &OS) { IncludeStrongLifetimeRAII Strong(Policy); - SaveAndRestore 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::printMemberPointerAfter(const MemberPointerType *T, raw_ostream &OS) { IncludeStrongLifetimeRAII Strong(Policy); - SaveAndRestore 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(T->getPointeeType())) @@ -848,7 +848,7 @@ OS << '('; } else { // If needed for precedence reasons, wrap the inner part in grouping parens. - SaveAndRestore PrevPHIsEmpty(HasEmptyPlaceHolder, false); + SaveAndRestore PrevPHIsEmpty(HasEmptyPlaceHolder, false); printBefore(T->getReturnType(), OS); if (!PrevPHIsEmpty.get()) OS << '('; @@ -876,7 +876,7 @@ // If needed for precedence reasons, wrap the inner part in grouping parens. if (!HasEmptyPlaceHolder) OS << ')'; - SaveAndRestore NonEmptyPH(HasEmptyPlaceHolder, false); + SaveAndRestore NonEmptyPH(HasEmptyPlaceHolder, false); OS << '('; { @@ -1027,7 +1027,7 @@ void TypePrinter::printFunctionNoProtoBefore(const FunctionNoProtoType *T, raw_ostream &OS) { // If needed for precedence reasons, wrap the inner part in grouping parens. - SaveAndRestore PrevPHIsEmpty(HasEmptyPlaceHolder, false); + SaveAndRestore PrevPHIsEmpty(HasEmptyPlaceHolder, false); printBefore(T->getReturnType(), OS); if (!PrevPHIsEmpty.get()) OS << '('; @@ -1038,7 +1038,7 @@ // If needed for precedence reasons, wrap the inner part in grouping parens. if (!HasEmptyPlaceHolder) OS << ')'; - SaveAndRestore NonEmptyPH(HasEmptyPlaceHolder, false); + SaveAndRestore NonEmptyPH(HasEmptyPlaceHolder, false); OS << "()"; printFunctionAfter(T->getExtInfo(), OS); @@ -1676,7 +1676,7 @@ // If this is a calling convention attribute, don't print the implicit CC from // the modified type. - SaveAndRestore MaybeSuppressCC(InsideCCAttribute, T->isCallingConv()); + SaveAndRestore MaybeSuppressCC(InsideCCAttribute, T->isCallingConv()); printAfter(T->getModifiedType(), OS); diff --git a/clang/lib/Analysis/AnalysisDeclContext.cpp b/clang/lib/Analysis/AnalysisDeclContext.cpp --- a/clang/lib/Analysis/AnalysisDeclContext.cpp +++ b/clang/lib/Analysis/AnalysisDeclContext.cpp @@ -231,8 +231,7 @@ CFG *AnalysisDeclContext::getUnoptimizedCFG() { if (!builtCompleteCFG) { - SaveAndRestore 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 diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp --- a/clang/lib/Analysis/CFG.cpp +++ b/clang/lib/Analysis/CFG.cpp @@ -3073,7 +3073,7 @@ // Save local scope position because in case of condition variable ScopePos // won't be restored when traversing AST. - SaveAndRestore 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 *ElseBlock = Succ; if (Stmt *Else = I->getElse()) { - SaveAndRestore 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 @@ { Stmt *Then = I->getThen(); assert(Then); - SaveAndRestore sv(Succ); + SaveAndRestore sv(Succ); Block = nullptr; // If branch is not a compound statement create implicit scope @@ -3274,7 +3274,7 @@ // Save local scope position because in case of exception variable ScopePos // won't be restored when traversing AST. - SaveAndRestore save_scope_pos(ScopePos); + SaveAndRestore save_scope_pos(ScopePos); addStmt(ES->getBlock()); CFGBlock *SEHExceptBlock = Block; @@ -3364,13 +3364,13 @@ Succ = SEHTrySuccessor; // Save the current "__try" context. - SaveAndRestore 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 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 @@ // Save local scope position because in case of condition variable ScopePos // won't be restored when traversing AST. - SaveAndRestore 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 @@ // Save the current value for the break targets. // All breaks should go to the code following the loop. - SaveAndRestore save_break(BreakJumpTarget); + SaveAndRestore save_break(BreakJumpTarget); BreakJumpTarget = JumpTarget(LoopSuccessor, ScopePos); CFGBlock *BodyBlock = nullptr, *TransitionBlock = nullptr; @@ -3531,8 +3531,8 @@ assert(F->getBody()); // Save the current values for Block, Succ, continue and break targets. - SaveAndRestore save_Block(Block), save_Succ(Succ); - SaveAndRestore 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 @@ do { Expr *C = F->getCond(); - SaveAndRestore 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 @@ // 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 save_scope_pos(ScopePos); + SaveAndRestore save_scope_pos(ScopePos); ScopePos = LoopBeginScopePos; Block = createBlock(); return addStmt(I); @@ -3756,9 +3756,9 @@ // Now create the true branch. { // Save the current values for Succ, continue and break targets. - SaveAndRestore save_Block(Block), save_Succ(Succ); - SaveAndRestore 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 @@ // Save local scope position because in case of condition variable ScopePos // won't be restored when traversing AST. - SaveAndRestore 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 @@ assert(W->getBody()); // Save the current values for Block, Succ, continue and break targets. - SaveAndRestore save_Block(Block), save_Succ(Succ); - SaveAndRestore 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 @@ // Save local scope position because in case of exception variable ScopePos // won't be restored when traversing AST. - SaveAndRestore save_scope_pos(ScopePos); + SaveAndRestore save_scope_pos(ScopePos); if (CS->getCatchBody()) addStmt(CS->getCatchBody()); @@ -4104,7 +4104,7 @@ Succ = TrySuccessor; // Save the current "try" context. - SaveAndRestore SaveTry(TryTerminatedBlock, NewTryTerminatedBlock); + SaveAndRestore SaveTry(TryTerminatedBlock, NewTryTerminatedBlock); cfg->addTryDispatchBlock(TryTerminatedBlock); assert(Terminator->getTryBody() && "try must contain a non-NULL body"); @@ -4207,8 +4207,8 @@ assert(D->getBody()); // Save the current values for Block, Succ, and continue and break targets - SaveAndRestore save_Block(Block), save_Succ(Succ); - SaveAndRestore 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 @@ // Save local scope position because in case of condition variable ScopePos // won't be restored when traversing AST. - SaveAndRestore 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 @@ } else SwitchSuccessor = Succ; // Save the current "switch" context. - SaveAndRestore save_switch(SwitchTerminatedBlock), - save_default(DefaultCaseBlock); - SaveAndRestore 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 @@ // For pruning unreachable case statements, save the current state // for tracking the condition value. - SaveAndRestore 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 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 @@ Succ = TrySuccessor; // Save the current "try" context. - SaveAndRestore SaveTry(TryTerminatedBlock, NewTryTerminatedBlock); + SaveAndRestore SaveTry(TryTerminatedBlock, NewTryTerminatedBlock); cfg->addTryDispatchBlock(TryTerminatedBlock); assert(Terminator->getTryBlock() && "try must contain a non-NULL body"); @@ -4620,7 +4618,7 @@ // Save local scope position because in case of exception variable ScopePos // won't be restored when traversing AST. - SaveAndRestore 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 @@ // } // Save local scope position before the addition of the implicit variables. - SaveAndRestore 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 @@ // Save the current value for the break targets. // All breaks should go to the code following the loop. - SaveAndRestore save_break(BreakJumpTarget); + SaveAndRestore save_break(BreakJumpTarget); BreakJumpTarget = JumpTarget(LoopSuccessor, ScopePos); // The block for the __begin != __end expression. @@ -4730,8 +4728,8 @@ assert(S->getBody()); // Save the current values for Block, Succ, and continue targets. - SaveAndRestore save_Block(Block), save_Succ(Succ); - SaveAndRestore 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. diff --git a/clang/lib/CodeGen/CGCleanup.cpp b/clang/lib/CodeGen/CGCleanup.cpp --- a/clang/lib/CodeGen/CGCleanup.cpp +++ b/clang/lib/CodeGen/CGCleanup.cpp @@ -1016,8 +1016,7 @@ // throwing cleanups. For funclet EH personalities, the cleanupendpad models // program termination when cleanups throw. bool PushedTerminate = false; - SaveAndRestore RestoreCurrentFuncletPad( - CurrentFuncletPad); + SaveAndRestore RestoreCurrentFuncletPad(CurrentFuncletPad); llvm::CleanupPadInst *CPI = nullptr; const EHPersonality &Personality = EHPersonality::get(*this); diff --git a/clang/lib/CodeGen/CGException.cpp b/clang/lib/CodeGen/CGException.cpp --- a/clang/lib/CodeGen/CGException.cpp +++ b/clang/lib/CodeGen/CGException.cpp @@ -1223,8 +1223,7 @@ // 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 RestoreCurrentFuncletPad( - CurrentFuncletPad); + SaveAndRestore RestoreCurrentFuncletPad(CurrentFuncletPad); llvm::BasicBlock *WasmCatchStartBlock = nullptr; if (EHPersonality::get(*this).isWasmPersonality()) { auto *CatchSwitch = @@ -1257,8 +1256,7 @@ RunCleanupsScope CatchScope(*this); // Initialize the catch variable and set up the cleanups. - SaveAndRestore RestoreCurrentFuncletPad( - CurrentFuncletPad); + SaveAndRestore RestoreCurrentFuncletPad(CurrentFuncletPad); CGM.getCXXABI().emitBeginCatch(*this, C); // Emit the PGO counter increment. @@ -1582,8 +1580,7 @@ // 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 RestoreCurrentFuncletPad( - CurrentFuncletPad); + SaveAndRestore RestoreCurrentFuncletPad(CurrentFuncletPad); llvm::Value *ParentPad = CurrentFuncletPad; if (!ParentPad) ParentPad = llvm::ConstantTokenNone::get(CGM.getLLVMContext()); diff --git a/clang/lib/CodeGen/CGObjCRuntime.cpp b/clang/lib/CodeGen/CGObjCRuntime.cpp --- a/clang/lib/CodeGen/CGObjCRuntime.cpp +++ b/clang/lib/CodeGen/CGObjCRuntime.cpp @@ -230,7 +230,7 @@ CGF.EmitBlock(Handler.Block); CodeGenFunction::LexicalScope Cleanups(CGF, Handler.Body->getSourceRange()); - SaveAndRestore RevertAfterScope(CGF.CurrentFuncletPad); + SaveAndRestore RevertAfterScope(CGF.CurrentFuncletPad); if (useFunclets) { llvm::Instruction *CPICandidate = Handler.Block->getFirstNonPHI(); if (auto *CPI = dyn_cast_or_null(CPICandidate)) { diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp --- a/clang/lib/CodeGen/CGStmt.cpp +++ b/clang/lib/CodeGen/CGStmt.cpp @@ -721,11 +721,10 @@ break; } } - SaveAndRestore save_nomerge(InNoMergeAttributedStmt, nomerge); - SaveAndRestore save_noinline(InNoInlineAttributedStmt, noinline); - SaveAndRestore save_alwaysinline(InAlwaysInlineAttributedStmt, - alwaysinline); - SaveAndRestore 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()); } diff --git a/clang/lib/Lex/MacroArgs.cpp b/clang/lib/Lex/MacroArgs.cpp --- a/clang/lib/Lex/MacroArgs.cpp +++ b/clang/lib/Lex/MacroArgs.cpp @@ -169,7 +169,7 @@ std::vector &Result = PreExpArgTokens[Arg]; if (!Result.empty()) return Result; - SaveAndRestore PreExpandingMacroArgs(PP.InMacroArgPreExpansion, true); + SaveAndRestore PreExpandingMacroArgs(PP.InMacroArgPreExpansion, true); const Token *AT = getUnexpArgument(Arg); unsigned NumToks = getArgLength(AT)+1; // Include the EOF. diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp --- a/clang/lib/Lex/PPDirectives.cpp +++ b/clang/lib/Lex/PPDirectives.cpp @@ -491,8 +491,7 @@ // lookup pointer. assert(!SkippingExcludedConditionalBlock && "calling SkipExcludedConditionalBlock recursively"); - llvm::SaveAndRestore SARSkipping(SkippingExcludedConditionalBlock, - true); + llvm::SaveAndRestore SARSkipping(SkippingExcludedConditionalBlock, true); ++NumSkipped; assert(!CurTokenLexer && CurPPLexer && "Lexing a macro, not a file?"); diff --git a/clang/lib/Lex/PPExpressions.cpp b/clang/lib/Lex/PPExpressions.cpp --- a/clang/lib/Lex/PPExpressions.cpp +++ b/clang/lib/Lex/PPExpressions.cpp @@ -869,7 +869,7 @@ /// to "!defined(X)" return X in IfNDefMacro. Preprocessor::DirectiveEvalResult Preprocessor::EvaluateDirectiveExpression(IdentifierInfo *&IfNDefMacro) { - SaveAndRestore 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 diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp --- a/clang/lib/Sema/SemaChecking.cpp +++ b/clang/lib/Sema/SemaChecking.cpp @@ -15584,8 +15584,8 @@ void Sema::CheckCompletedExpr(Expr *E, SourceLocation CheckLoc, bool IsConstexpr) { - llvm::SaveAndRestore ConstantContext( - isConstantEvaluatedOverride, IsConstexpr || isa(E)); + llvm::SaveAndRestore ConstantContext(isConstantEvaluatedOverride, + IsConstexpr || isa(E)); CheckImplicitConversions(E, CheckLoc); if (!E->isInstantiationDependent()) CheckUnsequencedOperations(E); diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp --- a/clang/lib/Sema/SemaExpr.cpp +++ b/clang/lib/Sema/SemaExpr.cpp @@ -17697,7 +17697,7 @@ /// Prevent sema calls during the tree transform from adding pointers that /// are already in the sets. - llvm::SaveAndRestore DisableIITracking( + llvm::SaveAndRestore DisableIITracking( SemaRef.RebuildingImmediateInvocation, true); /// Prevent diagnostic during tree transfrom as they are duplicates diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp --- a/clang/lib/Serialization/ASTReader.cpp +++ b/clang/lib/Serialization/ASTReader.cpp @@ -4257,8 +4257,7 @@ SmallVectorImpl *Imported) { llvm::TimeTraceScope scope("ReadAST", FileName); - llvm::SaveAndRestore - SetCurImportLocRAII(CurrentImportLoc, ImportLoc); + llvm::SaveAndRestore SetCurImportLocRAII(CurrentImportLoc, ImportLoc); llvm::SaveAndRestore> SetCurModuleKindRAII( CurrentDeserializingModuleKind, Type); diff --git a/clang/lib/Serialization/ASTReaderDecl.cpp b/clang/lib/Serialization/ASTReaderDecl.cpp --- a/clang/lib/Serialization/ASTReaderDecl.cpp +++ b/clang/lib/Serialization/ASTReaderDecl.cpp @@ -3966,8 +3966,7 @@ // Guard variable to avoid recursively redoing the process of passing // decls to consumer. - SaveAndRestore GuardPassingDeclsToConsumer(PassingDeclsToConsumer, - true); + SaveAndRestore GuardPassingDeclsToConsumer(PassingDeclsToConsumer, true); // Ensure that we've loaded all potentially-interesting declarations // that need to be eagerly loaded. diff --git a/clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp --- a/clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp +++ b/clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp @@ -38,17 +38,17 @@ llvm::DenseSet &S; bool TraverseObjCAtFinallyStmt(ObjCAtFinallyStmt *S) { - SaveAndRestore inFinally(inEH, true); + SaveAndRestore inFinally(inEH, true); return ::RecursiveASTVisitor::TraverseObjCAtFinallyStmt(S); } bool TraverseObjCAtCatchStmt(ObjCAtCatchStmt *S) { - SaveAndRestore inCatch(inEH, true); + SaveAndRestore inCatch(inEH, true); return ::RecursiveASTVisitor::TraverseObjCAtCatchStmt(S); } bool TraverseCXXCatchStmt(CXXCatchStmt *S) { - SaveAndRestore inCatch(inEH, true); + SaveAndRestore inCatch(inEH, true); return TraverseStmt(S->getHandlerBlock()); } diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp --- a/clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp +++ b/clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp @@ -391,9 +391,8 @@ // result onto the work list. // CEENode -> Dst -> WorkList NodeBuilderContext Ctx(Engine, calleeCtx->getCallSiteBlock(), CEENode); - SaveAndRestore NBCSave(currBldrCtx, - &Ctx); - SaveAndRestore CBISave(currStmtIdx, calleeCtx->getIndex()); + SaveAndRestore NBCSave(currBldrCtx, &Ctx); + SaveAndRestore CBISave(currStmtIdx, calleeCtx->getIndex()); CallEventRef<> UpdatedCall = Call.cloneWithState(CEEState); diff --git a/clang/lib/Tooling/Refactoring/ASTSelection.cpp b/clang/lib/Tooling/Refactoring/ASTSelection.cpp --- a/clang/lib/Tooling/Refactoring/ASTSelection.cpp +++ b/clang/lib/Tooling/Refactoring/ASTSelection.cpp @@ -63,14 +63,14 @@ // 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 LookThrough(LookThroughOpaqueValueExprs, true); + llvm::SaveAndRestore LookThrough(LookThroughOpaqueValueExprs, true); return TraverseStmt(E->getSyntacticForm()); } bool TraverseOpaqueValueExpr(OpaqueValueExpr *E) { if (!LookThroughOpaqueValueExprs) return true; - llvm::SaveAndRestore LookThrough(LookThroughOpaqueValueExprs, false); + llvm::SaveAndRestore LookThrough(LookThroughOpaqueValueExprs, false); return TraverseStmt(E->getSourceExpr()); } diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp --- a/clang/tools/libclang/CIndex.cpp +++ b/clang/tools/libclang/CIndex.cpp @@ -628,8 +628,8 @@ // FIXME: Eventually remove. This part of a hack to support proper // iteration over all Decls contained lexically within an ObjC container. - SaveAndRestore DI_saved(DI_current, &I); - SaveAndRestore DE_saved(DE_current, E); + SaveAndRestore DI_saved(DI_current, &I); + SaveAndRestore DE_saved(DE_current, E); for (; I != E; ++I) { Decl *D = *I; diff --git a/lld/ELF/ScriptParser.cpp b/lld/ELF/ScriptParser.cpp --- a/lld/ELF/ScriptParser.cpp +++ b/lld/ELF/ScriptParser.cpp @@ -1041,19 +1041,19 @@ const StringRef op = peek(); if (op.startswith("=")) { // Support = followed by an expression without whitespace. - SaveAndRestore 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 saved(inExpr, true); + SaveAndRestore saved(inExpr, true); cmd = readProvideHidden(true, false); } else if (tok == "HIDDEN") { - SaveAndRestore saved(inExpr, true); + SaveAndRestore saved(inExpr, true); cmd = readProvideHidden(false, true); } else if (tok == "PROVIDE_HIDDEN") { - SaveAndRestore saved(inExpr, true); + SaveAndRestore saved(inExpr, true); cmd = readProvideHidden(true, true); } diff --git a/llvm/include/llvm/Support/SaveAndRestore.h b/llvm/include/llvm/Support/SaveAndRestore.h --- a/llvm/include/llvm/Support/SaveAndRestore.h +++ b/llvm/include/llvm/Support/SaveAndRestore.h @@ -34,6 +34,11 @@ T OldValue; }; +// User-defined CTAD guides. +template SaveAndRestore(T &) -> SaveAndRestore; +template SaveAndRestore(T &, const T &) -> SaveAndRestore; +template SaveAndRestore(T &, T &&) -> SaveAndRestore; + } // namespace llvm #endif diff --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp b/llvm/lib/Analysis/BasicAliasAnalysis.cpp --- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp +++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp @@ -1399,7 +1399,7 @@ // In the recursive alias queries below, we may compare values from two // different loop iterations. - SaveAndRestore SavedMayBeCrossIteration(AAQI.MayBeCrossIteration, true); + SaveAndRestore SavedMayBeCrossIteration(AAQI.MayBeCrossIteration, true); AliasResult Alias = AAQI.AAR.alias(MemoryLocation(V1Srcs[0], PNSize), MemoryLocation(V2, V2Size), AAQI); diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -11170,7 +11170,7 @@ // Allowing arbitrary number of activations of isKnownPredicateViaSplitting on // the stack can result in exponential time complexity. - SaveAndRestore Restore(ProvingSplitPredicate, true); + SaveAndRestore Restore(ProvingSplitPredicate, true); // If L >= 0 then I `ult` L <=> I >= 0 && I `slt` L // @@ -11239,7 +11239,7 @@ if (WalkingBEDominatingConds) return false; - SaveAndRestore ClearOnExit(WalkingBEDominatingConds, true); + SaveAndRestore ClearOnExit(WalkingBEDominatingConds, true); // See if we can exploit a trip count to prove the predicate. const auto &BETakenInfo = getBackedgeTakenInfo(L); diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp --- a/llvm/lib/AsmParser/LLParser.cpp +++ b/llvm/lib/AsmParser/LLParser.cpp @@ -6072,7 +6072,7 @@ // within this function. if (PFS.resolveForwardRefBlockAddresses()) return true; - SaveAndRestore ScopeExit(BlockAddressPFS, &PFS); + SaveAndRestore ScopeExit(BlockAddressPFS, &PFS); // We need at least one basic block. if (Lex.getKind() == lltok::rbrace || Lex.getKind() == lltok::kw_uselistorder) diff --git a/llvm/lib/CodeGen/CallingConvLower.cpp b/llvm/lib/CodeGen/CallingConvLower.cpp --- a/llvm/lib/CodeGen/CallingConvLower.cpp +++ b/llvm/lib/CodeGen/CallingConvLower.cpp @@ -240,8 +240,8 @@ // 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 SavedVarArg(IsVarArg, false); - SaveAndRestore SavedMustTail(AnalyzingMustTailForwardedRegs, true); + SaveAndRestore SavedVarArg(IsVarArg, false); + SaveAndRestore SavedMustTail(AnalyzingMustTailForwardedRegs, true); for (MVT RegVT : RegParmTypes) { SmallVector RemainingRegs; diff --git a/llvm/lib/CodeGen/TargetPassConfig.cpp b/llvm/lib/CodeGen/TargetPassConfig.cpp --- a/llvm/lib/CodeGen/TargetPassConfig.cpp +++ b/llvm/lib/CodeGen/TargetPassConfig.cpp @@ -1059,13 +1059,13 @@ // 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 SavedDebugifyIsSafe(DebugifyIsSafe); + SaveAndRestore SavedDebugifyIsSafe(DebugifyIsSafe); if (Selector != SelectorType::GlobalISel || !isGlobalISelAbortEnabled()) DebugifyIsSafe = false; // Add instruction selector passes. if (Selector == SelectorType::GlobalISel) { - SaveAndRestore SavedAddingMachinePasses(AddingMachinePasses, true); + SaveAndRestore SavedAddingMachinePasses(AddingMachinePasses, true); if (addIRTranslator()) return true; diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp --- a/llvm/lib/IR/AsmWriter.cpp +++ b/llvm/lib/IR/AsmWriter.cpp @@ -2494,7 +2494,7 @@ if (const MDNode *N = dyn_cast(MD)) { std::unique_ptr MachineStorage; - SaveAndRestore SARMachine(WriterCtx.Machine); + SaveAndRestore SARMachine(WriterCtx.Machine); if (!WriterCtx.Machine) { MachineStorage = std::make_unique(WriterCtx.Context); WriterCtx.Machine = MachineStorage.get(); diff --git a/llvm/lib/MC/MCParser/AsmLexer.cpp b/llvm/lib/MC/MCParser/AsmLexer.cpp --- a/llvm/lib/MC/MCParser/AsmLexer.cpp +++ b/llvm/lib/MC/MCParser/AsmLexer.cpp @@ -684,12 +684,12 @@ size_t AsmLexer::peekTokens(MutableArrayRef Buf, bool ShouldSkipSpace) { - SaveAndRestore SavedTokenStart(TokStart); - SaveAndRestore SavedCurPtr(CurPtr); - SaveAndRestore SavedAtStartOfLine(IsAtStartOfLine); - SaveAndRestore SavedAtStartOfStatement(IsAtStartOfStatement); - SaveAndRestore SavedSkipSpace(SkipSpace, ShouldSkipSpace); - SaveAndRestore 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(); diff --git a/llvm/lib/Support/Unix/Signals.inc b/llvm/lib/Support/Unix/Signals.inc --- a/llvm/lib/Support/Unix/Signals.inc +++ b/llvm/lib/Support/Unix/Signals.inc @@ -412,7 +412,7 @@ } static void InfoSignalHandler(int Sig) { - SaveAndRestore SaveErrnoDuringASignalHandler(errno); + SaveAndRestore SaveErrnoDuringASignalHandler(errno); if (SignalHandlerFunctionType CurrentInfoFunction = InfoSignalFunction) CurrentInfoFunction(); } diff --git a/mlir/lib/IR/AsmPrinter.cpp b/mlir/lib/IR/AsmPrinter.cpp --- a/mlir/lib/IR/AsmPrinter.cpp +++ b/mlir/lib/IR/AsmPrinter.cpp @@ -1266,9 +1266,9 @@ SSANameState::SSANameState(Operation *op, const OpPrintingFlags &printerFlags) : printerFlags(printerFlags) { - llvm::SaveAndRestore valueIDSaver(nextValueID); - llvm::SaveAndRestore argumentIDSaver(nextArgumentID); - llvm::SaveAndRestore 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 diff --git a/mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp b/mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp --- a/mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp +++ b/mlir/lib/Target/SPIRV/Deserialization/Deserializer.cpp @@ -1389,8 +1389,7 @@ // 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 newValueMap; - llvm::SaveAndRestore> valueMapGuard(valueMap, - newValueMap); + llvm::SaveAndRestore valueMapGuard(valueMap, newValueMap); constexpr uint32_t fakeID = static_cast(-3); SmallVector enclosedOpResultTypeAndOperands; diff --git a/mlir/lib/Tools/PDLL/AST/NodePrinter.cpp b/mlir/lib/Tools/PDLL/AST/NodePrinter.cpp --- a/mlir/lib/Tools/PDLL/AST/NodePrinter.cpp +++ b/mlir/lib/Tools/PDLL/AST/NodePrinter.cpp @@ -62,7 +62,7 @@ if (range.empty()) return; elementIndentStack.reserve(elementIndentStack.size() + 1); - llvm::SaveAndRestore lastElement(elementIndentStack.back(), true); + llvm::SaveAndRestore lastElement(elementIndentStack.back(), true); printIndent(); os << label << "`\n"; diff --git a/mlir/lib/Tools/PDLL/Parser/Parser.cpp b/mlir/lib/Tools/PDLL/Parser/Parser.cpp --- a/mlir/lib/Tools/PDLL/Parser/Parser.cpp +++ b/mlir/lib/Tools/PDLL/Parser/Parser.cpp @@ -1293,7 +1293,7 @@ StringRef anonymousNamePrefix, bool isInline) { SMRange loc = curToken.getLoc(); consumeToken(); - llvm::SaveAndRestore saveCtx(parserContext, declContext); + llvm::SaveAndRestore saveCtx(parserContext, declContext); // Parse the name of the decl. const ast::Name *name = nullptr; @@ -1466,8 +1466,7 @@ FailureOr Parser::parsePatternDecl() { SMRange loc = curToken.getLoc(); consumeToken(Token::kw_Pattern); - llvm::SaveAndRestore 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 @@ return failure(); // The replacement portion of this statement is within a rewrite context. - llvm::SaveAndRestore saveCtx(parserContext, - ParserContext::Rewrite); + llvm::SaveAndRestore saveCtx(parserContext, ParserContext::Rewrite); // Parse the replacement values. SmallVector replValues; @@ -2445,8 +2443,7 @@ return emitError("expected `{` to start rewrite body"); // The rewrite body of this statement is within a rewrite context. - llvm::SaveAndRestore saveCtx(parserContext, - ParserContext::Rewrite); + llvm::SaveAndRestore saveCtx(parserContext, ParserContext::Rewrite); FailureOr rewriteBody = parseCompoundStmt(); if (failed(rewriteBody)) diff --git a/mlir/lib/Transforms/Utils/DialectConversion.cpp b/mlir/lib/Transforms/Utils/DialectConversion.cpp --- a/mlir/lib/Transforms/Utils/DialectConversion.cpp +++ b/mlir/lib/Transforms/Utils/DialectConversion.cpp @@ -1690,8 +1690,8 @@ auto &rewriterImpl = dialectRewriter.getImpl(); // Track the current conversion pattern type converter in the rewriter. - llvm::SaveAndRestore currentConverterGuard( - rewriterImpl.currentTypeConverter, getTypeConverter()); + llvm::SaveAndRestore currentConverterGuard(rewriterImpl.currentTypeConverter, + getTypeConverter()); // Remap the operands of the operation. SmallVector operands; diff --git a/mlir/tools/mlir-tblgen/AttrOrTypeFormatGen.cpp b/mlir/tools/mlir-tblgen/AttrOrTypeFormatGen.cpp --- a/mlir/tools/mlir-tblgen/AttrOrTypeFormatGen.cpp +++ b/mlir/tools/mlir-tblgen/AttrOrTypeFormatGen.cpp @@ -864,8 +864,8 @@ } // Generate the printer for the contained elements. { - llvm::SaveAndRestore shouldEmitSpaceFlag(shouldEmitSpace); - llvm::SaveAndRestore lastWasPunctuationFlag(lastWasPunctuation); + llvm::SaveAndRestore shouldEmitSpaceFlag(shouldEmitSpace); + llvm::SaveAndRestore lastWasPunctuationFlag(lastWasPunctuation); for (FormatElement *element : el->getThenElements()) genElementPrinter(element, ctx, os); }