clang 24.0.0git
clang::PTUMutationActions Class Reference

#include "/work/as-worker-4/publish-doxygen-docs/llvm-project/clang/lib/Interpreter/ErrorRecovery.h"

Inheritance diagram for clang::PTUMutationActions:
[legend]

Public Member Functions

 PTUMutationActions (IncrementalStateTracker &Tracker, Sema &S, CodeGenerator *CodeGen=nullptr)
Sema & getSema () const
CodeGenerator * getCodeGen () const
uint32_t DeclNeedingTracking (DeclShape S, const Decl *D)
 This is called when a decl is created or seen for the first time.
uint32_t confirmMutation (const Decl *D, DeclShape S, uint32_t FlaggedKinds)
 The single place to check whether a kind has actually changed.
void trackForSweep (const Decl *D, uint32_t Kinds)
 Start tracking D for mutation kinds that need verification.
void untrackIfClosed (const Decl *D, DeclShape S, uint32_t Confirmed)
 Stop tracking Decl D when it no longer needs verification.
void syncSweepTracking (const Decl *D, DeclShape S, uint32_t Kinds, bool IsNew)
bool shouldRecurseInto (const Decl *D)
 These are the places where the incremental state of a declaration is registered based on its DeclKind.
void VisitDeclContext (const DeclContext *DC)
void VisitCXXRecordDecl (const CXXRecordDecl *RD)
void VisitFunctionDecl (const FunctionDecl *FD)
void VisitVarDecl (const VarDecl *VD)
void VisitEnumDecl (const EnumDecl *ED)
void VisitRedeclarableTemplateDecl (const RedeclarableTemplateDecl *RT)
void CommitDecl (const Decl *D, MutationRecord *Rec)
void CommitPTU (TranslationUnitDecl *MostRecentTU)
void RestorePTU (TranslationUnitDecl *MostRecentTU)
Public Member Functions inherited from clang::declvisitor::Base< llvm::make_const_ptr, PTUMutationActions, void >
void Visit (PTR(Decl) D)
void VisitDecl (PTR(Decl) D)

Detailed Description

Definition at line 514 of file ErrorRecovery.h.

Constructor & Destructor Documentation

◆ PTUMutationActions()

clang::PTUMutationActions::PTUMutationActions ( IncrementalStateTracker & Tracker,
Sema & S,
CodeGenerator * CodeGen = nullptr )
inlineexplicit

Definition at line 531 of file ErrorRecovery.h.

Member Function Documentation

◆ CommitDecl()

◆ CommitPTU()

◆ confirmMutation()

uint32_t clang::PTUMutationActions::confirmMutation ( const Decl * D,
DeclShape S,
uint32_t FlaggedKinds )

The single place to check whether a kind has actually changed.

This handles both listener-less kinds and listener-unconfirmed mutations (currently SpecInfo and MemberSpecInfo). Mutations can be detected by both SweepTracker and the listener re-check. SweepTracker tracks hidden and listener-unconfirmed mutations in case the listener misses them. If the listener catches a mutation, it is removed from SweepTracker; see PTUStateInfo::verifyMutations. both use this functionality to verify mutation kind.

This check uses the decl shape and mutation kind to determine whether the decl has changed from its previous state.

Similarly, if a new hidden or listener-unconfirmed mutation is introduced in DeclNeedingTracking, and we need to determine whether it changed the previous state, the corresponding logic should be added here too when the kind is categorized as a hidden mutation from the listener.

Definition at line 401 of file ErrorRecovery.cpp.

References clang::cast(), clang::differsFromLast(), clang::Footprint(), and uint32_t.

Referenced by clang::SweepTracker::sweep(), and clang::PTUStateInfo::verifyMutations().

◆ DeclNeedingTracking()

uint32_t clang::PTUMutationActions::DeclNeedingTracking ( DeclShape S,
const Decl * D )

This is called when a decl is created or seen for the first time.

It also checks whether the decl is still in a mutation-sensitive state, meaning that a later PTU can modify it. Because of this, we need to track its state. This function provides a single place to decide whether a decl needs to be committed or not. It is called from CommitDecl to determine whether a new decl needs to be tracked.

