clang 22.0.0git
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 (const LangOptions &LangOpts, 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 UnsignedOrNone findUntaggedStructOrUnionIndex (RecordDecl *Anon)
 Find the index of the given anonymous struct/union within its context.

Public Attributes

const LangOptionsLangOpts
 The language options to use for making a structural equivalence check.
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 ( const LangOptions & LangOpts,
ASTContext & FromCtx,
ASTContext & ToCtx,
NonEquivalentDeclSet & NonEquivalentDecls,
StructuralEquivalenceKind EqKind,
bool StrictTypeSpelling = false,
bool Complain = true,
bool ErrorOnTagTypeMismatch = false,
bool IgnoreTemplateParmDepth = false )
inline

Member Function Documentation

◆ Diag1()

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

Definition at line 2559 of file ASTStructuralEquivalence.cpp.

References Complain, FromCtx, LastDiagFromC2, and ToCtx.

Referenced by IsStructurallyEquivalent().

◆ Diag2()

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

Definition at line 2568 of file ASTStructuralEquivalence.cpp.

References Complain, FromCtx, LastDiagFromC2, and ToCtx.

Referenced by IsStructurallyEquivalent().

◆ findUntaggedStructOrUnionIndex()

UnsignedOrNone 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 2578 of file ASTStructuralEquivalence.cpp.

References clang::Decl::getASTContext(), clang::Decl::getDeclContext(), and clang::NamedDecl::getIdentifier().

Referenced by IsStructurallyEquivalent().

◆ getApplicableDiagnostic()

unsigned StructuralEquivalenceContext::getApplicableDiagnostic ( unsigned ErrorDiagnostic)

Definition at line 2616 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 2662 of file ASTStructuralEquivalence.cpp.

References DeclsToCheck, IsStructurallyEquivalent(), and VisitedDecls.

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

◆ 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 2681 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 2690 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 74 of file ASTStructuralEquivalence.h.

Referenced by Diag1(), Diag2(), and StructuralEquivalenceContext().

◆ DeclsToCheck

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

Definition at line 54 of file ASTStructuralEquivalence.h.

Referenced by IsEquivalent(), IsEquivalent(), and IsEquivalent().

◆ EqKind

StructuralEquivalenceKind clang::StructuralEquivalenceContext::EqKind

Definition at line 64 of file ASTStructuralEquivalence.h.

Referenced by StructuralEquivalenceContext().

◆ ErrorOnTagTypeMismatch

bool clang::StructuralEquivalenceContext::ErrorOnTagTypeMismatch

Whether warn or error on tag type mismatches.

Definition at line 71 of file ASTStructuralEquivalence.h.

Referenced by getApplicableDiagnostic(), and StructuralEquivalenceContext().

◆ FromCtx

ASTContext& clang::StructuralEquivalenceContext::FromCtx

AST contexts for which we are checking structural equivalence.

Definition at line 50 of file ASTStructuralEquivalence.h.

Referenced by Diag1(), Diag2(), and StructuralEquivalenceContext().

◆ IgnoreTemplateParmDepth

bool clang::StructuralEquivalenceContext::IgnoreTemplateParmDepth

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

Definition at line 80 of file ASTStructuralEquivalence.h.

Referenced by StructuralEquivalenceContext().

◆ LangOpts

const LangOptions& clang::StructuralEquivalenceContext::LangOpts

The language options to use for making a structural equivalence check.

Definition at line 47 of file ASTStructuralEquivalence.h.

Referenced by StructuralEquivalenceContext().

◆ LastDiagFromC2

bool clang::StructuralEquivalenceContext::LastDiagFromC2 = false

true if the last diagnostic came from ToCtx.

Definition at line 77 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 62 of file ASTStructuralEquivalence.h.

Referenced by StructuralEquivalenceContext().

◆ StrictTypeSpelling

bool clang::StructuralEquivalenceContext::StrictTypeSpelling

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

Definition at line 68 of file ASTStructuralEquivalence.h.

Referenced by StructuralEquivalenceContext().

◆ ToCtx

ASTContext & clang::StructuralEquivalenceContext::ToCtx

Definition at line 50 of file ASTStructuralEquivalence.h.

Referenced by Diag1(), Diag2(), and StructuralEquivalenceContext().

◆ VisitedDecls

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

Definition at line 58 of file ASTStructuralEquivalence.h.

Referenced by IsEquivalent(), IsEquivalent(), and IsEquivalent().


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