[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:
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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 "";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user