clang 20.0.0git
Macros | Functions
ASTStructuralEquivalence.cpp File Reference
#include "clang/AST/ASTStructuralEquivalence.h"
#include "clang/AST/ASTContext.h"
#include "clang/AST/ASTDiagnostic.h"
#include "clang/AST/Decl.h"
#include "clang/AST/DeclBase.h"
#include "clang/AST/DeclCXX.h"
#include "clang/AST/DeclFriend.h"
#include "clang/AST/DeclObjC.h"
#include "clang/AST/DeclOpenMP.h"
#include "clang/AST/DeclTemplate.h"
#include "clang/AST/ExprCXX.h"
#include "clang/AST/ExprConcepts.h"
#include "clang/AST/ExprObjC.h"
#include "clang/AST/ExprOpenMP.h"
#include "clang/AST/NestedNameSpecifier.h"
#include "clang/AST/StmtObjC.h"
#include "clang/AST/StmtOpenACC.h"
#include "clang/AST/StmtOpenMP.h"
#include "clang/AST/TemplateBase.h"
#include "clang/AST/TemplateName.h"
#include "clang/AST/Type.h"
#include "clang/Basic/ExceptionSpecificationType.h"
#include "clang/Basic/IdentifierTable.h"
#include "clang/Basic/LLVM.h"
#include "clang/Basic/SourceLocation.h"
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/APSInt.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/ErrorHandling.h"
#include <cassert>
#include <optional>
#include <utility>
#include "clang/AST/StmtNodes.inc"
#include "clang/AST/DeclNodes.inc"

Go to the source code of this file.

Macros

#define STMT(CLASS, PARENT)
 
#define STMT(CLASS, PARENT)
 
#define ABSTRACT_STMT(S)
 
#define ABSTRACT_DECL(DECL)
 
#define DECL(DERIVED, BASE)
 

Functions

static bool IsStructurallyEquivalent (StructuralEquivalenceContext &Context, QualType T1, QualType T2)
 Determine structural equivalence of two types.
 
static bool IsStructurallyEquivalent (StructuralEquivalenceContext &Context, Decl *D1, Decl *D2)
 Determine structural equivalence of two declarations.
 
static bool IsStructurallyEquivalent (StructuralEquivalenceContext &Context, const Stmt *S1, const Stmt *S2)
 Determine structural equivalence of two statements.
 
static bool IsStructurallyEquivalent (StructuralEquivalenceContext &Context, const TemplateArgument &Arg1, const TemplateArgument &Arg2)
 Determine whether two template arguments are equivalent.
 
static bool IsStructurallyEquivalent (StructuralEquivalenceContext &Context, const TemplateArgumentLoc &Arg1, const TemplateArgumentLoc &Arg2)
 Determine whether two template argument locations are equivalent.
 
static bool IsStructurallyEquivalent (StructuralEquivalenceContext &Context, NestedNameSpecifier *NNS1, NestedNameSpecifier *NNS2)
 Determine whether two nested-name-specifiers are equivalent.
 
static bool IsStructurallyEquivalent (const IdentifierInfo *Name1, const IdentifierInfo *Name2)
 Determine whether two identifiers are equivalent.
 
static bool IsStructurallyEquivalent (StructuralEquivalenceContext &Context, const DeclarationName Name1, const DeclarationName Name2)
 
static bool IsStructurallyEquivalent (StructuralEquivalenceContext &Context, const UnaryOperator *E1, const CXXOperatorCallExpr *E2)
 
static bool IsStructurallyEquivalent (StructuralEquivalenceContext &Context, const CXXOperatorCallExpr *E1, const UnaryOperator *E2)
 
static bool IsStructurallyEquivalent (StructuralEquivalenceContext &Context, const BinaryOperator *E1, const CXXOperatorCallExpr *E2)
 
static bool IsStructurallyEquivalent (StructuralEquivalenceContext &Context, const CXXOperatorCallExpr *E1, const BinaryOperator *E2)
 
static bool IsStructurallyEquivalent (StructuralEquivalenceContext &Context, const TemplateName &N1, const TemplateName &N2)
 
static bool IsStructurallyEquivalent (StructuralEquivalenceContext &Context, ArrayRef< TemplateArgument > Args1, ArrayRef< TemplateArgument > Args2)
 Determine structural equivalence of two template argument lists.
 
static bool IsArrayStructurallyEquivalent (StructuralEquivalenceContext &Context, const ArrayType *Array1, const ArrayType *Array2)
 Determine structural equivalence for the common part of array types.
 
