Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ class FindEnumMember : public TypeVisitor<FindEnumMember, bool> {
return Visit(T->getElementType().getTypePtr());
}
bool VisitEnumType(const EnumType *T) {
if (isCompleteAndHasNoZeroValue(T->getOriginalDecl())) {
if (isCompleteAndHasNoZeroValue(T->getDecl())) {
FoundEnum = T;
return true;
}
return false;
}
bool VisitRecordType(const RecordType *T) {
const RecordDecl *RD = T->getOriginalDecl()->getDefinition();
const RecordDecl *RD = T->getDecl()->getDefinition();
if (!RD || RD->isUnion())
return false;
auto VisitField = [this](const FieldDecl *F) {
Expand Down Expand Up @@ -139,7 +139,7 @@ void InvalidEnumDefaultInitializationCheck::check(
if (!Finder.Visit(InitList->getArrayFiller()->getType().getTypePtr()))
return;
InitExpr = InitList;
Enum = Finder.FoundEnum->getOriginalDecl();
Enum = Finder.FoundEnum->getDecl();
}

if (!InitExpr || !Enum)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ struct InitializerInsertion {
// Convenience utility to get a RecordDecl from a QualType.
const RecordDecl *getCanonicalRecordDecl(const QualType &Type) {
if (const auto *RT = Type->getAsCanonical<RecordType>())
return RT->getOriginalDecl();
return RT->getDecl();
return nullptr;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ static bool isStdInitializerList(QualType Type) {
}
if (const auto *RT = Type->getAs<RecordType>()) {
if (const auto *Specialization =
dyn_cast<ClassTemplateSpecializationDecl>(RT->getOriginalDecl()))
dyn_cast<ClassTemplateSpecializationDecl>(RT->getDecl()))
return declIsStdInitializerList(Specialization->getSpecializedTemplate());
}
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) {
}
if (const auto *ECD = dyn_cast<EnumConstantDecl>(Used)) {
if (const auto *ET = ECD->getType()->getAsCanonical<EnumType>())
removeFromFoundDecls(ET->getOriginalDecl());
removeFromFoundDecls(ET->getDecl());
}
};
// We rely on the fact that the clang AST is walked in order, usages are only
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ static bool isLockGuardDecl(const NamedDecl *Decl) {

static bool isLockGuard(const QualType &Type) {
if (const auto *Record = Type->getAsCanonical<RecordType>())
if (const RecordDecl *Decl = Record->getOriginalDecl())
if (const RecordDecl *Decl = Record->getDecl())
return isLockGuardDecl(Decl);

if (const auto *TemplateSpecType = Type->getAs<TemplateSpecializationType>())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ struct UnqualNameVisitor : public RecursiveASTVisitor<UnqualNameVisitor> {
if (T->getKeyword() != ElaboratedTypeKeyword::None ||
TTL.getQualifierLoc())
break;
if (visitUnqualName(T->getOriginalDecl()->getName()))
if (visitUnqualName(T->getDecl()->getName()))
return false;
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,11 +413,10 @@ static bool areTypesCompatible(QualType ArgType, QualType ParamType,

// Arithmetic types are interconvertible, except scoped enums.
if (ParamType->isArithmeticType() && ArgType->isArithmeticType()) {
if ((ParamType->isEnumeralType() && ParamType->castAsCanonical<EnumType>()
->getOriginalDecl()
->isScoped()) ||
if ((ParamType->isEnumeralType() &&
ParamType->castAsCanonical<EnumType>()->getDecl()->isScoped()) ||
(ArgType->isEnumeralType() &&
ArgType->castAsCanonical<EnumType>()->getOriginalDecl()->isScoped()))
ArgType->castAsCanonical<EnumType>()->getDecl()->isScoped()))
return false;

return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ class RenamerClangTidyVisitor
}

bool VisitTagTypeLoc(const TagTypeLoc &Loc) {
Check->addUsage(Loc.getOriginalDecl(), Loc.getNameLoc(), SM);
Check->addUsage(Loc.getDecl(), Loc.getNameLoc(), SM);
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clangd/DumpAST.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ class DumpVisitor : public RecursiveASTVisitor<DumpVisitor> {
return TL.getType().getLocalQualifiers().getAsString(
Ctx.getPrintingPolicy());
if (const auto *TT = dyn_cast<TagType>(TL.getTypePtr()))
return getDetail(TT->getOriginalDecl());
return getDetail(TT->getDecl());
if (const auto *DT = dyn_cast<DeducedType>(TL.getTypePtr()))
if (DT->isDeduced())
return DT->getDeducedType().getAsString(Ctx.getPrintingPolicy());
Expand Down
4 changes: 2 additions & 2 deletions clang-tools-extra/clangd/FindTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ struct TargetFinder {
Visitor(TargetFinder &Outer, RelSet Flags) : Outer(Outer), Flags(Flags) {}

void VisitTagType(const TagType *TT) {
Outer.add(cast<TagType>(TT)->getOriginalDecl(), Flags);
Outer.add(cast<TagType>(TT)->getDecl(), Flags);
}

void VisitUsingType(const UsingType *ET) {
Expand Down Expand Up @@ -861,7 +861,7 @@ refInTypeLoc(TypeLoc L, const HeuristicResolver *Resolver) {
Refs.push_back(ReferenceLoc{L.getQualifierLoc(),
L.getNameLoc(),
/*IsDecl=*/false,
{L.getOriginalDecl()}});
{L.getDecl()}});
}

void VisitTemplateTypeParmTypeLoc(TemplateTypeParmTypeLoc L) {
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clangd/Hover.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ HoverInfo::PrintedType printType(QualType QT, ASTContext &ASTCtx,
if (!QT.isNull() && !QT.hasQualifiers() && PP.SuppressTagKeyword) {
if (auto *TT = llvm::dyn_cast<TagType>(QT.getTypePtr());
TT && TT->isCanonicalUnqualified())
OS << TT->getOriginalDecl()->getKindName() << " ";
OS << TT->getDecl()->getKindName() << " ";
}
QT.print(OS, PP);

Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clangd/IncludeFixer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ std::vector<Fix> IncludeFixer::fix(DiagnosticsEngine::Level DiagLevel,
// `enum x : int;' is not formally an incomplete type.
// We may need a full definition anyway.
if (auto * ET = llvm::dyn_cast<EnumType>(T))
if (!ET->getOriginalDecl()->getDefinition())
if (!ET->getDecl()->getDefinition())
return fixIncompleteType(*T);
}
}
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clangd/InlayHints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const NamedDecl *getDeclForType(const Type *T) {
case Type::Enum:
case Type::Record:
case Type::InjectedClassName:
return cast<TagType>(T)->getOriginalDecl();
return cast<TagType>(T)->getDecl();
case Type::TemplateSpecialization:
return cast<TemplateSpecializationType>(T)
->getTemplateName()
Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ bool AddUsing::prepare(const Selection &Inputs) {
if (!QualifierToRemove)
break;
SpelledNameRange = TL.getNameLoc();
MustInsertAfterLoc = TL.getOriginalDecl()->getBeginLoc();
MustInsertAfterLoc = TL.getDecl()->getBeginLoc();
break;
}
case TypeLoc::Typedef: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ bool PopulateSwitch::prepare(const Selection &Sel) {
EnumT = Cond->getType()->getAsCanonical<EnumType>();
if (!EnumT)
return false;
EnumD = EnumT->getOriginalDecl()->getDefinitionOrSelf();
EnumD = EnumT->getDecl()->getDefinitionOrSelf();
if (EnumD->isDependentType())
return false;

Expand Down
2 changes: 1 addition & 1 deletion clang-tools-extra/include-cleaner/lib/WalkAST.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ class ASTWalker : public RecursiveASTVisitor<ASTWalker> {
}

bool VisitTagTypeLoc(TagTypeLoc TTL) {
reportType(TTL.getNameLoc(), TTL.getOriginalDecl());
reportType(TTL.getNameLoc(), TTL.getDecl());
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion clang/include/clang/AST/ASTNodeTraverser.h
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ class ASTNodeTraverser
// it will not be in the parent context:
if (auto *TT = D->getFriendType()->getType()->getAs<TagType>())
if (TT->isTagOwned())
Visit(TT->getOriginalDecl());
Visit(TT->getDecl());
} else {
Visit(D->getFriendDecl());
}
Expand Down
6 changes: 3 additions & 3 deletions clang/include/clang/AST/CanonicalType.h
Original file line number Diff line number Diff line change
Expand Up @@ -551,18 +551,18 @@ struct CanProxyAdaptor<UnaryTransformType>

template<>
struct CanProxyAdaptor<TagType> : public CanProxyBase<TagType> {
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(TagDecl *, getOriginalDecl)
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(TagDecl *, getDecl)
};

template<>
struct CanProxyAdaptor<RecordType> : public CanProxyBase<RecordType> {
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(RecordDecl *, getOriginalDecl)
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(RecordDecl *, getDecl)
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(bool, hasConstFields)
};

template<>
struct CanProxyAdaptor<EnumType> : public CanProxyBase<EnumType> {
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(EnumDecl *, getOriginalDecl)
LLVM_CLANG_CANPROXY_SIMPLE_ACCESSOR(EnumDecl *, getDecl)
};

template<>
Expand Down
2 changes: 1 addition & 1 deletion clang/include/clang/AST/DeclCXX.h
Original file line number Diff line number Diff line change
Expand Up @@ -3832,7 +3832,7 @@ class UsingEnumDecl : public BaseUsingDecl, public Mergeable<UsingEnumDecl> {

public:
EnumDecl *getEnumDecl() const {
return EnumType->getType()->castAs<clang::EnumType>()->getOriginalDecl();
return EnumType->getType()->castAs<clang::EnumType>()->getDecl();
}

static UsingEnumDecl *Create(ASTContext &C, DeclContext *DC,
Expand Down
2 changes: 1 addition & 1 deletion clang/include/clang/AST/RecursiveASTVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -1710,7 +1710,7 @@ DEF_TRAVERSE_DECL(FriendDecl, {
// it will not be in the parent context:
if (auto *TT = D->getFriendType()->getType()->getAs<TagType>();
TT && TT->isTagOwned())
TRY_TO(TraverseDecl(TT->getOriginalDecl()));
TRY_TO(TraverseDecl(TT->getDecl()));
} else {
TRY_TO(TraverseDecl(D->getFriendDecl()));
}
Expand Down
18 changes: 8 additions & 10 deletions clang/include/clang/AST/Type.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,49 +27,47 @@ inline CXXRecordDecl *Type::getAsCXXRecordDecl() const {
const auto *TT = dyn_cast<TagType>(CanonicalType);
if (!isa_and_present<RecordType, InjectedClassNameType>(TT))
return nullptr;
auto *TD = TT->getOriginalDecl();
auto *TD = TT->getDecl();
if (isa<RecordType>(TT) && !isa<CXXRecordDecl>(TD))
return nullptr;
return cast<CXXRecordDecl>(TD)->getDefinitionOrSelf();
}

inline CXXRecordDecl *Type::castAsCXXRecordDecl() const {
const auto *TT = cast<TagType>(CanonicalType);
return cast<CXXRecordDecl>(TT->getOriginalDecl())->getDefinitionOrSelf();
return cast<CXXRecordDecl>(TT->getDecl())->getDefinitionOrSelf();
}

inline RecordDecl *Type::getAsRecordDecl() const {
const auto *TT = dyn_cast<TagType>(CanonicalType);
if (!isa_and_present<RecordType, InjectedClassNameType>(TT))
return nullptr;
return cast<RecordDecl>(TT->getOriginalDecl())->getDefinitionOrSelf();
return cast<RecordDecl>(TT->getDecl())->getDefinitionOrSelf();
}

inline RecordDecl *Type::castAsRecordDecl() const {
const auto *TT = cast<TagType>(CanonicalType);
return cast<RecordDecl>(TT->getOriginalDecl())->getDefinitionOrSelf();
return cast<RecordDecl>(TT->getDecl())->getDefinitionOrSelf();
}

inline EnumDecl *Type::getAsEnumDecl() const {
if (const auto *TT = dyn_cast<EnumType>(CanonicalType))
return TT->getOriginalDecl()->getDefinitionOrSelf();
return TT->getDecl()->getDefinitionOrSelf();
return nullptr;
}

inline EnumDecl *Type::castAsEnumDecl() const {
return cast<EnumType>(CanonicalType)
->getOriginalDecl()
->getDefinitionOrSelf();
return cast<EnumType>(CanonicalType)->getDecl()->getDefinitionOrSelf();
}

inline TagDecl *Type::getAsTagDecl() const {
if (const auto *TT = dyn_cast<TagType>(CanonicalType))
return TT->getOriginalDecl()->getDefinitionOrSelf();
return TT->getDecl()->getDefinitionOrSelf();
return nullptr;
}

inline TagDecl *Type::castAsTagDecl() const {
return cast<TagType>(CanonicalType)->getOriginalDecl()->getDefinitionOrSelf();
return cast<TagType>(CanonicalType)->getDecl()->getDefinitionOrSelf();
}

inline bool QualType::hasNonTrivialToPrimitiveDefaultInitializeCUnion() const {
Expand Down
48 changes: 24 additions & 24 deletions clang/include/clang/AST/TypeBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -6419,10 +6419,10 @@ class TagType : public TypeWithKeyword {
bool IsInjected, const Type *CanonicalType);

public:
// FIXME: Temporarily renamed from `getDecl` in order to facilitate
// rebasing, due to change in behaviour. This should be renamed back
// to `getDecl` once the change is settled.
TagDecl *getOriginalDecl() const { return decl; }
TagDecl *getDecl() const { return decl; }
[[deprecated("Use getDecl instead")]] TagDecl *getOriginalDecl() const {
return decl;
}

NestedNameSpecifier getQualifier() const;

Expand Down Expand Up @@ -6463,7 +6463,7 @@ struct TagTypeFoldingSetPlaceholder : public llvm::FoldingSetNode {

void Profile(llvm::FoldingSetNodeID &ID) const {
const TagType *T = getTagType();
Profile(ID, T->getKeyword(), T->getQualifier(), T->getOriginalDecl(),
Profile(ID, T->getKeyword(), T->getQualifier(), T->getDecl(),
T->isTagOwned(), T->isInjected());
}

Expand All @@ -6487,11 +6487,11 @@ class RecordType final : public TagType {
using TagType::TagType;

public:
// FIXME: Temporarily renamed from `getDecl` in order to facilitate
// rebasing, due to change in behaviour. This should be renamed back
// to `getDecl` once the change is settled.
RecordDecl *getOriginalDecl() const {
return reinterpret_cast<RecordDecl *>(TagType::getOriginalDecl());
RecordDecl *getDecl() const {
return reinterpret_cast<RecordDecl *>(TagType::getDecl());
}
[[deprecated("Use getDecl instead")]] RecordDecl *getOriginalDecl() const {
return getDecl();
}

/// Recursively check all fields in the record for const-ness. If any field
Expand All @@ -6507,11 +6507,11 @@ class EnumType final : public TagType {
using TagType::TagType;

public:
// FIXME: Temporarily renamed from `getDecl` in order to facilitate
// rebasing, due to change in behaviour. This should be renamed back
// to `getDecl` once the change is settled.
EnumDecl *getOriginalDecl() const {
return reinterpret_cast<EnumDecl *>(TagType::getOriginalDecl());
EnumDecl *getDecl() const {
return reinterpret_cast<EnumDecl *>(TagType::getDecl());
}
[[deprecated("Use getDecl instead")]] EnumDecl *getOriginalDecl() const {
return getDecl();
}

static bool classof(const Type *T) { return T->getTypeClass() == Enum; }
Expand Down Expand Up @@ -6542,11 +6542,11 @@ class InjectedClassNameType final : public TagType {
bool IsInjected, const Type *CanonicalType);

public:
// FIXME: Temporarily renamed from `getDecl` in order to facilitate
// rebasing, due to change in behaviour. This should be renamed back
// to `getDecl` once the change is settled.
CXXRecordDecl *getOriginalDecl() const {
return reinterpret_cast<CXXRecordDecl *>(TagType::getOriginalDecl());
CXXRecordDecl *getDecl() const {
return reinterpret_cast<CXXRecordDecl *>(TagType::getDecl());
}
[[deprecated("Use getDecl instead")]] CXXRecordDecl *getOriginalDecl() const {
return getDecl();
}

static bool classof(const Type *T) {
Expand Down Expand Up @@ -8930,8 +8930,8 @@ inline bool Type::isIntegerType() const {
if (const EnumType *ET = dyn_cast<EnumType>(CanonicalType)) {
// Incomplete enum types are not treated as integer types.
// FIXME: In C++, enum types are never integer types.
return IsEnumDeclComplete(ET->getOriginalDecl()) &&
!IsEnumDeclScoped(ET->getOriginalDecl());
return IsEnumDeclComplete(ET->getDecl()) &&
!IsEnumDeclScoped(ET->getDecl());
}
return isBitIntType();
}
Expand Down Expand Up @@ -8989,7 +8989,7 @@ inline bool Type::isScalarType() const {
if (const EnumType *ET = dyn_cast<EnumType>(CanonicalType))
// Enums are scalar types, but only if they are defined. Incomplete enums
// are not treated as scalar types.
return IsEnumDeclComplete(ET->getOriginalDecl());
return IsEnumDeclComplete(ET->getDecl());
return isa<PointerType>(CanonicalType) ||
isa<BlockPointerType>(CanonicalType) ||
isa<MemberPointerType>(CanonicalType) ||
Expand All @@ -9005,7 +9005,7 @@ inline bool Type::isIntegralOrEnumerationType() const {
// Check for a complete enum type; incomplete enum types are not properly an
// enumeration type in the sense required here.
if (const auto *ET = dyn_cast<EnumType>(CanonicalType))
return IsEnumDeclComplete(ET->getOriginalDecl());
return IsEnumDeclComplete(ET->getDecl());

return isBitIntType();
}
Expand Down
Loading
Loading