Skip to content

Commit

Permalink
[NFC] Use isa<...> to replace isa<>||isa<> in clang/Serialization
Browse files Browse the repository at this point in the history
Now isa supports the variant args, which could simplify the codes
further. This patch simplify the uses in clang/Serialization
  • Loading branch information
ChuanqiXu9 committed Oct 31, 2022
1 parent bc886e9 commit 22914a8
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 17 deletions.
4 changes: 2 additions & 2 deletions clang/lib/Serialization/ASTCommon.cpp
Expand Up @@ -474,7 +474,7 @@ bool serialization::needsAnonymousDeclarationNumber(const NamedDecl *D) {
if (auto *VD = dyn_cast<VarDecl>(D))
return VD->isStaticLocal();
// FIXME: What about CapturedDecls (and declarations nested within them)?
return isa<TagDecl>(D) || isa<BlockDecl>(D);
return isa<TagDecl, BlockDecl>(D);
}

// Otherwise, we only care about anonymous class members / block-scope decls.
Expand All @@ -484,5 +484,5 @@ bool serialization::needsAnonymousDeclarationNumber(const NamedDecl *D) {
return false;
if (!isa<RecordDecl, ObjCInterfaceDecl>(D->getLexicalDeclContext()))
return false;
return isa<TagDecl>(D) || isa<FieldDecl>(D);
return isa<TagDecl, FieldDecl>(D);
}
3 changes: 1 addition & 2 deletions clang/lib/Serialization/ASTReader.cpp
Expand Up @@ -7229,8 +7229,7 @@ void ASTReader::CompleteRedeclChain(const Decl *D) {
//
// FIXME: Merging a function definition should merge
// all mergeable entities within it.
if (isa<TranslationUnitDecl>(DC) || isa<NamespaceDecl>(DC) ||
isa<CXXRecordDecl>(DC) || isa<EnumDecl>(DC)) {
if (isa<TranslationUnitDecl, NamespaceDecl, CXXRecordDecl, EnumDecl>(DC)) {
if (DeclarationName Name = cast<NamedDecl>(D)->getDeclName()) {
if (!getContext().getLangOpts().CPlusPlus &&
isa<TranslationUnitDecl>(DC)) {
Expand Down
17 changes: 6 additions & 11 deletions clang/lib/Serialization/ASTReaderDecl.cpp
Expand Up @@ -567,7 +567,7 @@ void ASTDeclReader::Visit(Decl *D) {

void ASTDeclReader::VisitDecl(Decl *D) {
if (D->isTemplateParameter() || D->isTemplateParameterPack() ||
isa<ParmVarDecl>(D) || isa<ObjCTypeParamDecl>(D)) {
isa<ParmVarDecl, ObjCTypeParamDecl>(D)) {
// We don't want to deserialize the DeclContext of a template
// parameter or of a parameter of a function template immediately. These
// entities might be used in the formulation of its DeclContext (for
Expand Down Expand Up @@ -3021,16 +3021,11 @@ static bool isConsumerInterestedIn(ASTContext &Ctx, Decl *D, bool HasBody) {
return false;
}

if (isa<FileScopeAsmDecl>(D) ||
isa<ObjCProtocolDecl>(D) ||
isa<ObjCImplDecl>(D) ||
isa<ImportDecl>(D) ||
isa<PragmaCommentDecl>(D) ||
isa<PragmaDetectMismatchDecl>(D))
if (isa<FileScopeAsmDecl, ObjCProtocolDecl, ObjCImplDecl, ImportDecl,
PragmaCommentDecl, PragmaDetectMismatchDecl>(D))
return true;
if (isa<OMPThreadPrivateDecl>(D) || isa<OMPDeclareReductionDecl>(D) ||
isa<OMPDeclareMapperDecl>(D) || isa<OMPAllocateDecl>(D) ||
isa<OMPRequiresDecl>(D))
if (isa<OMPThreadPrivateDecl, OMPDeclareReductionDecl, OMPDeclareMapperDecl,
OMPAllocateDecl, OMPRequiresDecl>(D))
return !D->getDeclContext()->isFunctionOrMethod();
if (const auto *Var = dyn_cast<VarDecl>(D))
return Var->isFileVarDecl() &&
Expand Down Expand Up @@ -4049,7 +4044,7 @@ void ASTReader::loadDeclUpdateRecords(PendingUpdateRecord &Record) {
}
// Add the lazy specializations to the template.
assert((PendingLazySpecializationIDs.empty() || isa<ClassTemplateDecl>(D) ||
isa<FunctionTemplateDecl>(D) || isa<VarTemplateDecl>(D)) &&
isa<FunctionTemplateDecl, VarTemplateDecl>(D)) &&
"Must not have pending specializations");
if (auto *CTD = dyn_cast<ClassTemplateDecl>(D))
ASTDeclReader::AddLazySpecializations(CTD, PendingLazySpecializationIDs);
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Serialization/ASTWriter.cpp
Expand Up @@ -5471,7 +5471,7 @@ void ASTWriter::associateDeclWithFile(const Decl *D, DeclID ID) {
// a function/objc method, should not have TU as lexical context.
// TemplateTemplateParmDecls that are part of an alias template, should not
// have TU as lexical context.
if (isa<ParmVarDecl>(D) || isa<TemplateTemplateParmDecl>(D))
if (isa<ParmVarDecl, TemplateTemplateParmDecl>(D))
return;

SourceManager &SM = Context->getSourceManager();
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Serialization/ASTWriterDecl.cpp
Expand Up @@ -2417,7 +2417,7 @@ static bool isRequiredDecl(const Decl *D, ASTContext &Context,

// File scoped assembly or obj-c or OMP declare target implementation must be
// seen.
if (isa<FileScopeAsmDecl>(D) || isa<ObjCImplDecl>(D))
if (isa<FileScopeAsmDecl, ObjCImplDecl>(D))
return true;

if (WritingModule && isPartOfPerModuleInitializer(D)) {
Expand Down

0 comments on commit 22914a8

Please sign in to comment.