static bool IsStructurallyEquivalent (StructuralEquivalenceContext &Context, FunctionType::ExtInfo EI1, FunctionType::ExtInfo EI2)
 Determine structural equivalence based on the ExtInfo of functions.
 
static bool IsEquivalentExceptionSpec (StructuralEquivalenceContext &Context, const FunctionProtoType *Proto1, const FunctionProtoType *Proto2)
 Check the equivalence of exception specifications.
 
static bool IsStructurallyEquivalent (StructuralEquivalenceContext &Context, VarDecl *D1, VarDecl *D2)
 
static bool IsStructurallyEquivalent (StructuralEquivalenceContext &Context, FieldDecl *Field1, FieldDecl *Field2, QualType Owner2Type)
 
static bool IsStructurallyEquivalent (StructuralEquivalenceContext &Context, FieldDecl *Field1, FieldDecl *Field2)
 Determine structural equivalence of two fields.
 
static bool IsStructurallyEquivalent (StructuralEquivalenceContext &Context, CXXMethodDecl *Method1, CXXMethodDecl *Method2)
 Determine structural equivalence of two methods.
 
static bool IsStructurallyEquivalentLambdas (StructuralEquivalenceContext &Context, CXXRecordDecl *D1, CXXRecordDecl *D2)
 Determine structural equivalence of two lambda classes.
 
static bool IsRecordContextStructurallyEquivalent (StructuralEquivalenceContext &Context, RecordDecl *D1, RecordDecl *D2)
 Determine if context of a class is equivalent.
 
static bool NameIsStructurallyEquivalent (const TagDecl &D1, const TagDecl &D2)
 
static bool IsStructurallyEquivalent (StructuralEquivalenceContext &Context, RecordDecl *D1, RecordDecl *D2)
 Determine structural equivalence of two records.
 
static bool IsStructurallyEquivalent (StructuralEquivalenceContext &Context, EnumConstantDecl *D1, EnumConstantDecl *D2)
 
static bool IsStructurallyEquivalent (StructuralEquivalenceContext &Context, EnumDecl *D1, EnumDecl *D2)
 Determine structural equivalence of two enums.
 
static bool IsStructurallyEquivalent (StructuralEquivalenceContext &Context, TemplateParameterList *Params1, TemplateParameterList *Params2)
 
static bool IsStructurallyEquivalent (StructuralEquivalenceContext &Context, TemplateTypeParmDecl *D1, TemplateTypeParmDecl *D2)
 
static bool IsStructurallyEquivalent (StructuralEquivalenceContext &Context, NonTypeTemplateParmDecl *D1, NonTypeTemplateParmDecl *D2)
 
static bool IsStructurallyEquivalent (StructuralEquivalenceContext &Context, TemplateTemplateParmDecl *D1, TemplateTemplateParmDecl *D2)
 
static bool IsTemplateDeclCommonStructurallyEquivalent (StructuralEquivalenceContext &Ctx, TemplateDecl *D1, TemplateDecl *D2)
 
static bool IsStructurallyEquivalent (StructuralEquivalenceContext &Context, ClassTemplateDecl *D1, ClassTemplateDecl *D2)
 
static bool IsStructurallyEquivalent (StructuralEquivalenceContext &Context, FunctionTemplateDecl *D1, FunctionTemplateDecl *D2)
 
static bool IsStructurallyEquivalent (StructuralEquivalenceContext &Context, TypeAliasTemplateDecl *D1, TypeAliasTemplateDecl *D2)
 
static bool IsStructurallyEquivalent (StructuralEquivalenceContext &Context, ConceptDecl *D1, ConceptDecl *D2)
 
static bool IsStructurallyEquivalent (StructuralEquivalenceContext &Context, FriendDecl *D1, FriendDecl *D2)
 
static bool IsStructurallyEquivalent (StructuralEquivalenceContext &Context, TypedefNameDecl *D1, TypedefNameDecl *D2)
 
static bool IsStructurallyEquivalent (StructuralEquivalenceContext &Context, FunctionDecl *D1, FunctionDecl *D2)
 
static bool IsStructurallyEquivalent (StructuralEquivalenceContext &Context, ObjCIvarDecl *D1, ObjCIvarDecl *D2, QualType Owner2Type)
 
static bool IsStructurallyEquivalent (StructuralEquivalenceContext &Context, ObjCIvarDecl *D1, ObjCIvarDecl *D2)
 
