99#include " BitcodeReader.h"
1010#include " llvm/ADT/IndexedMap.h"
1111#include " llvm/Support/Error.h"
12+ #include " llvm/Support/ErrorHandling.h"
1213#include " llvm/Support/TimeProfiler.h"
1314#include " llvm/Support/raw_ostream.h"
1415#include < optional>
1516
1617namespace clang {
1718namespace doc {
1819
20+ static llvm::ExitOnError ExitOnErr (" clang-doc error: " );
21+
1922using Record = llvm::SmallVector<uint64_t , 1024 >;
2023
2124// This implements decode for SmallString.
@@ -717,8 +720,8 @@ llvm::Error addReference(FriendInfo *Friend, Reference &&R, FieldId F) {
717720
718721template <typename T, typename ChildInfoType>
719722static void addChild (T I, ChildInfoType &&R) {
720- llvm::errs () << " invalid child type for info " ;
721- exit ( 1 );
723+ ExitOnErr ( llvm::createStringError ( llvm::inconvertibleErrorCode (),
724+ " invalid child type for info " ) );
722725}
723726
724727// Namespace children:
@@ -767,8 +770,9 @@ template <> void addChild(BaseRecordInfo *I, FunctionInfo &&R) {
767770// parameters) or TemplateSpecializationInfo (for the specialization's
768771// parameters).
769772template <typename T> static void addTemplateParam (T I, TemplateParamInfo &&P) {
770- llvm::errs () << " invalid container for template parameter" ;
771- exit (1 );
773+ ExitOnErr (
774+ llvm::createStringError (llvm::inconvertibleErrorCode (),
775+ " invalid container for template parameter" ));
772776}
773777template <> void addTemplateParam (TemplateInfo *I, TemplateParamInfo &&P) {
774778 I->Params .emplace_back (std::move (P));
@@ -780,8 +784,8 @@ void addTemplateParam(TemplateSpecializationInfo *I, TemplateParamInfo &&P) {
780784
781785// Template info. These apply to either records or functions.
782786template <typename T> static void addTemplate (T I, TemplateInfo &&P) {
783- llvm::errs () << " invalid container for template info " ;
784- exit ( 1 );
787+ ExitOnErr ( llvm::createStringError ( llvm::inconvertibleErrorCode (),
788+ " invalid container for template info " ) );
785789}
786790template <> void addTemplate (RecordInfo *I, TemplateInfo &&P) {
787791 I->Template .emplace (std::move (P));
@@ -799,8 +803,9 @@ template <> void addTemplate(FriendInfo *I, TemplateInfo &&P) {
799803// Template specializations go only into template records.
800804template <typename T>
801805static void addTemplateSpecialization (T I, TemplateSpecializationInfo &&TSI) {
802- llvm::errs () << " invalid container for template specialization info" ;
803- exit (1 );
806+ ExitOnErr (llvm::createStringError (
807+ llvm::inconvertibleErrorCode (),
808+ " invalid container for template specialization info" ));
804809}
805810template <>
806811void addTemplateSpecialization (TemplateInfo *I,
@@ -809,8 +814,8 @@ void addTemplateSpecialization(TemplateInfo *I,
809814}
810815
811816template <typename T> static void addConstraint (T I, ConstraintInfo &&C) {
812- llvm::errs () << " invalid container for constraint info " ;
813- exit ( 1 );
817+ ExitOnErr ( llvm::createStringError ( llvm::inconvertibleErrorCode (),
818+ " invalid container for constraint info " ) );
814819}
815820template <> void addConstraint (TemplateInfo *I, ConstraintInfo &&C) {
816821 I->Constraints .emplace_back (std::move (C));
0 commit comments