clang 20.0.0git
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | List of all members
clang::StructuralEquivalenceContext Struct Reference

#include "clang/AST/ASTStructuralEquivalence.h"

Public Types

using NonEquivalentDeclSet = llvm::DenseSet< std::tuple< Decl *, Decl *, int > >
 Store declaration pairs already found to be non-equivalent.
 

Public Member Functions

 StructuralEquivalenceContext (ASTContext &FromCtx, ASTContext &ToCtx, NonEquivalentDeclSet &NonEquivalentDecls, StructuralEquivalenceKind EqKind, bool StrictTypeSpelling=false, bool Complain=true, bool ErrorOnTagTypeMismatch=false, bool IgnoreTemplateParmDepth=false)
 
DiagnosticBuilder Diag1 (SourceLocation Loc, unsigned DiagID)
 
DiagnosticBuilder Diag2 (SourceLocation Loc, unsigned DiagID)
 
bool IsEquivalent (Decl *D1, Decl *D2)
 Determine whether the two declarations are structurally equivalent.
 
bool IsEquivalent (QualType T1, QualType T2)
 Determine whether the two types are structurally equivalent.
 
bool IsEquivalent (Stmt *S1, Stmt *S2)
 Determine whether the two statements are structurally equivalent.
 
unsigned getApplicableDiagnostic (unsigned ErrorDiagnostic)
 

Static Public Member Functions

static std::optional< unsignedfindUntaggedStructOrUnionIndex (RecordDecl *Anon)
 Find the index of the given anonymous struct/union within its context.
 

Public Attributes

ASTContextFromCtx
 AST contexts for which we are checking structural equivalence.
 
ASTContextToCtx
 
std::queue< std::pair< Decl *, Decl * > > DeclsToCheck
 
llvm::DenseSet< std::pair< Decl *, Decl * > > VisitedDecls
 
NonEquivalentDeclSetNonEquivalentDecls
 Declaration (from, to) pairs that are known not to be equivalent (which we have already complained about).
 
StructuralEquivalenceKind EqKind
 
bool StrictTypeSpelling
 Whether we're being strict about the spelling of types when unifying two types.
 
bool ErrorOnTagTypeMismatch
 Whether warn or error on tag type mismatches.
 
bool Complain
 Whether to complain about failures.
 
bool LastDiagFromC2 = false
 true if the last diagnostic came from ToCtx.
 
bool IgnoreTemplateParmDepth
 Whether to ignore comparing the depth of template param(TemplateTypeParm)
 

Detailed Description

Definition at line 41 of file ASTStructuralEquivalence.h.

Member Typedef Documentation

◆ NonEquivalentDeclSet

using clang::StructuralEquivalenceContext::NonEquivalentDeclSet = llvm::DenseSet<std::tuple<Decl *, Decl *, int> >

Store declaration pairs already found to be non-equivalent.

key: (from, to, IgnoreTemplateParmDepth)

Definition at line 44 of file ASTStructuralEquivalence.h.

Constructor & Destructor Documentation

◆ StructuralEquivalenceContext()

clang::StructuralEquivalenceContext::StructuralEquivalenceContext ( ASTContext FromCtx,
ASTContext ToCtx,
NonEquivalentDeclSet NonEquivalentDecls,
StructuralEquivalenceKind  EqKind,
bool  StrictTypeSpelling = false,
bool  Complain = true,
bool  ErrorOnTagTypeMismatch = false,
bool  IgnoreTemplateParmDepth = false 
)
inline

Definition at line 79 of file ASTStructuralEquivalence.h.

Member Function Documentation

◆ Diag1()

DiagnosticBuilder StructuralEquivalenceContext::Diag1 ( SourceLocation  Loc,
unsigned  DiagID 
)

◆ Diag2()

DiagnosticBuilder StructuralEquivalenceContext::Diag2 ( SourceLocation  Loc,
unsigned  DiagID 
)

◆ findUntaggedStructOrUnionIndex()

std::optional< unsigned > StructuralEquivalenceContext::findUntaggedStructOrUnionIndex ( RecordDecl Anon)
static

Find the index of the given anonymous struct/union within its context.

Returns
Returns the index of this anonymous struct/union in its context, including the next assigned index (if none of them match). Returns an empty option if the context is not a record, i.e.. if the anonymous struct/union is at namespace or block scope.

FIXME: This is needed by ASTImporter and ASTStructureEquivalence. It probably makes more sense in some other common place then here.

Definition at line 2340 of file ASTStructuralEquivalence.cpp.

References D, clang::Decl::getASTContext(), clang::Decl::getDeclContext(), clang::NamedDecl::getIdentifier(), clang::ASTContext::getRecordType(), and clang::ASTContext::hasSameType().

Referenced by IsStructurallyEquivalent().

◆ getApplicableDiagnostic()