static bool IsStructurallyEquivalent (StructuralEquivalenceContext &Context, ObjCMethodDecl *Method1, ObjCMethodDecl *Method2)
 
static bool IsStructurallyEquivalent (StructuralEquivalenceContext &Context, ObjCCategoryDecl *D1, ObjCCategoryDecl *D2)
 

Macro Definition Documentation

◆ ABSTRACT_DECL

#define ABSTRACT_DECL (   DECL)

◆ ABSTRACT_STMT

#define ABSTRACT_STMT (   S)

◆ DECL

#define DECL (   DERIVED,
  BASE 
)
Value:
case Decl::Kind::DERIVED: \
return ::IsStructurallyEquivalent(*this, static_cast<DERIVED##Decl *>(D1), \
static_cast<DERIVED##Decl *>(D2));
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:86

◆ STMT [1/2]

#define STMT (   CLASS,
  PARENT 
)
Value:
bool TraverseStmt(const CLASS *S1, const CLASS *S2) { \
if (!TraverseStmt(static_cast<const PARENT *>(S1), \
static_cast<const PARENT *>(S2))) \
return false; \
return IsStmtEquivalent(S1, S2); \
}

Definition at line 413 of file ASTStructuralEquivalence.cpp.

◆ STMT [2/2]

#define STMT (   CLASS,
  PARENT 
)
Value:
case Stmt::StmtClass::CLASS##Class: \
return TraverseStmt(static_cast<const CLASS *>(S1), \
static_cast<const CLASS *>(S2));
@ Class
The "class" keyword introduces the elaborated-type-specifier.

Definition at line 413 of file ASTStructuralEquivalence.cpp.

Function Documentation

◆ IsArrayStructurallyEquivalent()

static bool IsArrayStructurallyEquivalent ( StructuralEquivalenceContext Context,
const ArrayType Array1,
const ArrayType Array2 
)
static

Determine structural equivalence for the common part of array types.

Definition at line 732 of file ASTStructuralEquivalence.cpp.

References clang::ArrayType::getElementType(), clang::ArrayType::getIndexTypeQualifiers(), clang::ArrayType::getSizeModifier(), and IsStructurallyEquivalent().

Referenced by IsStructurallyEquivalent().

◆ IsEquivalentExceptionSpec()

static bool IsEquivalentExceptionSpec ( StructuralEquivalenceContext Context,
const FunctionProtoType Proto1,
const FunctionProtoType Proto2 
)
static

◆ IsRecordContextStructurallyEquivalent()

static bool IsRecordContextStructurallyEquivalent ( StructuralEquivalenceContext Context,
RecordDecl D1,
RecordDecl D2 
)
static

◆ IsStructurallyEquivalent() [1/37]

static bool IsStructurallyEquivalent ( const IdentifierInfo Name1,
const IdentifierInfo Name2 
)
static

Determine whether two identifiers are equivalent.

Definition at line 533 of file ASTStructuralEquivalence.cpp.

References clang::IdentifierInfo::getName().

◆ IsStructurallyEquivalent() [2/37]

static bool IsStructurallyEquivalent ( StructuralEquivalenceContext Context,
ArrayRef< TemplateArgument Args1,
ArrayRef< TemplateArgument Args2 
)
static

Determine structural equivalence of two template argument lists.

Definition at line 710 of file ASTStructuralEquivalence.cpp.

References IsStructurallyEquivalent().

◆ IsStructurallyEquivalent() [3/37]

static bool IsStructurallyEquivalent ( StructuralEquivalenceContext Context,
ClassTemplateDecl D1,
ClassTemplateDecl D2 
)
static

◆ IsStructurallyEquivalent() [4/37]

static bool IsStructurallyEquivalent ( StructuralEquivalenceContext Context,
ConceptDecl D1,
ConceptDecl D2 
)
static

◆ IsStructurallyEquivalent() [5/37]

static bool IsStructurallyEquivalent ( StructuralEquivalenceContext Context,
const BinaryOperator E1,
const CXXOperatorCallExpr E2 
)
static

◆ IsStructurallyEquivalent() [6/37]

static bool IsStructurallyEquivalent ( StructuralEquivalenceContext Context,
const CXXOperatorCallExpr E1,
const BinaryOperator E2 
)
static

◆ IsStructurallyEquivalent() [7/37]

static bool IsStructurallyEquivalent ( StructuralEquivalenceContext Context,
const CXXOperatorCallExpr E1,
const UnaryOperator E2 
)
static

◆ IsStructurallyEquivalent() [8/37]

