Skip to content

Commit ce5f365

Browse files
committed
[PATCH 5/6] [clang] NNS improvement: getOriginalDecl changes
1 parent 172e50c commit ce5f365

File tree

167 files changed

+1273
-821
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

167 files changed

+1273
-821
lines changed

clang-tools-extra/clang-doc/Serialize.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -895,8 +895,8 @@ parseBases(RecordInfo &I, const CXXRecordDecl *D, bool IsFileInRootDir,
895895
return;
896896
for (const CXXBaseSpecifier &B : D->bases()) {
897897
if (const RecordType *Ty = B.getType()->getAs<RecordType>()) {
898-
if (const CXXRecordDecl *Base =
899-
cast_or_null<CXXRecordDecl>(Ty->getDecl()->getDefinition())) {
898+
if (const CXXRecordDecl *Base = cast_or_null<CXXRecordDecl>(
899+
Ty->getOriginalDecl()->getDefinition())) {
900900
// Initialized without USR and name, this will be set in the following
901901
// if-else stmt.
902902
BaseRecordInfo BI(

clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ struct InitializerInsertion {
190190
// Convenience utility to get a RecordDecl from a QualType.
191191
const RecordDecl *getCanonicalRecordDecl(const QualType &Type) {
192192
if (const auto *RT = Type.getCanonicalType()->getAs<RecordType>())
193-
return RT->getDecl();
193+
return RT->getOriginalDecl();
194194
return nullptr;
195195
}
196196

clang-tools-extra/clang-tidy/cppcoreguidelines/SlicingCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ void SlicingCheck::diagnoseSlicedOverriddenMethods(
9292
for (const auto &Base : DerivedDecl.bases()) {
9393
if (const auto *BaseRecordType = Base.getType()->getAs<RecordType>()) {
9494
if (const auto *BaseRecord = cast_or_null<CXXRecordDecl>(
95-
BaseRecordType->getDecl()->getDefinition()))
95+
BaseRecordType->getOriginalDecl()->getDefinition()))
9696
diagnoseSlicedOverriddenMethods(Call, *BaseRecord, BaseDecl);
9797
}
9898
}

clang-tools-extra/clang-tidy/fuchsia/MultipleInheritanceCheck.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ bool MultipleInheritanceCheck::isInterface(const CXXRecordDecl *Node) {
7474
const auto *Ty = I.getType()->getAs<RecordType>();
7575
if (!Ty)
7676
continue;
77-
const RecordDecl *D = Ty->getDecl()->getDefinition();
77+
const RecordDecl *D = Ty->getOriginalDecl()->getDefinition();
7878
if (!D)
7979
continue;
8080
const auto *Base = cast<CXXRecordDecl>(D);
@@ -106,7 +106,8 @@ void MultipleInheritanceCheck::check(const MatchFinder::MatchResult &Result) {
106106
const auto *Ty = I.getType()->getAs<RecordType>();
107107
if (!Ty)
108108
continue;
109-
const auto *Base = cast<CXXRecordDecl>(Ty->getDecl()->getDefinition());
109+
const auto *Base =
110+
cast<CXXRecordDecl>(Ty->getOriginalDecl()->getDefinition());
110111
if (!isInterface(Base))
111112
NumConcrete++;
112113
}
@@ -117,7 +118,8 @@ void MultipleInheritanceCheck::check(const MatchFinder::MatchResult &Result) {
117118
const auto *Ty = V.getType()->getAs<RecordType>();
118119
if (!Ty)
119120
continue;
120-
const auto *Base = cast<CXXRecordDecl>(Ty->getDecl()->getDefinition());
121+
const auto *Base =
122+
cast<CXXRecordDecl>(Ty->getOriginalDecl()->getDefinition());
121123
if (!isInterface(Base))
122124
NumConcrete++;
123125
}

clang-tools-extra/clang-tidy/google/ExplicitConstructorCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ static bool isStdInitializerList(QualType Type) {
7272
}
7373
if (const auto *RT = Type->getAs<RecordType>()) {
7474
if (const auto *Specialization =
75-
dyn_cast<ClassTemplateSpecializationDecl>(RT->getDecl()))
75+
dyn_cast<ClassTemplateSpecializationDecl>(RT->getOriginalDecl()))
7676
return declIsStdInitializerList(Specialization->getSpecializedTemplate());
7777
}
7878
return false;

clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ void UnusedUsingDeclsCheck::check(const MatchFinder::MatchResult &Result) {
132132
}
133133
if (const auto *ECD = dyn_cast<EnumConstantDecl>(Used)) {
134134
if (const auto *ET = ECD->getType()->getAs<EnumType>())
135-
removeFromFoundDecls(ET->getDecl());
135+
removeFromFoundDecls(ET->getOriginalDecl());
136136
}
137137
};
138138
// We rely on the fact that the clang AST is walked in order, usages are only

clang-tools-extra/clang-tidy/modernize/UseScopedLockCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ static bool isLockGuardDecl(const NamedDecl *Decl) {
2929

3030
static bool isLockGuard(const QualType &Type) {
3131
if (const auto *Record = Type->getAs<RecordType>())
32-
if (const RecordDecl *Decl = Record->getDecl())
32+
if (const RecordDecl *Decl = Record->getOriginalDecl())
3333
return isLockGuardDecl(Decl);
3434

3535
if (const auto *TemplateSpecType = Type->getAs<TemplateSpecializationType>())

clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,9 +414,9 @@ static bool areTypesCompatible(QualType ArgType, QualType ParamType,
414414
// Arithmetic types are interconvertible, except scoped enums.
415415
if (ParamType->isArithmeticType() && ArgType->isArithmeticType()) {
416416
if ((ParamType->isEnumeralType() &&
417-
ParamType->castAs<EnumType>()->getDecl()->isScoped()) ||
417+
ParamType->castAs<EnumType>()->getOriginalDecl()->isScoped()) ||
418418
(ArgType->isEnumeralType() &&
419-
ArgType->castAs<EnumType>()->getDecl()->isScoped()))
419+
ArgType->castAs<EnumType>()->getOriginalDecl()->isScoped()))
420420
return false;
421421

422422
return true;

clang-tools-extra/clang-tidy/utils/ExceptionSpecAnalyzer.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ ExceptionSpecAnalyzer::analyzeBase(const CXXBaseSpecifier &Base,
6666
if (!RecType)
6767
return State::Unknown;
6868

69-
const auto *BaseClass = cast<CXXRecordDecl>(RecType->getDecl());
69+
const auto *BaseClass =
70+
cast<CXXRecordDecl>(RecType->getOriginalDecl())->getDefinitionOrSelf();
7071

7172
return analyzeRecord(BaseClass, Kind);
7273
}

clang-tools-extra/clang-tidy/utils/FormatStringConverter.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -465,8 +465,9 @@ bool FormatStringConverter::emitIntegerArgument(
465465
// the signedness based on the format string, so we need to do the
466466
// same.
467467
if (const auto *ET = ArgType->getAs<EnumType>()) {
468-
if (const std::optional<std::string> MaybeCastType =
469-
castTypeForArgument(ArgKind, ET->getDecl()->getIntegerType()))
468+
if (const std::optional<std::string> MaybeCastType = castTypeForArgument(
469+
ArgKind,
470+
ET->getOriginalDecl()->getDefinitionOrSelf()->getIntegerType()))
470471
ArgFixes.emplace_back(
471472
ArgIndex, (Twine("static_cast<") + *MaybeCastType + ">(").str());
472473
else

0 commit comments

Comments
 (0)