@@ -12103,25 +12103,31 @@ class Sema final : public SemaBase {
1210312103 }
1210412104 };
1210512105
12106+ class DisableTypoCorrectionRAII {
12107+ Sema &SemaRef;
12108+ bool PrevDisableTypoCorrection;
12109+
12110+ public:
12111+ explicit DisableTypoCorrectionRAII(Sema &SemaRef)
12112+ : SemaRef(SemaRef), PrevDisableTypoCorrection(std::exchange(
12113+ SemaRef.DisableTypoCorrection, true)) {}
12114+
12115+ ~DisableTypoCorrectionRAII() {
12116+ SemaRef.DisableTypoCorrection = PrevDisableTypoCorrection;
12117+ }
12118+ };
12119+
1210612120 /// RAII class used to indicate that we are performing provisional
1210712121 /// semantic analysis to determine the validity of a construct, so
1210812122 /// typo-correction and diagnostics in the immediate context (not within
1210912123 /// implicitly-instantiated templates) should be suppressed.
12110- class TentativeAnalysisScope {
12111- Sema &SemaRef;
12124+ class TentativeAnalysisScope : public DisableTypoCorrectionRAII {
1211212125 // FIXME: Using a SFINAETrap for this is a hack.
1211312126 SFINAETrap Trap;
12114- bool PrevDisableTypoCorrection;
1211512127
1211612128 public:
1211712129 explicit TentativeAnalysisScope(Sema &SemaRef)
12118- : SemaRef(SemaRef), Trap(SemaRef, true),
12119- PrevDisableTypoCorrection(SemaRef.DisableTypoCorrection) {
12120- SemaRef.DisableTypoCorrection = true;
12121- }
12122- ~TentativeAnalysisScope() {
12123- SemaRef.DisableTypoCorrection = PrevDisableTypoCorrection;
12124- }
12130+ : DisableTypoCorrectionRAII(SemaRef), Trap(SemaRef, true) {}
1212512131 };
1212612132
1212712133 /// For each declaration that involved template argument deduction, the
0 commit comments