static bool IsStructurallyEquivalent ( StructuralEquivalenceContext Context,
const DeclarationName  Name1,
const DeclarationName  Name2 
)
static

◆ IsStructurallyEquivalent() [9/37]

static bool IsStructurallyEquivalent ( StructuralEquivalenceContext Context,
const Stmt S1,
const Stmt S2 
)
static

Determine structural equivalence of two statements.

Definition at line 487 of file ASTStructuralEquivalence.cpp.

References clang::Stmt::children(), and IsStructurallyEquivalent().

◆ IsStructurallyEquivalent() [10/37]

static bool IsStructurallyEquivalent ( StructuralEquivalenceContext Context,
const TemplateArgument Arg1,
const TemplateArgument Arg2 
)
static

◆ IsStructurallyEquivalent() [11/37]

static bool IsStructurallyEquivalent ( StructuralEquivalenceContext Context,
const TemplateArgumentLoc Arg1,
const TemplateArgumentLoc Arg2 
)
static

Determine whether two template argument locations are equivalent.

Definition at line 723 of file ASTStructuralEquivalence.cpp.

References clang::TemplateArgumentLoc::getArgument(), and IsStructurallyEquivalent().

◆ IsStructurallyEquivalent() [12/37]

static bool IsStructurallyEquivalent ( StructuralEquivalenceContext Context,
const TemplateName N1,
const TemplateName N2 
)
static

◆ IsStructurallyEquivalent() [13/37]

static bool IsStructurallyEquivalent ( StructuralEquivalenceContext Context,
const UnaryOperator E1,
const CXXOperatorCallExpr E2 
)
static

◆ IsStructurallyEquivalent() [14/37]

static bool IsStructurallyEquivalent ( StructuralEquivalenceContext Context,
CXXMethodDecl Method1,
CXXMethodDecl Method2 
)
static

◆ IsStructurallyEquivalent() [15/37]

static bool IsStructurallyEquivalent ( StructuralEquivalenceContext Context,
Decl D1,
Decl D2 
)
static

Determine structural equivalence of two declarations.

Definition at line 2279 of file ASTStructuralEquivalence.cpp.

References clang::Decl::getCanonicalDecl(), and P.

◆ IsStructurallyEquivalent() [16/37]

static bool IsStructurallyEquivalent ( StructuralEquivalenceContext Context,
EnumConstantDecl D1,
EnumConstantDecl D2 
)
static

◆ IsStructurallyEquivalent() [17/37]

static bool IsStructurallyEquivalent ( StructuralEquivalenceContext Context,
EnumDecl D1,
EnumDecl D2 
)
static

◆ IsStructurallyEquivalent() [18/37]

static bool IsStructurallyEquivalent ( StructuralEquivalenceContext Context,
FieldDecl Field1,
FieldDecl Field2 
)
static

Determine structural equivalence of two fields.

Definition at line 1485 of file ASTStructuralEquivalence.cpp.

References clang::Decl::getDeclContext(), clang::ASTContext::getTypeDeclType(), and IsStructurallyEquivalent().

◆ IsStructurallyEquivalent() [19/37]

static bool IsStructurallyEquivalent ( StructuralEquivalenceContext Context,
FieldDecl Field1,
FieldDecl Field2,
QualType  Owner2Type 
)
static

◆ IsStructurallyEquivalent() [20/37]

static bool IsStructurallyEquivalent ( StructuralEquivalenceContext Context,
FriendDecl D1,
FriendDecl D2 
)
static

◆ IsStructurallyEquivalent() [21/37]

static bool IsStructurallyEquivalent ( StructuralEquivalenceContext Context,
FunctionDecl D1,
FunctionDecl D2 
)
static

◆ IsStructurallyEquivalent() [22/37]

static bool IsStructurallyEquivalent ( StructuralEquivalenceContext Context,
FunctionTemplateDecl D1,
FunctionTemplateDecl D2 
)
static

◆ IsStructurallyEquivalent() [23/37]

static bool IsStructurallyEquivalent ( StructuralEquivalenceContext Context,
FunctionType::ExtInfo  EI1,
FunctionType::ExtInfo  EI2 
)
static

Determine structural equivalence based on the ExtInfo of functions.

This is inspired by ASTContext::mergeFunctionTypes(), we compare calling conventions bits but must not compare some other bits.

Definition at line 749 of file ASTStructuralEquivalence.cpp.

