89#include "llvm/ADT/APInt.h"
90#include "llvm/ADT/APSInt.h"
91#include "llvm/ADT/STLExtras.h"
92#include "llvm/ADT/StringExtras.h"
93#include "llvm/Support/Compiler.h"
94#include "llvm/Support/ErrorHandling.h"
163 llvm_unreachable(
"Unhandled kind of DeclarationName");
170 StructuralEquivalenceContext &Context;
176 bool IsStmtEquivalent(
const AddrLabelExpr *E1,
const AddrLabelExpr *E2) {
180 bool IsStmtEquivalent(
const AtomicExpr *E1,
const AtomicExpr *E2) {
184 bool IsStmtEquivalent(
const BinaryOperator *E1,
const BinaryOperator *E2) {
188 bool IsStmtEquivalent(
const CallExpr *E1,
const CallExpr *E2) {
194 if (
static_cast<bool>(Callee1) !=
static_cast<bool>(Callee2))
198 if (!
static_cast<bool>(Callee1))
205 bool IsStmtEquivalent(
const CharacterLiteral *E1,
206 const CharacterLiteral *E2) {
210 bool IsStmtEquivalent(
const ChooseExpr *E1,
const ChooseExpr *E2) {
223 bool IsStmtEquivalent(
const DeclRefExpr *DRE1,
const DeclRefExpr *DRE2) {
224 const ValueDecl *Decl1 = DRE1->
getDecl();
225 const ValueDecl *Decl2 = DRE2->
getDecl();
226 if (!Decl1 || !Decl2)
229 const_cast<ValueDecl *
>(Decl2));
232 bool IsStmtEquivalent(
const DependentScopeDeclRefExpr *DE1,
233 const DependentScopeDeclRefExpr *DE2) {
241 bool IsStmtEquivalent(
const Expr *E1,
const Expr *E2) {
245 bool IsStmtEquivalent(
const ExpressionTraitExpr *E1,
246 const ExpressionTraitExpr *E2) {
250 bool IsStmtEquivalent(
const FloatingLiteral *E1,
const FloatingLiteral *E2) {
254 bool IsStmtEquivalent(
const GenericSelectionExpr *E1,
255 const GenericSelectionExpr *E2) {
258 std::optional<TypeSourceInfo *> Child1 = std::get<0>(Pair);
259 std::optional<TypeSourceInfo *> Child2 = std::get<1>(Pair);
261 if (!Child1 || !Child2)
265 (*Child2)->getType()))
272 bool IsStmtEquivalent(
const ImplicitCastExpr *CastE1,
273 const ImplicitCastExpr *CastE2) {
278 bool IsStmtEquivalent(
const IntegerLiteral *E1,
const IntegerLiteral *E2) {
282 bool IsStmtEquivalent(
const MemberExpr *E1,
const MemberExpr *E2) {
287 bool IsStmtEquivalent(
const ObjCStringLiteral *E1,
288 const ObjCStringLiteral *E2) {
293 bool IsStmtEquivalent(
const Stmt *S1,
const Stmt *S2) {
return true; }
295 bool IsStmtEquivalent(
const GotoStmt *S1,
const GotoStmt *S2) {
303 return ::IsStructurallyEquivalent(Name1, Name2);
306 bool IsStmtEquivalent(
const SourceLocExpr *E1,
const SourceLocExpr *E2) {
310 bool IsStmtEquivalent(
const StmtExpr *E1,
const StmtExpr *E2) {
314 bool IsStmtEquivalent(
const StringLiteral *E1,
const StringLiteral *E2) {
318 bool IsStmtEquivalent(
const SubstNonTypeTemplateParmExpr *E1,
319 const SubstNonTypeTemplateParmExpr *E2) {
330 bool IsStmtEquivalent(
const SubstNonTypeTemplateParmPackExpr *E1,
331 const SubstNonTypeTemplateParmPackExpr *E2) {
336 bool IsStmtEquivalent(
const TypeTraitExpr *E1,
const TypeTraitExpr *E2) {
341 std::optional<TypeSourceInfo *> Child1 = std::get<0>(Pair);
342 std::optional<TypeSourceInfo *> Child2 = std::get<1>(Pair);
344 if (!Child1 || !Child2)
348 (*Child2)->getType()))
354 bool IsStmtEquivalent(
const CXXDependentScopeMemberExpr *E1,
355 const CXXDependentScopeMemberExpr *E2) {
363 bool IsStmtEquivalent(
const UnaryExprOrTypeTraitExpr *E1,
364 const UnaryExprOrTypeTraitExpr *E2) {
371 bool IsStmtEquivalent(
const UnaryOperator *E1,
const UnaryOperator *E2) {
375 bool IsStmtEquivalent(
const VAArgExpr *E1,
const VAArgExpr *E2) {
380 bool IsStmtEquivalent(
const OverloadExpr *E1,
const OverloadExpr *E2) {
404 bool IsStmtEquivalent(
const CXXBoolLiteralExpr *E1,
const CXXBoolLiteralExpr *E2) {
409 bool TraverseStmt(
const Stmt *S1,
const Stmt *S2) {
return true; }
416#define STMT(CLASS, PARENT) \
417 bool TraverseStmt(const CLASS *S1, const CLASS *S2) { \
418 if (!TraverseStmt(static_cast<const PARENT *>(S1), \
419 static_cast<const PARENT *>(S2))) \
421 return IsStmtEquivalent(S1, S2); \
423#include "clang/AST/StmtNodes.inc"
431 bool IsEquivalent(
const Stmt *S1,
const Stmt *S2) {
442 llvm_unreachable(
"Can't traverse NoStmtClass");
443#define STMT(CLASS, PARENT) \
444 case Stmt::StmtClass::CLASS##Class: \
445 return TraverseStmt(static_cast<const CLASS *>(S1), \
446 static_cast<const CLASS *>(S2));
447#define ABSTRACT_STMT(S)
448#include "clang/AST/StmtNodes.inc"
450 llvm_unreachable(
"Invalid statement kind");
458struct AttrComparisonResult {
460 const Attr *A1 =
nullptr, *A2 =
nullptr;
470static AttrComparisonResult
481 auto RemoveInherited = [](
const Attr *A) {
return !A->isInherited(); };
483 llvm::copy_if(D1->
attrs(), std::back_inserter(A1), RemoveInherited);
484 llvm::copy_if(D2->
attrs(), std::back_inserter(A2), RemoveInherited);
488 auto I1 = A1.begin(), E1 = A1.end(), I2 = A2.begin(), E2 = A2.end();
489 for (; I1 != E1 && I2 != E2; ++I1, ++I2) {
490 bool R = (*I1)->isEquivalent(**I2, Context);
492 R = !Context.checkDeclQueue();
494 return {
false, *I1, *I2};
500 return {
false,
nullptr, *I2};
508 const Decl *PrimaryDecl =
nullptr) {
509 if (Context.Complain) {
512 const auto *DiagnoseDecl =
cast<TypeDecl>(PrimaryDecl ? PrimaryDecl : D2);
513 Context.Diag2(DiagnoseDecl->getLocation(),
514 diag::warn_odr_tag_type_with_attributes)
515 << Context.ToCtx.getTypeDeclType(DiagnoseDecl)
516 << (PrimaryDecl !=
nullptr);
518 Context.Diag1(R.A1->getLoc(), diag::note_odr_attr_here) << R.A1;
520 Context.Diag2(R.A2->getLoc(), diag::note_odr_attr_here) << R.A2;
578 if (
const auto *E2CXXOperatorCall = dyn_cast<CXXOperatorCallExpr>(S2)) {
579 if (
const auto *E1Unary = dyn_cast<UnaryOperator>(S1))
581 if (
const auto *E1Binary = dyn_cast<BinaryOperator>(S1))
584 if (
const auto *E1CXXOperatorCall = dyn_cast<CXXOperatorCallExpr>(S1)) {
585 if (
const auto *E2Unary = dyn_cast<UnaryOperator>(S2))
587 if (
const auto *E2Binary = dyn_cast<BinaryOperator>(S2))
592 StmtComparer Comparer(Context);
593 if (!Comparer.IsEquivalent(S1, S2))
598 std::optional<const Stmt *> Child1 = std::get<0>(Pair);
599 std::optional<const Stmt *> Child2 = std::get<1>(Pair);
602 if (!Child1 || !Child2)
618 if (!Name1 || !Name2)
619 return Name1 == Name2;
677 if (TemplateDeclN1 && TemplateDeclN2) {
683 }
else if (TemplateDeclN1 || TemplateDeclN2)
695 E1 = OS1->
end(), E2 = OS2->end();
696 for (; I1 != E1 && I2 != E2; ++I1, ++I2)
699 return I1 == E1 && I2 == E2;
717 P2->getArgumentPack()) &&
719 P2->getAssociatedDecl()) &&
741 llvm_unreachable(
"unimplemented");
800 llvm_unreachable(
"Invalid template argument kind");
807 if (Args1.size() != Args2.size())
809 for (
unsigned I = 0, N = Args1.size(); I != N; ++I) {
905 if (!Context.StrictTypeSpelling) {
922 TC = Type::FunctionNoProto;
925 TC = Type::FunctionNoProto;
926 else if (Context.LangOpts.C23 && !Context.StrictTypeSpelling &&
948 T1 = Context.FromCtx.IntTy;
954 T2 = Context.ToCtx.IntTy;
977 case Type::ArrayParameter:
991 case Type::BlockPointer:
998 case Type::LValueReference:
999 case Type::RValueReference: {
1002 if (Ref1->isSpelledAsLValue() != Ref2->isSpelledAsLValue())
1004 if (Ref1->isInnerRef() != Ref2->isInnerRef())
1007 Ref2->getPointeeTypeAsWritten()))
1012 case Type::MemberPointer: {
1016 MemPtr2->getPointeeType()))
1019 MemPtr2->getQualifier()))
1022 *D2 = MemPtr2->getMostRecentCXXRecordDecl();
1030 case Type::ConstantArray: {
1033 if (!llvm::APInt::isSameValue(Array1->getSize(), Array2->getSize()))
1041 case Type::IncompleteArray:
1047 case Type::VariableArray: {
1051 Array2->getSizeExpr()))
1060 case Type::DependentSizedArray: {
1064 Array2->getSizeExpr()))
1073 case Type::DependentAddressSpace: {
1077 DepAddressSpace2->getAddrSpaceExpr()))
1080 DepAddressSpace2->getPointeeType()))
1086 case Type::DependentSizedExtVector: {
1090 Vec2->getSizeExpr()))
1093 Vec2->getElementType()))
1098 case Type::DependentVector: {
1101 if (Vec1->getVectorKind() != Vec2->getVectorKind())
1104 Vec2->getSizeExpr()))
1107 Vec2->getElementType()))
1113 case Type::ExtVector: {
1117 Vec2->getElementType()))
1119 if (Vec1->getNumElements() != Vec2->getNumElements())
1121 if (Vec1->getVectorKind() != Vec2->getVectorKind())
1126 case Type::DependentSizedMatrix: {
1141 case Type::ConstantMatrix: {
1154 case Type::CooperativeMatrix: {
1169 case Type::FunctionProto: {
1173 if (Proto1->getNumParams() != Proto2->getNumParams())
1175 for (
unsigned I = 0, N = Proto1->getNumParams(); I != N; ++I) {
1177 Proto2->getParamType(I)))
1180 if (Proto1->isVariadic() != Proto2->isVariadic())
1183 if (Proto1->getMethodQuals() != Proto2->getMethodQuals())
1187 const auto *OrigProto1 =
1189 const auto *OrigProto2 =
1198 case Type::FunctionNoProto: {
1202 Function2->getReturnType()))
1205 Function2->getExtInfo()))
1210 case Type::UnresolvedUsing:
1217 case Type::Attributed:
1228 case Type::CountAttributed:
1235 case Type::LateParsedAttr:
1242 case Type::BTFTagAttributed:
1249 case Type::OverflowBehavior:
1256 case Type::HLSLAttributedResource:
1269 Res2->getSampleCountExpr()))
1271 HLSLAttributedResourceType::Attributes Attrs1 = Res1->getAttrs();
1272 HLSLAttributedResourceType::Attributes Attrs2 = Res2->getAttrs();
1273 Attrs1.SampleCountExpr = Attrs2.SampleCountExpr =
nullptr;
1274 if (Attrs1 != Attrs2)
1279 case Type::HLSLInlineSpirv:
1287 for (
size_t I = 0; I < cast<HLSLInlineSpirvType>(T1)->getOperands().size();
1302 case Type::MacroQualified:
1311 if (U1->getKeyword() != U2->getKeyword())
1314 U2->getQualifier()))
1322 case Type::Typedef: {
1324 if (U1->getKeyword() != U2->getKeyword())
1327 U2->getQualifier()))
1331 if (U1->typeMatchesDecl() != U2->typeMatchesDecl())
1333 if (!U1->typeMatchesDecl() &&
1339 case Type::TypeOfExpr:
1353 case Type::UnaryTransform:
1360 case Type::Decltype:
1371 Auto2->getDeducedType()))
1373 if (Auto1->isConstrained() != Auto2->isConstrained())
1375 if (Auto1->isConstrained()) {
1376 if (Auto1->getTypeConstraintConcept().getAsTemplateDecl() !=
1377 Auto2->getTypeConstraintConcept().getAsTemplateDecl())
1380 Auto1->getTypeConstraintArguments(),
1381 Auto2->getTypeConstraintArguments()))
1387 case Type::DeducedTemplateSpecialization: {
1391 DT2->getTemplateName()))
1394 DT2->getDeducedType()))
1401 case Type::InjectedClassName: {
1403 if (TT1->getKeyword() != TT2->getKeyword())
1405 if (TT1->isTagOwned() != TT2->isTagOwned())
1408 TT2->getQualifier()))
1415 case Type::TemplateTypeParm: {
1418 if (!Context.IgnoreTemplateParmDepth &&
1419 Parm1->getDepth() != Parm2->getDepth())
1421 if (Parm1->getIndex() != Parm2->getIndex())
1423 if (Parm1->isParameterPack() != Parm2->isParameterPack())
1430 case Type::SubstTemplateTypeParm: {
1434 Subst2->getReplacementType()))
1437 Subst2->getAssociatedDecl()))
1439 if (Subst1->getIndex() != Subst2->getIndex())
1441 if (Subst1->getPackIndex() != Subst2->getPackIndex())
1446 case Type::SubstBuiltinTemplatePack: {
1450 Subst2->getArgumentPack()))
1454 case Type::SubstTemplateTypeParmPack: {
1458 Subst2->getAssociatedDecl()))
1460 if (Subst1->getIndex() != Subst2->getIndex())
1463 Subst2->getArgumentPack()))
1468 case Type::TemplateSpecialization: {
1472 Spec2->getTemplateName()))
1475 Spec2->template_arguments()))
1480 case Type::DependentName: {
1484 Typename2->getQualifier()))
1487 Typename2->getIdentifier()))
1493 case Type::PackExpansion:
1500 case Type::PackIndexing:
1510 case Type::ObjCInterface: {
1519 case Type::ObjCTypeParam: {
1525 if (Obj1->getNumProtocols() != Obj2->getNumProtocols())
1527 for (
unsigned I = 0, N = Obj1->getNumProtocols(); I != N; ++I) {
1529 Obj2->getProtocol(I)))
1535 case Type::ObjCObject: {
1539 Obj2->getBaseType()))
1541 if (Obj1->getNumProtocols() != Obj2->getNumProtocols())
1543 for (
unsigned I = 0, N = Obj1->getNumProtocols(); I != N; ++I) {
1545 Obj2->getProtocol(I)))
1551 case Type::ObjCObjectPointer: {
1555 Ptr2->getPointeeType()))
1571 case Type::BitInt: {
1575 if (Int1->isUnsigned() != Int2->isUnsigned() ||
1576 Int1->getNumBits() != Int2->getNumBits())
1580 case Type::DependentBitInt: {
1584 if (Int1->isUnsigned() != Int2->isUnsigned() ||
1586 Int2->getNumBitsExpr()))
1590 case Type::PredefinedSugar: {
1593 if (TP1->getKind() != TP2->getKind())
1636 if (Context.LangOpts.C23 &&
1654 if (Context.Complain) {
1656 Owner2->getLocation(),
1657 Context.getApplicableDiagnostic(diag::err_odr_tag_type_inconsistent))
1658 << Owner2Type << (&Context.FromCtx != &Context.ToCtx);
1659 Context.Diag2(Field2->
getLocation(), diag::note_odr_field_name)
1661 Context.Diag1(Field1->
getLocation(), diag::note_odr_field_name)
1669 if (Context.Complain) {
1671 Owner2->getLocation(),
1672 Context.getApplicableDiagnostic(diag::err_odr_tag_type_inconsistent))
1673 << Owner2Type << (&Context.FromCtx != &Context.ToCtx);
1674 Context.Diag2(Field2->
getLocation(), diag::note_odr_field)
1676 Context.Diag1(Field1->
getLocation(), diag::note_odr_field)
1686 bool Diagnose =
false;
1693 if (Diagnose && Context.Complain) {
1694 auto DiagNote = [&](
const FieldDecl *FD,
1702 (Context.*
Diag)(FD->
getLocation(), diag::note_odr_field_not_bit_field)
1708 Owner2->getLocation(),
1709 Context.getApplicableDiagnostic(diag::err_odr_tag_type_inconsistent))
1710 << Owner2Type << (&Context.FromCtx != &Context.ToCtx);
1726 Context.ToCtx.getCanonicalTagType(Owner2));
1741 if (!Method1 && !Method2)
1743 if (!Method1 || !Method2)
1746 bool PropertiesEqual =
1760 if (!PropertiesEqual)
1764 if (
auto *Constructor1 = dyn_cast<CXXConstructorDecl>(Method1)) {
1766 if (!Constructor1->getExplicitSpecifier().isEquivalent(
1767 Constructor2->getExplicitSpecifier()))
1771 if (
auto *Conversion1 = dyn_cast<CXXConversionDecl>(Method1)) {
1773 if (!Conversion1->getExplicitSpecifier().isEquivalent(
1774 Conversion2->getExplicitSpecifier()))
1777 Conversion2->getConversionType()))
1801 "Must be called on lambda classes");
1832 if (
const auto *ND1 = dyn_cast<NamedDecl>(DC1)) {
1839 if (
auto *D1Spec = dyn_cast<ClassTemplateSpecializationDecl>(DC1)) {
1840 auto *D2Spec = dyn_cast<ClassTemplateSpecializationDecl>(DC2);
1856 if (
const TypedefNameDecl *TypedefName = D.getTypedefNameForAnonDecl())
1857 return TypedefName->getIdentifier();
1891 if (Context.Complain) {
1892 Context.Diag2(D2->
getLocation(), Context.getApplicableDiagnostic(
1893 diag::err_odr_tag_type_inconsistent))
1894 << Context.ToCtx.getCanonicalTagType(D2)
1895 << (&Context.FromCtx != &Context.ToCtx);
1896 Context.Diag1(D1->
getLocation(), diag::note_odr_tag_kind_here)
1910 if (*Index1 != *Index2)
1921 if (!Context.LangOpts.C23 &&
1927 const auto *Spec1 = dyn_cast<ClassTemplateSpecializationDecl>(D1);
1928 const auto *Spec2 = dyn_cast<ClassTemplateSpecializationDecl>(D2);
1929 if (Spec1 && Spec2) {
1932 Spec2->getSpecializedTemplate()))
1936 if (Spec1->getTemplateArgs().size() != Spec2->getTemplateArgs().size())
1939 for (
unsigned I = 0, N = Spec1->getTemplateArgs().size(); I != N; ++I)
1941 Spec2->getTemplateArgs().get(I)))
1946 else if (Spec1 || Spec2)
1955 return !Context.LangOpts.C23;
1959 if (Context.LangOpts.C23 &&
1977 if (
auto *D1CXX = dyn_cast<CXXRecordDecl>(D1)) {
1978 if (
auto *D2CXX = dyn_cast<CXXRecordDecl>(D2)) {
1979 if (D1CXX->hasExternalLexicalStorage() &&
1980 !D1CXX->isCompleteDefinition()) {
1981 D1CXX->getASTContext().getExternalSource()->CompleteType(D1CXX);
1984 if (D1CXX->isLambda() != D2CXX->isLambda())
1986 if (D1CXX->isLambda()) {
1991 if (D1CXX->getNumBases() != D2CXX->getNumBases()) {
1992 if (Context.Complain) {
1994 Context.getApplicableDiagnostic(
1995 diag::err_odr_tag_type_inconsistent))
1996 << Context.ToCtx.getCanonicalTagType(D2)
1997 << (&Context.FromCtx != &Context.ToCtx);
1998 Context.Diag2(D2->
getLocation(), diag::note_odr_number_of_bases)
1999 << D2CXX->getNumBases();
2000 Context.Diag1(D1->
getLocation(), diag::note_odr_number_of_bases)
2001 << D1CXX->getNumBases();
2008 BaseEnd1 = D1CXX->bases_end(),
2009 Base2 = D2CXX->bases_begin();
2010 Base1 != BaseEnd1; ++Base1, ++Base2) {
2012 Base2->getType())) {
2013 if (Context.Complain) {
2015 Context.getApplicableDiagnostic(
2016 diag::err_odr_tag_type_inconsistent))
2017 << Context.ToCtx.getCanonicalTagType(D2)
2018 << (&Context.FromCtx != &Context.ToCtx);
2019 Context.Diag2(Base2->getBeginLoc(), diag::note_odr_base)
2020 << Base2->getType() << Base2->getSourceRange();
2021 Context.Diag1(Base1->getBeginLoc(), diag::note_odr_base)
2022 << Base1->getType() << Base1->getSourceRange();
2028 if (Base1->isVirtual() != Base2->isVirtual()) {
2029 if (Context.Complain) {
2031 Context.getApplicableDiagnostic(
2032 diag::err_odr_tag_type_inconsistent))
2033 << Context.ToCtx.getCanonicalTagType(D2)
2034 << (&Context.FromCtx != &Context.ToCtx);
2035 Context.Diag2(Base2->getBeginLoc(), diag::note_odr_virtual_base)
2036 << Base2->isVirtual() << Base2->getSourceRange();
2037 Context.Diag1(Base1->getBeginLoc(), diag::note_odr_base)
2038 << Base1->isVirtual() << Base1->getSourceRange();
2046 Friend2End = D2CXX->friend_end();
2048 Friend1End = D1CXX->friend_end();
2049 Friend1 != Friend1End; ++Friend1, ++Friend2) {
2050 if (Friend2 == Friend2End) {
2051 if (Context.Complain) {
2053 Context.getApplicableDiagnostic(
2054 diag::err_odr_tag_type_inconsistent))
2055 << Context.ToCtx.getCanonicalTagType(D2CXX)
2056 << (&Context.FromCtx != &Context.ToCtx);
2057 Context.Diag1((*Friend1)->getFriendLoc(), diag::note_odr_friend);
2058 Context.Diag2(D2->
getLocation(), diag::note_odr_missing_friend);
2064 if (Context.Complain) {
2066 Context.getApplicableDiagnostic(
2067 diag::err_odr_tag_type_inconsistent))
2068 << Context.ToCtx.getCanonicalTagType(D2CXX)
2069 << (&Context.FromCtx != &Context.ToCtx);
2070 Context.Diag1((*Friend1)->getFriendLoc(), diag::note_odr_friend);
2071 Context.Diag2((*Friend2)->getFriendLoc(), diag::note_odr_friend);
2077 if (Friend2 != Friend2End) {
2078 if (Context.Complain) {
2080 Context.getApplicableDiagnostic(
2081 diag::err_odr_tag_type_inconsistent))
2082 << Context.ToCtx.getCanonicalTagType(D2)
2083 << (&Context.FromCtx != &Context.ToCtx);
2084 Context.Diag2((*Friend2)->getFriendLoc(), diag::note_odr_friend);
2085 Context.Diag1(D1->
getLocation(), diag::note_odr_missing_friend);
2089 }
else if (D1CXX->getNumBases() > 0) {
2090 if (Context.Complain) {
2092 Context.getApplicableDiagnostic(
2093 diag::err_odr_tag_type_inconsistent))
2094 << Context.ToCtx.getCanonicalTagType(D2)
2095 << (&Context.FromCtx != &Context.ToCtx);
2097 Context.Diag1(Base1->
getBeginLoc(), diag::note_odr_base)
2099 Context.Diag2(D2->
getLocation(), diag::note_odr_missing_base);
2106 CanQualType D2Type = Context.ToCtx.getCanonicalTagType(D2);
2111 Field1 != Field1End; ++Field1, ++Field2) {
2112 if (Field2 == Field2End) {
2113 if (Context.Complain) {
2115 Context.getApplicableDiagnostic(
2116 diag::err_odr_tag_type_inconsistent))
2117 << Context.ToCtx.getCanonicalTagType(D2)
2118 << (&Context.FromCtx != &Context.ToCtx);
2119 Context.Diag1(Field1->getLocation(), diag::note_odr_field)
2120 << Field1->getDeclName() << Field1->getType();
2121 Context.Diag2(D2->
getLocation(), diag::note_odr_missing_field);
2130 if (Field2 != Field2End) {
2131 if (Context.Complain) {
2132 Context.Diag2(D2->
getLocation(), Context.getApplicableDiagnostic(
2133 diag::err_odr_tag_type_inconsistent))
2134 << Context.ToCtx.getCanonicalTagType(D2)
2135 << (&Context.FromCtx != &Context.ToCtx);
2136 Context.Diag2(Field2->getLocation(), diag::note_odr_field)
2137 << Field2->getDeclName() << Field2->getType();
2138 Context.Diag1(D1->
getLocation(), diag::note_odr_missing_field);
2149 const llvm::APSInt &FromVal = D1->
getInitVal();
2150 const llvm::APSInt &ToVal = D2->
getInitVal();
2151 if (FromVal.isSigned() != ToVal.isSigned())
2153 if (FromVal.getBitWidth() != ToVal.getBitWidth())
2155 if (FromVal != ToVal)
2182 if (Context.LangOpts.C23 &&
2188 if (Context.LangOpts.C23) {
2190 if (Context.Complain) {
2192 Context.getApplicableDiagnostic(
2193 diag::err_odr_tag_type_inconsistent))
2194 << Context.ToCtx.getCanonicalTagType(D2)
2195 << (&Context.FromCtx != &Context.ToCtx);
2198 ? diag::note_odr_fixed_underlying_type
2199 : diag::note_odr_missing_fixed_underlying_type)
2203 ? diag::note_odr_fixed_underlying_type
2204 : diag::note_odr_missing_fixed_underlying_type)
2210 assert(D2->
isFixed() &&
"enums expected to have fixed underlying types");
2213 if (Context.Complain) {
2215 Context.getApplicableDiagnostic(
2216 diag::err_odr_tag_type_inconsistent))
2217 << Context.ToCtx.getCanonicalTagType(D2)
2218 << (&Context.FromCtx != &Context.ToCtx);
2220 diag::note_odr_incompatible_fixed_underlying_type)
2229 auto CopyEnumerators =
2232 Cont.push_back(ECD);
2239 if (Context.LangOpts.C23) {
2241 return LHS->
getName() < RHS->getName();
2243 llvm::sort(D1Enums, Sorter);
2244 llvm::sort(D2Enums, Sorter);
2247 auto EC2 = D2Enums.begin(), EC2End = D2Enums.end();
2248 for (
auto EC1 = D1Enums.begin(), EC1End = D1Enums.end(); EC1 != EC1End;
2250 if (EC2 == EC2End) {
2251 if (Context.Complain) {
2253 Context.getApplicableDiagnostic(
2254 diag::err_odr_tag_type_inconsistent))
2255 << Context.ToCtx.getCanonicalTagType(D2)
2256 << (&Context.FromCtx != &Context.ToCtx);
2257 Context.Diag1((*EC1)->getLocation(), diag::note_odr_enumerator)
2258 << (*EC1)->getDeclName() <<
toString((*EC1)->getInitVal(), 10);
2259 Context.Diag2(D2->
getLocation(), diag::note_odr_missing_enumerator);
2264 llvm::APSInt Val1 = (*EC1)->getInitVal();
2265 llvm::APSInt Val2 = (*EC2)->getInitVal();
2266 if (!llvm::APSInt::isSameValue(Val1, Val2) ||
2268 (*EC2)->getIdentifier())) {
2269 if (Context.Complain) {
2271 Context.getApplicableDiagnostic(
2272 diag::err_odr_tag_type_inconsistent))
2273 << Context.ToCtx.getCanonicalTagType(D2)
2274 << (&Context.FromCtx != &Context.ToCtx);
2275 Context.Diag2((*EC2)->getLocation(), diag::note_odr_enumerator)
2276 << (*EC2)->getDeclName() <<
toString((*EC2)->getInitVal(), 10);
2277 Context.Diag1((*EC1)->getLocation(), diag::note_odr_enumerator)
2278 << (*EC1)->getDeclName() <<
toString((*EC1)->getInitVal(), 10);
2282 if (Context.LangOpts.C23 &&
2287 if (EC2 != EC2End) {
2288 if (Context.Complain) {
2289 Context.Diag2(D2->
getLocation(), Context.getApplicableDiagnostic(
2290 diag::err_odr_tag_type_inconsistent))
2291 << Context.ToCtx.getCanonicalTagType(D2)
2292 << (&Context.FromCtx != &Context.ToCtx);
2293 Context.Diag2((*EC2)->getLocation(), diag::note_odr_enumerator)
2294 << (*EC2)->getDeclName() <<
toString((*EC2)->getInitVal(), 10);
2295 Context.Diag1(D1->
getLocation(), diag::note_odr_missing_enumerator);
2306 if (Params1->
size() != Params2->
size()) {
2307 if (Context.Complain) {
2309 Context.getApplicableDiagnostic(
2310 diag::err_odr_different_num_template_parameters))
2311 << Params1->
size() << Params2->
size();
2313 diag::note_odr_template_parameter_list);
2318 for (
unsigned I = 0, N = Params1->
size(); I != N; ++I) {
2320 if (Context.Complain) {
2322 Context.getApplicableDiagnostic(
2323 diag::err_odr_different_template_parameter_kind));
2325 diag::note_odr_template_parameter_here);
2343 if (Context.Complain) {
2345 Context.getApplicableDiagnostic(
2346 diag::err_odr_parameter_pack_non_pack))
2348 Context.Diag1(D1->
getLocation(), diag::note_odr_parameter_pack_non_pack)
2361 if (Context.Complain) {
2363 Context.getApplicableDiagnostic(
2364 diag::err_odr_parameter_pack_non_pack))
2366 Context.Diag1(D1->
getLocation(), diag::note_odr_parameter_pack_non_pack)
2377 if (Context.Complain) {
2379 Context.getApplicableDiagnostic(
2380 diag::err_odr_non_type_parameter_type_inconsistent))
2382 Context.Diag1(D1->
getLocation(), diag::note_odr_value_here)
2395 if (Context.Complain) {
2397 Context.getApplicableDiagnostic(
2398 diag::err_odr_parameter_pack_non_pack))
2400 Context.Diag1(D1->
getLocation(), diag::note_odr_parameter_pack_non_pack)
2527 llvm_unreachable(
"unknown friend template kind");
2578 bool PropertiesEqual =
2582 if (!PropertiesEqual)
2589 if (NumArgs != Selector2.getNumArgs())
2593 unsigned SlotsToCheck = NumArgs > 0 ? NumArgs : 1;
2594 for (
unsigned I = 0; I < SlotsToCheck; ++I) {
2596 Selector2.getIdentifierInfoForSlot(I)))
2606 "Same number of arguments should be already enforced in Selector checks");
2612 (ParamT1 != ParamT1End) && (ParamT2 != ParamT2End);
2613 ++ParamT1, ++ParamT2) {
2629 if ((!Intf1 || !Intf2) && (Intf1 != Intf2))
2641 Protocol1 != Protocol1End; ++Protocol1, ++Protocol2) {
2642 if (Protocol2 == Protocol2End)
2645 (*Protocol2)->getIdentifier()))
2648 if (Protocol2 != Protocol2End)
2653 Intf2 ? Context.ToCtx.getObjCInterfaceType(Intf2) :
QualType();
2658 Ivar1 != Ivar1End; ++Ivar1, ++Ivar2) {
2659 if (Ivar2 == Ivar2End)
2664 if (Ivar2 != Ivar2End)
2672 Method1 != Method1End; ++Method1, ++Method2) {
2673 if (Method2 == Method2End)
2678 if (Method2 != Method2End)
2695 std::pair<Decl *, Decl *> P{D1, D2};
2699 if (Context.NonEquivalentDecls.count(
2700 std::make_tuple(D1, D2, Context.IgnoreTemplateParmDepth)))
2706 bool Inserted = Context.VisitedDecls.insert(P).second;
2710 Context.DeclsToCheck.push(P);
2717 assert(
Complain &&
"Not allowed to complain");
2719 FromCtx.getDiagnostics().notePriorDiagnosticFrom(
ToCtx.getDiagnostics());
2721 return FromCtx.getDiagnostics().Report(Loc, DiagID);
2726 assert(
Complain &&
"Not allowed to complain");
2728 ToCtx.getDiagnostics().notePriorDiagnosticFrom(
FromCtx.getDiagnostics());
2730 return ToCtx.getDiagnostics().Report(Loc, DiagID);
2736 CanQualType AnonTy = Context.getCanonicalTagType(Anon);
2738 const auto *Owner = dyn_cast<RecordDecl>(Anon->
getDeclContext());
2740 return std::nullopt;
2743 for (
const auto *D : Owner->noload_decls()) {
2744 const auto *F = dyn_cast<FieldDecl>(D);
2748 if (F->isAnonymousStructOrUnion()) {
2749 if (Context.hasSameType(F->getType(), AnonTy))
2758 if (
const auto *RecType = dyn_cast<RecordType>(FieldType)) {
2759 const RecordDecl *RecDecl = RecType->getDecl();
2761 if (Context.hasSameType(FieldType, AnonTy))
2773 unsigned ErrorDiagnostic) {
2775 return ErrorDiagnostic;
2777 switch (ErrorDiagnostic) {
2778 case diag::err_odr_variable_type_inconsistent:
2779 return diag::warn_odr_variable_type_inconsistent;
2780 case diag::err_odr_variable_multiple_def:
2781 return diag::warn_odr_variable_multiple_def;
2782 case diag::err_odr_function_type_inconsistent:
2783 return diag::warn_odr_function_type_inconsistent;
2784 case diag::err_odr_tag_type_inconsistent:
2785 return diag::warn_odr_tag_type_inconsistent;
2786 case diag::err_odr_field_type_inconsistent:
2787 return diag::warn_odr_field_type_inconsistent;
2788 case diag::err_odr_ivar_type_inconsistent:
2789 return diag::warn_odr_ivar_type_inconsistent;
2790 case diag::err_odr_objc_superclass_inconsistent:
2791 return diag::warn_odr_objc_superclass_inconsistent;
2792 case diag::err_odr_objc_method_result_type_inconsistent:
2793 return diag::warn_odr_objc_method_result_type_inconsistent;
2794 case diag::err_odr_objc_method_num_params_inconsistent:
2795 return diag::warn_odr_objc_method_num_params_inconsistent;
2796 case diag::err_odr_objc_method_param_type_inconsistent:
2797 return diag::warn_odr_objc_method_param_type_inconsistent;
2798 case diag::err_odr_objc_method_variadic_inconsistent:
2799 return diag::warn_odr_objc_method_variadic_inconsistent;
2800 case diag::err_odr_objc_property_type_inconsistent:
2801 return diag::warn_odr_objc_property_type_inconsistent;
2802 case diag::err_odr_objc_property_impl_kind_inconsistent:
2803 return diag::warn_odr_objc_property_impl_kind_inconsistent;
2804 case diag::err_odr_objc_synthesize_ivar_inconsistent:
2805 return diag::warn_odr_objc_synthesize_ivar_inconsistent;
2806 case diag::err_odr_different_num_template_parameters:
2807 return diag::warn_odr_different_num_template_parameters;
2808 case diag::err_odr_different_template_parameter_kind:
2809 return diag::warn_odr_different_template_parameter_kind;
2810 case diag::err_odr_parameter_pack_non_pack:
2811 return diag::warn_odr_parameter_pack_non_pack;
2812 case diag::err_odr_non_type_parameter_type_inconsistent:
2813 return diag::warn_odr_non_type_parameter_type_inconsistent;
2815 llvm_unreachable(
"Diagnostic kind not handled in preceding switch");
2855bool StructuralEquivalenceContext::CheckCommonEquivalence(
Decl *D1,
Decl *D2) {
2859 if ((Template1 !=
nullptr) != (Template2 !=
nullptr))
2869bool StructuralEquivalenceContext::CheckKindSpecificEquivalence(
2879#define ABSTRACT_DECL(DECL)
2880#define DECL(DERIVED, BASE) \
2881 case Decl::Kind::DERIVED: \
2882 return ::IsStructurallyEquivalent(*this, static_cast<DERIVED##Decl *>(D1), \
2883 static_cast<DERIVED##Decl *>(D2));
2884#include "clang/AST/DeclNodes.inc"
2896 Decl *D2 = P.second;
2899 CheckCommonEquivalence(D1, D2) && CheckKindSpecificEquivalence(D1, D2);
2914bool StructuralEquivalenceContext::Finish() {
return checkDeclQueue(); }
Defines the clang::ASTContext interface.
static bool IsTemplateDeclCommonStructurallyEquivalent(StructuralEquivalenceContext &Ctx, TemplateDecl *D1, TemplateDecl *D2)
static bool CheckStructurallyEquivalentAttributes(StructuralEquivalenceContext &Context, const Decl *D1, const Decl *D2, const Decl *PrimaryDecl=nullptr)
static AttrComparisonResult areDeclAttrsEquivalent(const Decl *D1, const Decl *D2, StructuralEquivalenceContext &Context)
Determines whether D1 and D2 have compatible sets of attributes for the purposes of structural equiva...
static bool IsStructurallyEquivalentLambdas(StructuralEquivalenceContext &Context, CXXRecordDecl *D1, CXXRecordDecl *D2)
Determine structural equivalence of two lambda classes.
static bool NameIsStructurallyEquivalent(const TagDecl &D1, const TagDecl &D2)
static bool IsRecordContextStructurallyEquivalent(StructuralEquivalenceContext &Context, RecordDecl *D1, RecordDecl *D2)
Determine if context of a class is equivalent.
static bool IsEquivalentExceptionSpec(StructuralEquivalenceContext &Context, const FunctionProtoType *Proto1, const FunctionProtoType *Proto2)
Check the equivalence of exception specifications.
static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context, QualType T1, QualType T2)
static bool IsArrayStructurallyEquivalent(StructuralEquivalenceContext &Context, const ArrayType *Array1, const ArrayType *Array2)
Determine structural equivalence for the common part of array types.
static Decl::Kind getKind(const Decl *D)
Defines the C++ Decl subclasses, other than those for templates (found in DeclTemplate....
This file defines OpenACC nodes for declarative directives.
This file defines OpenMP nodes for declarative directives.
Defines the C++ template declaration subclasses.
Defines the ExceptionSpecificationType enumeration and various utility functions.
Defines the clang::Expr interface and subclasses for C++ expressions.
Defines Expressions and AST nodes for C++2a concepts.
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
static DiagnosticBuilder Diag(DiagnosticsEngine *Diags, const LangOptions &Features, FullSourceLoc TokLoc, const char *TokBegin, const char *TokRangeBegin, const char *TokRangeEnd, unsigned DiagID)
Produce a diagnostic highlighting some portion of a literal.
static QualType getUnderlyingType(const SubRegion *R)
static std::string toString(const clang::SanitizerSet &Sanitizers)
Produce a string containing comma-separated names of sanitizers in Sanitizers set.
Defines the clang::SourceLocation class and associated facilities.
Defines the Objective-C statement AST node classes.
This file defines OpenACC AST classes for statement-level contructs.
This file defines OpenMP AST classes for executable directives and clauses.
This file defines SYCL AST classes used to represent calls to SYCL kernels.
static QualType getPointeeType(const MemRegion *R)
C Language Family Type Representation.
llvm::APInt getValue() const
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
LabelDecl * getLabel() const
Represents an array type, per C99 6.7.5.2 - Array Declarators.
ArraySizeModifier getSizeModifier() const
Qualifiers getIndexTypeQualifiers() const
QualType getElementType() const
A structure for storing the information associated with a name that has been assumed to be a template...
DeclarationName getDeclName() const
Get the name of the template.
Attr - This represents one attribute.
A builtin binary operation expression such as "x + y" or "x <= y".
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given binary opcode.
Represents a base class of a C++ class.
SourceLocation getBeginLoc() const LLVM_READONLY
QualType getType() const
Retrieves the type of the base class.
SourceRange getSourceRange() const LLVM_READONLY
Retrieves the source range that contains the entire base specifier.
QualType getBaseType() const
DeclarationName getMember() const
Retrieve the name of the member that this expression refers to.
Represents a static or instance method of a struct/union/class.
bool isImplicitObjectMemberFunction() const
[C++2b][dcl.fct]/p7 An implicit object member function is a non-static member function without an exp...
RefQualifierKind getRefQualifier() const
Retrieve the ref-qualifier associated with this method.
A call to an overloaded operator written using operator syntax.
OverloadedOperatorKind getOperator() const
Returns the kind of overloaded operator that this expression refers to.
An iterator over the friend declarations of a class.
Represents a C++ struct/union/class.
CXXBaseSpecifier * base_class_iterator
Iterator that traverses the base classes of a class.
bool isLambda() const
Determine whether this class describes a lambda function object.
CXXMethodDecl * getLambdaCallOperator() const
Retrieve the lambda call operator of the closure type if this is a closure type.
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
unsigned getValue() const
CharacterLiteralKind getKind() const
Declaration of a class template.
CXXRecordDecl * getTemplatedDecl() const
Get the underlying class declarations of the template.
Declaration of a C++20 concept.
Expr * getConstraintExpr() const
Represents a concrete matrix type with constant number of rows and columns.
unsigned getNumColumns() const
Returns the number of columns in the matrix.
unsigned getNumRows() const
Returns the number of rows in the matrix.
Represents an opaque OpenCL cooperative matrix type.
unsigned getScope() const
Returns the cooperative matrix scope.
unsigned getNumColumns() const
Returns the number of columns.
unsigned getUse() const
Returns the cooperative matrix use.
QualType getElementType() const
Returns the element type.
unsigned getNumRows() const
Returns the number of rows.
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
DeclContext * getParent()
getParent - Returns the containing DeclContext.
bool isTranslationUnit() const
bool hasExternalLexicalStorage() const
Whether this DeclContext has external storage containing additional declarations that are lexically i...
bool isInlineNamespace() const
bool isFunctionOrMethod() const
Returns true if this DeclContext is a function, Objective-C method, or block, or a DeclContext that c...
Decl::Kind getDeclKind() const
DeclContext * getNonTransparentContext()
Decl - This represents one declaration (or definition), e.g.
TemplateDecl * getDescribedTemplate() const
If this is a declaration that describes some template, this method returns that template declaration.
ASTContext & getASTContext() const LLVM_READONLY
bool isImplicit() const
isImplicit - Indicates whether the declaration was implicitly generated by the implementation.
SourceLocation getLocation() const
DeclContext * getDeclContext()
AccessSpecifier getAccess() const
virtual Decl * getCanonicalDecl()
Retrieves the "canonical" declaration of the given declaration.
The name of a declaration.
IdentifierInfo * getAsIdentifierInfo() const
Retrieve the IdentifierInfo * stored in this declaration name, or null if this declaration name isn't...
TemplateDecl * getCXXDeductionGuideTemplate() const
If this name is the name of a C++ deduction guide, return the template associated with that name.
const IdentifierInfo * getCXXLiteralIdentifier() const
If this name is the name of a literal operator, retrieve the identifier associated with it.
OverloadedOperatorKind getCXXOverloadedOperator() const
If this name is the name of an overloadable operator in C++ (e.g., operator+), retrieve the kind of o...
@ CXXConversionFunctionName
QualType getCXXNameType() const
If this name is one of the C++ names (of a constructor, destructor, or conversion function),...
NameKind getNameKind() const
Determine what kind of name this is.
NestedNameSpecifier getQualifier() const
Retrieve the nested-name-specifier that qualifies this declaration.
DeclarationName getDeclName() const
Retrieve the name that this expression refers to.
Represents a matrix type where the type and the number of rows and columns is dependent on a template...
Expr * getColumnExpr() const
Expr * getRowExpr() const
Represents a dependent template name that cannot be resolved prior to template instantiation.
IdentifierOrOverloadedOperator getName() const
NestedNameSpecifier getQualifier() const
Return the nested name specifier that qualifies this name.
A little helper class used to produce diagnostics.
An instance of this object exists for each enum constant that is defined.
llvm::APSInt getInitVal() const
const Expr * getInitExpr() const
enumerator_range enumerators() const
bool isFixed() const
Returns true if this is an Objective-C, C++11, or Microsoft-style enumeration with a fixed underlying...
QualType getIntegerType() const
Return the integer type this enum decl corresponds to.
EnumDecl * getDefinition() const
ExpressionTrait getTrait() const
Represents a member of a struct/union/class.
bool isBitField() const
Determines whether this field is a bitfield.
unsigned getBitWidthValue() const
Computes the bit width of this field, if this is a bit field.
bool isAnonymousStructOrUnion() const
Determines whether this field is a representative for an anonymous struct or union.
Expr * getBitWidth() const
Returns the expression that represents the bit width, if this field is a bit field.
llvm::APFloat getValue() const
FriendDecl - Represents the declaration of a friend entity, which can be a function,...
virtual NamedDecl * getFriendDecl() const
If this friend declaration doesn't name a type, return the inner declaration.
TypeSourceInfo * getFriendType() const
If this friend declaration names an (untemplated but possibly dependent) type, return the type; other...
bool isPackExpansion() const
Declaration of a friend template.
TemplateName getFriendTemplateName() const
FriendTemplateEntityKind getFriendKind() const
ArrayRef< TemplateParameterList * > getTemplateParameterLists() const
Represents a function declaration or definition.
bool isDeleted() const
Whether this function has been deleted.
bool isPureVirtual() const
Whether this virtual function is pure, i.e.
bool isDefaulted() const
Whether this function is defaulted.
bool isOverloadedOperator() const
Whether this function declaration represents an C++ overloaded operator, e.g., "operator+".
OverloadedOperatorKind getOverloadedOperator() const
getOverloadedOperator - Which C++ overloaded operator this function represents, if any.
Represents a prototype with parameter type info, e.g.
ExceptionSpecificationType getExceptionSpecType() const
Get the kind of exception specification on this function.
QualType getExceptionType(unsigned i) const
Return the ith exception type, where 0 <= i < getNumExceptions().
unsigned getNumExceptions() const
Return the number of types in the exception specification.
Expr * getNoexceptExpr() const
Return the expression inside noexcept(expression), or a null pointer if there is none (because the ex...
Declaration of a template function.
FunctionDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
A class which abstracts out some details necessary for making a call.
CallingConv getCC() const
bool getNoCfCheck() const
unsigned getRegParm() const
bool getNoCallerSavedRegs() const
bool getHasRegParm() const
bool getProducesResult() const
ArrayRef< TypeSourceInfo * > getAssocTypeSourceInfos() const
LabelDecl * getLabel() const
One of these records is kept for each identifier that is lexed.
StringRef getName() const
Return the actual identifier string.
Represents a field injected from an anonymous union/struct into the parent scope.
FieldDecl * getAnonField() const
QualType getElementType() const
Returns type of the elements being stored in the matrix.
DeclAccessPair getFoundDecl() const
Retrieves the declaration found by lookup.
IdentifierInfo * getIdentifier() const
Get the identifier that names this declaration, if there is one.
StringRef getName() const
Get the name of identifier for this declaration as a StringRef.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
std::string getNameAsString() const
Get a human-readable name for the declaration, even if it is one of the special kinds of names (C++ c...
Represents C++ namespaces and their aliases.
Represents a C++ nested name specifier, such as "\::std::vector<int>::".
CXXRecordDecl * getAsMicrosoftSuper() const
NamespaceAndPrefix getAsNamespaceAndPrefix() const
const Type * getAsType() const
@ MicrosoftSuper
Microsoft's '__super' specifier, stored as a CXXRecordDecl* of the class it appeared in.
@ Global
The global specifier '::'. There is no stored value.
@ Type
A type, stored as a Type*.
@ Namespace
A namespace-like entity, stored as a NamespaceBaseDecl*.
NonTypeTemplateParmDecl - Declares a non-type template parameter, e.g., "Size" in.
bool isParameterPack() const
Whether this parameter is a non-type template parameter pack.
unsigned getIndex() const
Get the index of the template parameter within its parameter list.
unsigned getDepth() const
Get the nesting depth of the template parameter.
ObjCCategoryDecl - Represents a category declaration.
ivar_iterator ivar_begin() const
ivar_iterator ivar_end() const
ObjCInterfaceDecl * getClassInterface()
specific_decl_iterator< ObjCIvarDecl > ivar_iterator
protocol_iterator protocol_end() const
protocol_iterator protocol_begin() const
ObjCProtocolList::iterator protocol_iterator
method_iterator meth_begin() const
specific_decl_iterator< ObjCMethodDecl > method_iterator
method_iterator meth_end() const
Represents an ObjC class declaration.
ObjCIvarDecl - Represents an ObjC instance variable.
AccessControl getAccessControl() const
ObjCInterfaceDecl * getContainingInterface()
Return the class interface that this ivar is logically contained in; this is either the interface whe...
ObjCMethodDecl - Represents an instance or class method declaration.
unsigned param_size() const
param_type_iterator param_type_begin() const
param_type_iterator param_type_end() const
bool isDirectMethod() const
True if the method is tagged as objc_direct.
Selector getSelector() const
bool isInstanceMethod() const
llvm::mapped_iterator< param_const_iterator, GetTypeFn > param_type_iterator
QualType getReturnType() const
NestedNameSpecifier getQualifier() const
Fetches the nested-name qualifier, if one was given.
TemplateArgumentLoc const * getTemplateArgs() const
unsigned getNumTemplateArgs() const
DeclarationName getName() const
Gets the name looked up.
A structure for storing the information associated with an overloaded template name.
NamedDecl *const * iterator
A structure for storing a pack-index-template-name ([temp.names]).
TemplateName getPattern() const
Expr * getIndexExpr() const
A (possibly-)qualified type.
QualType getDesugaredType(const ASTContext &Context) const
Return the specified type with any "sugar" removed from the type.
bool isNull() const
Return true if this QualType doesn't point to a type yet.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
QualType getCanonicalType() const
Represents a struct/union/class.
field_iterator field_end() const
RecordDecl * getDefinition() const
Returns the RecordDecl that actually defines this struct/union/class.
specific_decl_iterator< FieldDecl > field_iterator
field_iterator field_begin() const
Smart pointer class that efficiently represents Objective-C method names.
const IdentifierInfo * getIdentifierInfoForSlot(unsigned argIndex) const
Retrieve the identifier at a given position in the selector.
unsigned getNumArgs() const
SourceLocIdentKind getIdentKind() const
Encodes a location in the source.
unsigned getTemplateDepth() const
Stmt - This represents one statement.
StmtClass getStmtClass() const
StringRef getBytes() const
Allow access to clients that need the byte representation, such as ASTWriterStmt::VisitStringLiteral(...
Decl * getAssociatedDecl() const
A template-like entity which owns the whole pattern being substituted.
UnsignedOrNone getPackIndex() const
unsigned getIndex() const
Returns the index of the replaced parameter in the associated declaration.
TemplateArgument getArgumentPack() const
Retrieve the template argument pack containing the substituted template arguments.
A structure for storing an already-substituted template template parameter pack.
Decl * getAssociatedDecl() const
A template-like entity which owns the whole pattern being substituted.
TemplateArgument getArgumentPack() const
Retrieve the template template argument pack with which this parameter was substituted.
unsigned getIndex() const
Returns the index of the replaced parameter in the associated declaration.
Represents the declaration of a struct/union/class/enum.
bool isBeingDefined() const
Return true if this decl is currently being defined.
TagKind getTagKind() const
Location wrapper for a TemplateArgument.
const TemplateArgument & getArgument() const
Represents a template argument.
Expr * getAsExpr() const
Retrieve the template argument as an expression.
QualType getAsType() const
Retrieve the type for a type template argument.
llvm::APSInt getAsIntegral() const
Retrieve the template argument as an integral value.
TemplateName getAsTemplate() const
Retrieve the template name for a template name argument.
bool structurallyEquals(const TemplateArgument &Other) const
Determines whether two template arguments are superficially the same.
QualType getIntegralType() const
Retrieve the type of the integral value.
ValueDecl * getAsDecl() const
Retrieve the declaration for a declaration non-type template argument.
ArrayRef< TemplateArgument > pack_elements() const
Iterator range referencing all of the elements of a template argument pack.
@ Declaration
The template argument is a declaration that was provided for a pointer, reference,...
@ Template
The template argument is a template name that was provided for a template template parameter.
@ StructuralValue
The template argument is a non-type template argument that can't be represented by the special-case D...
@ Pack
The template argument is actually a parameter pack.
@ TemplateExpansion
The template argument is a pack expansion of a template name that was provided for a template templat...
@ NullPtr
The template argument is a null pointer or null pointer to member that was provided for a non-type te...
@ Type
The template argument is a type.
@ Null
Represents an empty template argument, e.g., one that has not been deduced.
@ Integral
The template argument is an integral value stored in an llvm::APSInt that was provided for an integra...
@ Expression
The template argument is an expression, and we've not resolved it to one of the other forms yet,...
ArgKind getKind() const
Return the kind of stored template argument.
TemplateName getAsTemplateOrTemplatePattern() const
Retrieve the template argument as a template name; if the argument is a pack expansion,...
The base class of all kinds of template declarations (e.g., class, function, etc.).
TemplateParameterList * getTemplateParameters() const
Get the list of template parameters.
Represents a C++ template name within the type system.
TemplateDecl * getAsTemplateDecl(bool IgnoreDeduced=false) const
Retrieve the underlying template declaration that this template name refers to, if known.
bool isNull() const
Determine whether this template name is NULL.
DependentTemplateName * getAsDependentTemplateName() const
Retrieve the underlying dependent template name structure, if any.
OverloadedTemplateStorage * getAsOverloadedTemplate() const
Retrieve the underlying, overloaded function template declarations that this template name refers to,...
AssumedTemplateStorage * getAsAssumedTemplateName() const
Retrieve information on a name that has been assumed to be a template-name in order to permit a call ...
@ UsingTemplate
A template name that refers to a template declaration found through a specific using shadow declarati...
@ OverloadedTemplate
A set of overloaded template declarations.
@ PackIndexingTemplate
A pack-index-template-name.
@ Template
A single template declaration.
@ DependentTemplate
A dependent template name that has not been resolved to a template (or set of templates).
@ SubstTemplateTemplateParm
A template template parameter that has been substituted for some other template name.
@ SubstTemplateTemplateParmPack
A template template parameter pack that has been substituted for a template template argument pack,...
@ DeducedTemplate
A template name that refers to another TemplateName with deduced default arguments.
@ QualifiedTemplate
A qualified template name, where the qualification is kept to describe the source code as written.
@ AssumedTemplate
An unqualified-id that has been assumed to name a function template that will be found by ADL.
SubstTemplateTemplateParmPackStorage * getAsSubstTemplateTemplateParmPack() const
Retrieve the substituted template template parameter pack, if known.
PackIndexingTemplateStorage * getAsPackIndexingTemplate() const
Retrieve the pack-index-template-name storage, if any.
Stores a list of template parameters for a TemplateDecl and its derived classes.
NamedDecl * getParam(unsigned Idx)
Expr * getRequiresClause()
The constraint-expression of the associated requires-clause.
SourceLocation getTemplateLoc() const
TemplateTemplateParmDecl - Declares a template template parameter, e.g., "T" in.
TemplateNameKind templateParameterKind() const
bool isParameterPack() const
Whether this template template parameter is a template parameter pack.
Declaration of a template type parameter.
bool isParameterPack() const
Returns whether this is a parameter pack.
Declaration of an alias template.
TypeAliasDecl * getTemplatedDecl() const
Get the underlying function declaration of the template.
QualType getType() const
Return the type wrapped by this type source info.
ArrayRef< TypeSourceInfo * > getArgs() const
Retrieve the argument types.
TypeTrait getTrait() const
Determine which type trait this expression uses.
const T * castAs() const
Member-template castAs<specific type>.
bool isEnumeralType() const
bool isBuiltinType() const
Helper methods to distinguish type categories.
TypeClass getTypeClass() const
Base class for declarations which introduce a typedef-name.
QualType getUnderlyingType() const
QualType getTypeOfArgument() const
Gets the argument type, or the type of the argument expression, whichever is appropriate.
UnaryExprOrTypeTrait getKind() const
UnaryOperator - This represents the unary-expression's (except sizeof and alignof),...
Expr * getSubExpr() const
static OverloadedOperatorKind getOverloadedOperator(Opcode Opc)
Retrieve the overloaded operator kind that corresponds to the given unary opcode.
Represents a variable declaration or definition.
DefinitionKind isThisDeclarationADefinition(ASTContext &) const
Check whether this declaration is a definition.
const Expr * getInit() const
StorageClass getStorageClass() const
Returns the storage class as written in the source.
bool isEquivalent(StructuralEquivalenceContext &Context, QualType T1, QualType T2)
Determine structural equivalence of two types.
std::variant< struct RequiresDecl, struct HeaderDecl, struct UmbrellaDirDecl, struct ModuleDecl, struct ExcludeDecl, struct ExportDecl, struct ExportAsDecl, struct ExternModuleDecl, struct UseDecl, struct LinkDecl, struct ConfigMacrosDecl, struct ConflictDecl > Decl
All declarations that can appear in a module declaration.
Top level wrappers for InstallAPI frontend operations.
CanQual< Type > CanQualType
Represents a canonical, potentially-qualified type.
bool isUnresolvedExceptionSpec(ExceptionSpecificationType ESpecType)
OptionalUnsigned< unsigned > UnsignedOrNone
bool isComputedNoexcept(ExceptionSpecificationType ESpecType)
U cast(CodeGen::Address addr)
@ EST_Dynamic
throw(T1, T2)
__builtin_elementwise_add_sat __builtin_elementwise_sub_sat uint32_t uint64_t __builtin_riscv_ssha_i32 __builtin_riscv_sshl_u32 unsigned
const IdentifierInfo * getIdentifier() const
Returns the identifier to which this template name refers.
OverloadedOperatorKind getOperator() const
Return the overloaded operator to which this template name refers.
RAII helper that is used to suppress diagnostics during attribute equivalence checking.
ASTContext & FromCtx
AST contexts for which we are checking structural equivalence.
bool LastDiagFromC2
true if the last diagnostic came from ToCtx.
bool checkDeclQueue()
Iterate over the decl pairs in DeclsToCheck until either an inequivalent pair is found or the queue i...
std::queue< std::pair< Decl *, Decl * > > DeclsToCheck
llvm::DenseSet< std::pair< Decl *, Decl * > > VisitedDecls
static UnsignedOrNone findUntaggedStructOrUnionIndex(RecordDecl *Anon)
Find the index of the given anonymous struct/union within its context.
bool IgnoreTemplateParmDepth
Whether to ignore comparing the depth of template param(TemplateTypeParm)
bool ErrorOnTagTypeMismatch
Whether warn or error on tag type mismatches.
NonEquivalentDeclSet & NonEquivalentDecls
Declaration (from, to) pairs that are known not to be equivalent (which we have already complained ab...
bool Complain
Whether to complain about failures.
DiagnosticBuilder Diag2(SourceLocation Loc, unsigned DiagID)
unsigned getApplicableDiagnostic(unsigned ErrorDiagnostic)
DiagnosticBuilder Diag1(SourceLocation Loc, unsigned DiagID)
bool IsEquivalent(Decl *D1, Decl *D2)
Determine whether the two declarations are structurally equivalent.