[clang] [Clang-Repl] Introduce Error Recovery for Clang-Repl (PR #247062)

via cfe-commits cfe-commits at lists.llvm.org
Sun Nov 29 22:07:22 PST 2026


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions h,cpp -- clang/lib/Interpreter/ErrorRecovery.cpp clang/lib/Interpreter/ErrorRecovery.h clang/include/clang/AST/DeclBase.h clang/include/clang/AST/DeclTemplate.h clang/lib/Interpreter/IncrementalAction.cpp clang/lib/Interpreter/IncrementalAction.h clang/lib/Interpreter/IncrementalParser.cpp clang/lib/Interpreter/IncrementalParser.h --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/clang/lib/Interpreter/IncrementalParser.cpp b/clang/lib/Interpreter/IncrementalParser.cpp
index fdb741be8..43b63e1f8 100644
--- a/clang/lib/Interpreter/IncrementalParser.cpp
+++ b/clang/lib/Interpreter/IncrementalParser.cpp
@@ -10,8 +10,8 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "ErrorRecovery.h"
 #include "IncrementalParser.h"
+#include "ErrorRecovery.h"
 #include "IncrementalAction.h"
 
 #include "clang/AST/ASTContext.h"
@@ -44,8 +44,8 @@ IncrementalParser::IncrementalParser(CompilerInstance &Instance,
   llvm::ErrorAsOutParameter EAO(&Err);
 
   Tracker = std::make_unique<IncrementalStateTracker>(S.getASTContext());
-  MutationActions = std::make_unique<PTUMutationActions>(
-      *Tracker, S, Act->getCodeGen());
+  MutationActions =
+      std::make_unique<PTUMutationActions>(*Tracker, S, Act->getCodeGen());
   MutationRecorder = std::make_unique<PTUMutationRecorder>(*Tracker);
   S.getASTContext().setASTMutationListener(MutationRecorder.get());
 
@@ -209,7 +209,8 @@ void IncrementalParser::withdrawMostRecentTU(
 //   Sema &S;
 //   TranslationUnitDecl *DiscardedTU;
 
-//   /// The newest declaration of whatever D redeclares that still lives outside
+//   /// The newest declaration of whatever D redeclares that still lives
+//   outside
 //   /// the DiscardedTU, or null if DiscardedTU introduced the name.
 //   NamedDecl *findSurvivor(NamedDecl *D) const {
 //     for (Decl *Prev = D->getPreviousDecl(); Prev;
@@ -229,7 +230,8 @@ void IncrementalParser::withdrawMostRecentTU(
 //     // First -> ... -> Survivor.
 //     Latest->getFirstDecl()->RedeclLink.setLatest(Survivor);
 
-//     // The chain is circular: a withdrawn declaration still linked into it can
+//     // The chain is circular: a withdrawn declaration still linked into it
+//     can
 //     // never walk back around to itself, so redecls() on one would not
 //     // terminate. Give each withdrawn declaration a chain of its own.
 //     for (DeclT *Dead = Latest; Dead != Survivor;) {
@@ -245,7 +247,8 @@ void IncrementalParser::withdrawMostRecentTU(
 //     if (D->getDeclName().isEmpty())
 //       return;
 
-//     if (D->getDeclName().isIdentifier() && D->getDeclName().getFETokenInfo() &&
+//     if (D->getDeclName().isIdentifier() && D->getDeclName().getFETokenInfo()
+//     &&
 //         !D->getLangOpts().ObjC && !D->getLangOpts().CPlusPlus)
 //       S.IdResolver.RemoveDecl(D);
 
@@ -280,8 +283,8 @@ void IncrementalParser::withdrawMostRecentTU(
 
 //   /// Remove ND from its context and the lookup tables, and make the
 //   /// declaration it redeclares visible again. Called by VisitRedeclarable()
-//   /// before it restores the redeclaration chain, which hides that declaration.
-//   void VisitNamedDecl(NamedDecl *ND) {
+//   /// before it restores the redeclaration chain, which hides that
+//   declaration. void VisitNamedDecl(NamedDecl *ND) {
 //     // The templated decl of a template is not a member of its context: the
 //     // template is.
 //     DeclContext *DC = ND->getLexicalDeclContext();
@@ -290,14 +293,16 @@ void IncrementalParser::withdrawMostRecentTU(
 //     NamedDecl *Prev = findSurvivor(ND);
 //     DC->removeDecl(ND);
 //     removeFromLookups(ND);
-//     // Like removeDecl(), use the semantic context: the out-of-line definition
+//     // Like removeDecl(), use the semantic context: the out-of-line
+//     definition
 //     // of a member is in DC, but it was removed from the lookup table of its
 //     // class or namespace.
 //     if (Prev)
 //       Prev->getDeclContext()->makeDeclVisibleInContext(Prev);
 //   }
 
-//   /// Remove D like VisitNamedDecl() and restore its redeclaration chain to the
+//   /// Remove D like VisitNamedDecl() and restore its redeclaration chain to
+//   the
 //   /// previous state. Returns the surviving previous declaration, if any.
 //   /// DeclVisitor doesn't dispatch to it: Redeclarable is not a Decl class.
 //   template <typename DeclT>
@@ -311,13 +316,14 @@ void IncrementalParser::withdrawMostRecentTU(
 //   }
 
 //   void VisitFunctionDecl(FunctionDecl *D) { VisitRedeclarable(D); }
-//   void VisitNamespaceAliasDecl(NamespaceAliasDecl *D) { VisitRedeclarable(D); }
-//   void VisitTypedefNameDecl(TypedefNameDecl *D) { VisitRedeclarable(D); }
+//   void VisitNamespaceAliasDecl(NamespaceAliasDecl *D) { VisitRedeclarable(D);
+//   } void VisitTypedefNameDecl(TypedefNameDecl *D) { VisitRedeclarable(D); }
 //   void VisitUsingShadowDecl(UsingShadowDecl *D) { VisitRedeclarable(D); }
 //   void VisitVarDecl(VarDecl *D) { VisitRedeclarable(D); }
 
 //   void VisitTagDecl(TagDecl *D) {
-//     // Some members of a definition are visible outside of it: the enumerators
+//     // Some members of a definition are visible outside of it: the
+//     enumerators
 //     // of an unscoped enumeration, and in C the tags and enumerators declared
 //     // in a structure or union.
 //     if (D->isThisDeclarationADefinition())
@@ -350,7 +356,8 @@ void IncrementalParser::withdrawMostRecentTU(
 //     VisitRedeclarable(D);
 //   }
 
-//   void VisitTranslationUnitDecl(TranslationUnitDecl *D) { VisitDeclContext(D); }
+//   void VisitTranslationUnitDecl(TranslationUnitDecl *D) {
+//   VisitDeclContext(D); }
 // };
 
 void IncrementalParser::CleanUpPTU(TranslationUnitDecl *MostRecentTU) {
diff --git a/clang/lib/Interpreter/IncrementalParser.h b/clang/lib/Interpreter/IncrementalParser.h
index 79decf7d8..48f53492e 100644
--- a/clang/lib/Interpreter/IncrementalParser.h
+++ b/clang/lib/Interpreter/IncrementalParser.h
@@ -32,7 +32,6 @@ struct PartialTranslationUnit;
 class PTUMutationActions;
 class PTUMutationRecorder;
 
-
 /// Provides support for incremental compilation. Keeps track of the state
 /// changes between the subsequent incremental input.
 ///

``````````

</details>


https://github.com/llvm/llvm-project/pull/247062


More information about the cfe-commits mailing list