References clang::FunctionType::ExtInfo::getCC(), clang::FunctionType::ExtInfo::getHasRegParm(), clang::FunctionType::ExtInfo::getNoCallerSavedRegs(), clang::FunctionType::ExtInfo::getNoCfCheck(), clang::FunctionType::ExtInfo::getProducesResult(), and clang::FunctionType::ExtInfo::getRegParm().

◆ IsStructurallyEquivalent() [24/37]

static bool IsStructurallyEquivalent ( StructuralEquivalenceContext Context,
NestedNameSpecifier NNS1,
NestedNameSpecifier NNS2 
)
static

◆ IsStructurallyEquivalent() [25/37]

static bool IsStructurallyEquivalent ( StructuralEquivalenceContext Context,
NonTypeTemplateParmDecl D1,
NonTypeTemplateParmDecl D2 
)
static

◆ IsStructurallyEquivalent() [26/37]

static bool IsStructurallyEquivalent ( StructuralEquivalenceContext Context,
ObjCCategoryDecl D1,
ObjCCategoryDecl D2 
)
static

◆ IsStructurallyEquivalent() [27/37]

static bool IsStructurallyEquivalent ( StructuralEquivalenceContext Context,
ObjCIvarDecl D1,
ObjCIvarDecl D2 
)
static

◆ IsStructurallyEquivalent() [28/37]

static bool IsStructurallyEquivalent ( StructuralEquivalenceContext Context,
ObjCIvarDecl D1,
ObjCIvarDecl D2,
QualType  Owner2Type 
)
static

◆ IsStructurallyEquivalent() [29/37]

static bool IsStructurallyEquivalent ( StructuralEquivalenceContext Context,
ObjCMethodDecl Method1,
ObjCMethodDecl Method2 
)
static

◆ IsStructurallyEquivalent() [30/37]

static bool IsStructurallyEquivalent ( StructuralEquivalenceContext Context,
QualType  T1,
QualType  T2 
)
static

◆ IsStructurallyEquivalent() [31/37]

static bool IsStructurallyEquivalent ( StructuralEquivalenceContext Context,
RecordDecl D1,
RecordDecl D2 
)
static

◆ IsStructurallyEquivalent() [32/37]

static bool IsStructurallyEquivalent ( StructuralEquivalenceContext Context,
TemplateParameterList Params1,
TemplateParameterList Params2 
)
static

◆ IsStructurallyEquivalent() [33/37]

static bool IsStructurallyEquivalent ( StructuralEquivalenceContext Context,
TemplateTemplateParmDecl D1,
TemplateTemplateParmDecl D2 
)
static

◆ IsStructurallyEquivalent() [34/37]

static bool IsStructurallyEquivalent ( StructuralEquivalenceContext Context,
TemplateTypeParmDecl D1,
TemplateTypeParmDecl D2 
)
static

◆ IsStructurallyEquivalent() [35/37]

static bool IsStructurallyEquivalent ( StructuralEquivalenceContext Context,
TypeAliasTemplateDecl D1,
TypeAliasTemplateDecl D2 
)
static

◆ IsStructurallyEquivalent() [36/37]

static bool IsStructurallyEquivalent ( StructuralEquivalenceContext Context,
TypedefNameDecl D1,
TypedefNameDecl D2 
)
static

◆ IsStructurallyEquivalent() [37/37]

static bool IsStructurallyEquivalent ( StructuralEquivalenceContext Context,
VarDecl D1,
VarDecl D2 
)
static

◆ IsStructurallyEquivalentLambdas()

static bool IsStructurallyEquivalentLambdas ( StructuralEquivalenceContext Context,
CXXRecordDecl D1,
CXXRecordDecl D2 
)
static

Determine structural equivalence of two lambda classes.

Definition at line 1548 of file ASTStructuralEquivalence.cpp.

References clang::CXXRecordDecl::getLambdaCallOperator(), clang::CXXRecordDecl::isLambda(), and IsStructurallyEquivalent().

Referenced by IsStructurallyEquivalent().

◆ IsTemplateDeclCommonStructurallyEquivalent()

static bool IsTemplateDeclCommonStructurallyEquivalent ( StructuralEquivalenceContext Ctx,
TemplateDecl D1,
TemplateDecl D2 
)
static

◆ NameIsStructurallyEquivalent()

static bool NameIsStructurallyEquivalent ( const TagDecl D1,
const TagDecl D2 
)
static

Definition at line 1602 of file ASTStructuralEquivalence.cpp.

References D, and IsStructurallyEquivalent().

Referenced by IsStructurallyEquivalent().