unsigned StructuralEquivalenceContext::getApplicableDiagnostic ( unsigned  ErrorDiagnostic)

Definition at line 2382 of file ASTStructuralEquivalence.cpp.

References ErrorOnTagTypeMismatch.

◆ IsEquivalent() [1/3]

bool StructuralEquivalenceContext::IsEquivalent ( Decl D1,
Decl D2 
)

Determine whether the two declarations are structurally equivalent.

Implementation functions (all static functions in ASTStructuralEquivalence.cpp) must never call this function because that will wreak havoc the internal state (DeclsToCheck and VisitedDecls members) and can cause faulty equivalent results.

Definition at line 2428 of file ASTStructuralEquivalence.cpp.

References DeclsToCheck, IsStructurallyEquivalent(), and VisitedDecls.

Referenced by clang::Sema::hasStructuralCompatLayout(), IsEquivalentFriend(), clang::ASTImporter::IsStructurallyEquivalent(), and clang::ASTNodeImporter::IsStructuralMatch().

◆ IsEquivalent() [2/3]

bool StructuralEquivalenceContext::IsEquivalent ( QualType  T1,
QualType  T2 
)

Determine whether the two types are structurally equivalent.

Implementation functions (all static functions in ASTStructuralEquivalence.cpp) must never call this function because that will wreak havoc the internal state (DeclsToCheck and VisitedDecls members) and can cause faulty equivalent results.

Definition at line 2447 of file ASTStructuralEquivalence.cpp.

References DeclsToCheck, IsStructurallyEquivalent(), and VisitedDecls.

◆ IsEquivalent() [3/3]

bool StructuralEquivalenceContext::IsEquivalent ( Stmt S1,
Stmt S2 
)

Determine whether the two statements are structurally equivalent.

Implementation functions (all static functions in ASTStructuralEquivalence.cpp) must never call this function because that will wreak havoc the internal state (DeclsToCheck and VisitedDecls members) and can cause faulty equivalent results.

Definition at line 2456 of file ASTStructuralEquivalence.cpp.

References DeclsToCheck, IsStructurallyEquivalent(), and VisitedDecls.

Member Data Documentation

◆ Complain

bool clang::StructuralEquivalenceContext::Complain

Whether to complain about failures.

Definition at line 71 of file ASTStructuralEquivalence.h.

Referenced by Diag1(), and Diag2().

◆ DeclsToCheck

std::queue<std::pair<Decl *, Decl *> > clang::StructuralEquivalenceContext::DeclsToCheck

Definition at line 51 of file ASTStructuralEquivalence.h.

Referenced by IsEquivalent().

◆ EqKind

StructuralEquivalenceKind clang::StructuralEquivalenceContext::EqKind

Definition at line 61 of file ASTStructuralEquivalence.h.

◆ ErrorOnTagTypeMismatch

bool clang::StructuralEquivalenceContext::ErrorOnTagTypeMismatch

Whether warn or error on tag type mismatches.

Definition at line 68 of file ASTStructuralEquivalence.h.

Referenced by getApplicableDiagnostic().

◆ FromCtx

ASTContext& clang::StructuralEquivalenceContext::FromCtx

AST contexts for which we are checking structural equivalence.

Definition at line 47 of file ASTStructuralEquivalence.h.

Referenced by Diag1(), and Diag2().

◆ IgnoreTemplateParmDepth

bool clang::StructuralEquivalenceContext::IgnoreTemplateParmDepth

Whether to ignore comparing the depth of template param(TemplateTypeParm)

Definition at line 77 of file ASTStructuralEquivalence.h.

◆ LastDiagFromC2

bool clang::StructuralEquivalenceContext::LastDiagFromC2 = false

true if the last diagnostic came from ToCtx.

Definition at line 74 of file ASTStructuralEquivalence.h.

Referenced by Diag1(), and Diag2().

◆ NonEquivalentDecls

NonEquivalentDeclSet& clang::StructuralEquivalenceContext::NonEquivalentDecls

Declaration (from, to) pairs that are known not to be equivalent (which we have already complained about).

Definition at line 59 of file ASTStructuralEquivalence.h.

◆ StrictTypeSpelling

bool clang::StructuralEquivalenceContext::StrictTypeSpelling

Whether we're being strict about the spelling of types when unifying two types.

Definition at line 65 of file ASTStructuralEquivalence.h.

◆ ToCtx

ASTContext & clang::StructuralEquivalenceContext::ToCtx

Definition at line 47 of file ASTStructuralEquivalence.h.

Referenced by Diag1(), and Diag2().

◆ VisitedDecls

llvm::DenseSet<std::pair<Decl *, Decl *> > clang::StructuralEquivalenceContext::VisitedDecls

Definition at line 55 of file ASTStructuralEquivalence.h.

Referenced by IsEquivalent().


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