clang  14.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/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/None.h"
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Support/Casting.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/ErrorHandling.h"
#include <cassert>
#include <utility>
#include "clang/AST/StmtNodes.inc"
#include "clang/AST/DeclNodes.inc"
Include dependency graph for ASTStructuralEquivalence.cpp:

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. More...
 
static bool IsStructurallyEquivalent (StructuralEquivalenceContext &Context, Decl *D1, Decl *D2)
 Determine structural equivalence of two declarations. More...
 
static bool IsStructurallyEquivalent (StructuralEquivalenceContext &Context, const TemplateArgument &Arg1, const TemplateArgument &Arg2)
 Determine whether two template arguments are equivalent. More...
 
static bool IsStructurallyEquivalent (StructuralEquivalenceContext &Context, NestedNameSpecifier *NNS1, NestedNameSpecifier *NNS2)
 Determine whether two nested-name-specifiers are equivalent. More...
 
static bool IsStructurallyEquivalent (const IdentifierInfo *Name1, const IdentifierInfo *Name2)
 Determine whether two identifiers are equivalent. More...
 
static bool IsStructurallyEquivalent (StructuralEquivalenceContext &Context, const DeclarationName Name1, const DeclarationName Name2)
 
static bool IsStructurallyEquivalent (StructuralEquivalenceContext &Context, const Stmt *S1, const Stmt *S2)
 Determine structural equivalence of two statements. More...
 
static bool IsStructurallyEquivalent (StructuralEquivalenceContext &Context, const TemplateName &N1, const TemplateName &N2)
 
static bool IsArrayStructurallyEquivalent (StructuralEquivalenceContext &Context, const ArrayType *Array1, const ArrayType *Array2)
 Determine structural equivalence for the common part of array types. More...
 
static bool IsStructurallyEquivalent (StructuralEquivalenceContext &Context, FunctionType::ExtInfo EI1, FunctionType::ExtInfo EI2)
 Determine structural equivalence based on the ExtInfo of functions. More...
 
static bool IsEquivalentExceptionSpec (StructuralEquivalenceContext &Context, const FunctionProtoType *Proto1, const FunctionProtoType *Proto2)
 Check the equivalence of exception specifications. More...
 
static bool IsStructurallyEquivalent (StructuralEquivalenceContext &Context, FieldDecl *Field1, FieldDecl *Field2)
 Determine structural equivalence of two fields. More...
 
static bool IsStructurallyEquivalent (StructuralEquivalenceContext &Context, CXXMethodDecl *Method1, CXXMethodDecl *Method2)
 Determine structural equivalence of two methods. More...
 
static bool IsStructurallyEquivalentLambdas (StructuralEquivalenceContext &Context, CXXRecordDecl *D1, CXXRecordDecl *D2)
 Determine structural equivalence of two lambda classes. More...
 
static bool IsStructurallyEquivalent (StructuralEquivalenceContext &Context, RecordDecl *D1, RecordDecl *D2)
 Determine structural equivalence of two records. More...
 
static bool IsStructurallyEquivalent (StructuralEquivalenceContext &Context, EnumDecl *D1, EnumDecl *D2)
 Determine structural equivalence of two enums. More...
 
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, 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)
 

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));

◆ 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 345 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));

Definition at line 345 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 586 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

◆ IsStructurallyEquivalent() [1/23]

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

Determine whether two identifiers are equivalent.

Definition at line 410 of file ASTStructuralEquivalence.cpp.

References clang::IdentifierInfo::getName().

◆ IsStructurallyEquivalent() [2/23]

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

◆ IsStructurallyEquivalent() [3/23]

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

◆ IsStructurallyEquivalent() [4/23]

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

◆ IsStructurallyEquivalent() [5/23]

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

Determine structural equivalence of two statements.

Definition at line 385 of file ASTStructuralEquivalence.cpp.

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

◆ IsStructurallyEquivalent() [6/23]

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

◆ IsStructurallyEquivalent() [7/23]

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

◆ IsStructurallyEquivalent() [8/23]

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

◆ IsStructurallyEquivalent() [9/23]

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

Determine structural equivalence of two declarations.

Definition at line 1862 of file ASTStructuralEquivalence.cpp.

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

◆ IsStructurallyEquivalent() [10/23]

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

◆ IsStructurallyEquivalent() [11/23]

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

◆ IsStructurallyEquivalent() [12/23]

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

◆ IsStructurallyEquivalent() [13/23]

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

◆ IsStructurallyEquivalent() [14/23]

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

◆ IsStructurallyEquivalent() [15/23]

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 603 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() [16/23]

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

◆ IsStructurallyEquivalent() [17/23]

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

◆ IsStructurallyEquivalent() [18/23]

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

◆ IsStructurallyEquivalent() [19/23]

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

◆ IsStructurallyEquivalent() [20/23]

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

◆ IsStructurallyEquivalent() [21/23]

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

◆ IsStructurallyEquivalent() [22/23]

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

◆ IsStructurallyEquivalent() [23/23]

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

◆ IsStructurallyEquivalentLambdas()

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

Determine structural equivalence of two lambda classes.

Definition at line 1339 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
clang::index::SymbolKind::Class
@ Class
IsStructurallyEquivalent
static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context, QualType T1, QualType T2)
Determine structural equivalence of two types.
Definition: ASTStructuralEquivalence.cpp:657
clang::Decl
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:89