This requires Decl to determine which mutation kinds apply to the shape and whether they need to be tracked. In the future, if a new mutation site is found for a shape, it should be added here along with the logic to determine whether the decl is still in an open, modifiable state.

Definition at line 326 of file ErrorRecovery.cpp.

References clang::cast(), and uint32_t.

Referenced by CommitDecl(), and untrackIfClosed().

◆ getCodeGen()

CodeGenerator * clang::PTUMutationActions::getCodeGen ( ) const
inline

Definition at line 538 of file ErrorRecovery.h.

◆ getSema()

Sema & clang::PTUMutationActions::getSema ( ) const
inline

Definition at line 537 of file ErrorRecovery.h.

◆ RestorePTU()

◆ shouldRecurseInto()

bool clang::PTUMutationActions::shouldRecurseInto ( const Decl * D)

These are the places where the incremental state of a declaration is registered based on its DeclKind.


PTUMutationActions::commit ///////////////////////

For a declaration created in the current PTU, its state is committed to the tracker. For an existing declaration modified in the current PTU, its previous state is recorded so it can be restored on undo.

The idea is to keep state tracking limited to a small set of known mutation sites for each DeclKind, instead of tracking changes everywhere in Clang.

Currently, this covers Class, Function, Enum, Template, etc. Each DeclKind is associated with the mutation kinds that need to be tracked.

When adding a new mutation site, it should be handled according to the corresponding DeclKind and mutation kind.

Definition at line 585 of file ErrorRecovery.cpp.

References clang::isa().

Referenced by CommitPTU(), and VisitDeclContext().

◆ syncSweepTracking()

void clang::PTUMutationActions::syncSweepTracking ( const Decl * D,
DeclShape S,
uint32_t Kinds,
bool IsNew )

Definition at line 520 of file ErrorRecovery.cpp.

References trackForSweep(), uint32_t, and untrackIfClosed().

◆ trackForSweep()

void clang::PTUMutationActions::trackForSweep ( const Decl * D,
uint32_t Kinds )

Start tracking D for mutation kinds that need verification.

Called when a new mutation is committed or an undone mutation is restored. we apply this for listener unconfirmed cases.

Definition at line 500 of file ErrorRecovery.cpp.

References clang::KindsNeedingVerification, and uint32_t.

Referenced by syncSweepTracking().

◆ untrackIfClosed()

void clang::PTUMutationActions::untrackIfClosed ( const Decl * D,
DeclShape S,
uint32_t Confirmed )

Stop tracking Decl D when it no longer needs verification.

Re-check DeclNeedingTracking to see if a later PTU can still update D.

Definition at line 507 of file ErrorRecovery.cpp.

References DeclNeedingTracking(), clang::KindsNeedingVerification, and uint32_t.

Referenced by syncSweepTracking(), and clang::PTUStateInfo::verifyMutations().

◆ VisitCXXRecordDecl()

void clang::PTUMutationActions::VisitCXXRecordDecl ( const CXXRecordDecl * RD)
inline

Definition at line 554 of file ErrorRecovery.h.

◆ VisitDeclContext()

void clang::PTUMutationActions::VisitDeclContext ( const DeclContext * DC)

◆ VisitEnumDecl()

void clang::PTUMutationActions::VisitEnumDecl ( const EnumDecl * ED)
inline

Definition at line 557 of file ErrorRecovery.h.

◆ VisitFunctionDecl()

void clang::PTUMutationActions::VisitFunctionDecl ( const FunctionDecl * FD)
inline

Definition at line 555 of file ErrorRecovery.h.

◆ VisitRedeclarableTemplateDecl()

void clang::PTUMutationActions::VisitRedeclarableTemplateDecl ( const RedeclarableTemplateDecl * RT)
inline

Definition at line 558 of file ErrorRecovery.h.

◆ VisitVarDecl()

void clang::PTUMutationActions::VisitVarDecl ( const VarDecl * VD)
inline

Definition at line 556 of file ErrorRecovery.h.


The documentation for this class was generated from the following files: