[clang-doc] remove default label on some switches (#143919)

LLVM style prefers no default label on fully covered switches to warn if
new enums are added. This patch removes the default label for that
purpose or uses IT_default instead of default if that was the only enum
not covered.
This commit is contained in:
Erick Velez
2025-06-13 16:35:30 -07:00
committed by GitHub
parent d7e64d9594
commit 7f69cd578d
5 changed files with 12 additions and 9 deletions

View File

@@ -54,10 +54,8 @@ static llvm::Error decodeRecord(const Record &R, AccessSpecifier &Field,
case AS_none:
Field = (AccessSpecifier)R[0];
return llvm::Error::success();
default:
return llvm::createStringError(llvm::inconvertibleErrorCode(),
"invalid value for AccessSpecifier");
}
llvm_unreachable("invalid value for AccessSpecifier");
}
static llvm::Error decodeRecord(const Record &R, TagTypeKind &Field,

View File

@@ -664,7 +664,7 @@ bool ClangDocBitcodeWriter::dispatchInfoForWrite(Info *I) {
case InfoType::IT_typedef:
emitBlock(*static_cast<clang::doc::TypedefInfo *>(I));
break;
default:
case InfoType::IT_default:
llvm::errs() << "Unexpected info, unable to write.\n";
return true;
}

View File

@@ -143,7 +143,7 @@ mergeInfos(std::vector<std::unique_ptr<Info>> &Values) {
return reduce<FunctionInfo>(Values);
case InfoType::IT_typedef:
return reduce<TypedefInfo>(Values);
default:
case InfoType::IT_default:
return llvm::createStringError(llvm::inconvertibleErrorCode(),
"unexpected info type");
}

View File

@@ -388,7 +388,8 @@ std::string serialize(std::unique_ptr<Info> &I) {
return serialize(*static_cast<EnumInfo *>(I.get()));
case InfoType::IT_function:
return serialize(*static_cast<FunctionInfo *>(I.get()));
default:
case InfoType::IT_typedef:
case InfoType::IT_default:
return "";
}
}
@@ -525,9 +526,13 @@ static std::unique_ptr<Info> makeAndInsertIntoParent(ChildType Child) {
InsertChild(ParentRec->Children, std::forward<ChildType>(Child));
return ParentRec;
}
default:
llvm_unreachable("Invalid reference type for parent namespace");
case InfoType::IT_default:
case InfoType::IT_enum:
case InfoType::IT_function:
case InfoType::IT_typedef:
break;
}
llvm_unreachable("Invalid reference type for parent namespace");
}
// There are two uses for this function.

View File

@@ -37,7 +37,7 @@ static std::string writeInfo(Info *I) {
return writeInfo(*static_cast<FunctionInfo *>(I));
case InfoType::IT_typedef:
return writeInfo(*static_cast<TypedefInfo *>(I));
default:
case InfoType::IT_default:
return "";
}
}