Skip to content

Fixup InstallAPI post merge #8434

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions clang/lib/Basic/DiagnosticIDs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ struct StaticDiagInfoDescriptionStringTable {
#include "clang/Basic/DiagnosticSemaKinds.inc"
#include "clang/Basic/DiagnosticAnalysisKinds.inc"
#include "clang/Basic/DiagnosticRefactoringKinds.inc"
#include "clang/Basic/DiagnosticCASKinds.inc"
#include "clang/Basic/DiagnosticInstallAPIKinds.inc"
#include "clang/Basic/DiagnosticCASKinds.inc"
// clang-format on
#undef DIAG
};
Expand All @@ -72,8 +72,8 @@ const StaticDiagInfoDescriptionStringTable StaticDiagInfoDescriptions = {
#include "clang/Basic/DiagnosticSemaKinds.inc"
#include "clang/Basic/DiagnosticAnalysisKinds.inc"
#include "clang/Basic/DiagnosticRefactoringKinds.inc"
#include "clang/Basic/DiagnosticCASKinds.inc"
#include "clang/Basic/DiagnosticInstallAPIKinds.inc"
#include "clang/Basic/DiagnosticCASKinds.inc"
// clang-format on
#undef DIAG
};
Expand All @@ -99,8 +99,8 @@ const uint32_t StaticDiagInfoDescriptionOffsets[] = {
#include "clang/Basic/DiagnosticSemaKinds.inc"
#include "clang/Basic/DiagnosticAnalysisKinds.inc"
#include "clang/Basic/DiagnosticRefactoringKinds.inc"
#include "clang/Basic/DiagnosticCASKinds.inc"
#include "clang/Basic/DiagnosticInstallAPIKinds.inc"
#include "clang/Basic/DiagnosticCASKinds.inc"
// clang-format on
#undef DIAG
};
Expand Down Expand Up @@ -179,8 +179,8 @@ VALIDATE_DIAG_SIZE(CROSSTU)
VALIDATE_DIAG_SIZE(SEMA)
VALIDATE_DIAG_SIZE(ANALYSIS)
VALIDATE_DIAG_SIZE(REFACTORING)
VALIDATE_DIAG_SIZE(CAS)
VALIDATE_DIAG_SIZE(INSTALLAPI)
VALIDATE_DIAG_SIZE(CAS)
#undef VALIDATE_DIAG_SIZE
#undef STRINGIFY_NAME

Expand Down Expand Up @@ -212,8 +212,8 @@ const StaticDiagInfoRec StaticDiagInfo[] = {
#include "clang/Basic/DiagnosticSemaKinds.inc"
#include "clang/Basic/DiagnosticAnalysisKinds.inc"
#include "clang/Basic/DiagnosticRefactoringKinds.inc"
#include "clang/Basic/DiagnosticCASKinds.inc"
#include "clang/Basic/DiagnosticInstallAPIKinds.inc"
#include "clang/Basic/DiagnosticCASKinds.inc"
// clang-format on
#undef DIAG
};
Expand Down Expand Up @@ -256,8 +256,8 @@ CATEGORY(CROSSTU, COMMENT)
CATEGORY(SEMA, CROSSTU)
CATEGORY(ANALYSIS, SEMA)
CATEGORY(REFACTORING, ANALYSIS)
CATEGORY(CAS, REFACTORING)
CATEGORY(INSTALLAPI, REFACTORING)
CATEGORY(CAS, INSTALLAPI)
#undef CATEGORY

// Avoid out of bounds reads.
Expand Down
11 changes: 8 additions & 3 deletions clang/tools/clang-installapi/ClangInstallAPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ static bool run(ArrayRef<const char *> Args, const char *ProgName) {
}
}

if (Ctx.Verifier->getState() == DylibVerifier::Result::Invalid)
return EXIT_FAILURE;

// After symbols have been collected, prepare to write output.
llvm::vfs::OnDiskOutputBackend Backend;
std::optional<llvm::vfs::OutputFile> Out = llvm::expectedToOptional(
Backend.createFile(Ctx.OutputLoc, llvm::vfs::OutputConfig()
Expand All @@ -146,14 +150,15 @@ static bool run(ArrayRef<const char *> Args, const char *ProgName) {

// Write output file and perform CI cleanup.
if (auto Err = TextAPIWriter::writeToStream(Out->getOS(), IF, Ctx.FT)) {
Diag->Report(diag::err_cannot_open_file) << Ctx.OutputLoc;
CI->clearOutputFiles(/*EraseFiles=*/true);
Diag->Report(diag::err_cannot_write_file)
<< Ctx.OutputLoc << std::move(Err);
if (auto Err = Out->discard())
llvm::consumeError(std::move(Err));
return EXIT_FAILURE;
}
if (auto Err = Out->keep()) {
Diag->Report(diag::err_cannot_open_file) << Ctx.OutputLoc << std::move(Err);
Diag->Report(diag::err_cannot_write_file)
<< Ctx.OutputLoc << std::move(Err);
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
Expand Down