Move some clang-cc errors to use diagnostics, and simplify.
llvm-svn: 85527
This commit is contained in:
parent
fa50290b49
commit
7ad807f248
|
@ -12,6 +12,7 @@ let Component = "Frontend" in {
|
||||||
def err_fe_unknown_triple : Error<
|
def err_fe_unknown_triple : Error<
|
||||||
"unknown target triple '%0', please use -triple or -arch">;
|
"unknown target triple '%0', please use -triple or -arch">;
|
||||||
def err_fe_unknown_target_abi : Error<"unknown target ABI '%0'">;
|
def err_fe_unknown_target_abi : Error<"unknown target ABI '%0'">;
|
||||||
|
def err_fe_error_opening : Error<"error opening '%0': %1">;
|
||||||
def err_fe_error_reading : Error<"error reading '%0'">;
|
def err_fe_error_reading : Error<"error reading '%0'">;
|
||||||
def err_fe_error_reading_stdin : Error<"error reading stdin">;
|
def err_fe_error_reading_stdin : Error<"error reading stdin">;
|
||||||
def err_fe_error_backend : Error<"error in backend: %0">, DefaultFatal;
|
def err_fe_error_backend : Error<"error in backend: %0">, DefaultFatal;
|
||||||
|
@ -19,6 +20,8 @@ def err_fe_invalid_ast_file : Error<"invalid AST file: '%0'">, DefaultFatal;
|
||||||
def err_fe_invalid_ast_action : Error<"invalid action for AST input">, DefaultFatal;
|
def err_fe_invalid_ast_action : Error<"invalid action for AST input">, DefaultFatal;
|
||||||
def err_fe_invalid_code_complete_file
|
def err_fe_invalid_code_complete_file
|
||||||
: Error<"cannot locate code-completion file %0">, DefaultFatal;
|
: Error<"cannot locate code-completion file %0">, DefaultFatal;
|
||||||
|
def err_fe_dependency_file_requires_MT : Error<
|
||||||
|
"-dependency-file requires at least one -MT option">;
|
||||||
|
|
||||||
def note_fixit_applied : Note<"FIX-IT applied suggested code changes">;
|
def note_fixit_applied : Note<"FIX-IT applied suggested code changes">;
|
||||||
def note_fixit_in_macro : Note<
|
def note_fixit_in_macro : Note<
|
||||||
|
|
|
@ -106,8 +106,6 @@ static bool ResolveParsedLocation(ParsedSourceLocation &ParsedLoc,
|
||||||
/// anything.
|
/// anything.
|
||||||
llvm::Timer *ClangFrontendTimer = 0;
|
llvm::Timer *ClangFrontendTimer = 0;
|
||||||
|
|
||||||
static bool HadErrors = false;
|
|
||||||
|
|
||||||
static llvm::cl::opt<bool>
|
static llvm::cl::opt<bool>
|
||||||
Verbose("v", llvm::cl::desc("Enable verbose output"));
|
Verbose("v", llvm::cl::desc("Enable verbose output"));
|
||||||
static llvm::cl::opt<bool>
|
static llvm::cl::opt<bool>
|
||||||
|
@ -1853,8 +1851,8 @@ static void ProcessInputFile(Preprocessor &PP, PreprocessorFactory &PPF,
|
||||||
Features, Context));
|
Features, Context));
|
||||||
|
|
||||||
if (!Consumer.get()) {
|
if (!Consumer.get()) {
|
||||||
fprintf(stderr, "Unexpected program action!\n");
|
PP.getDiagnostics().Report(FullSourceLoc(),
|
||||||
HadErrors = true;
|
diag::err_fe_invalid_ast_action);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2165,11 +2163,9 @@ static void ProcessInputFile(Preprocessor &PP, PreprocessorFactory &PPF,
|
||||||
// handles. Also, we don't want to try to erase an open file.
|
// handles. Also, we don't want to try to erase an open file.
|
||||||
OS.reset();
|
OS.reset();
|
||||||
|
|
||||||
if ((HadErrors || (PP.getDiagnostics().getNumErrors() != 0)) &&
|
// If we had errors, try to erase the output file.
|
||||||
!OutPath.isEmpty()) {
|
if (PP.getDiagnostics().getNumErrors() && !OutPath.isEmpty())
|
||||||
// If we had errors, try to erase the output file.
|
|
||||||
OutPath.eraseFromDisk();
|
OutPath.eraseFromDisk();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ProcessInputFile - Process a single AST input file with the specified state.
|
/// ProcessInputFile - Process a single AST input file with the specified state.
|
||||||
|
@ -2224,11 +2220,9 @@ static void ProcessASTInputFile(const std::string &InFile, ProgActions PA,
|
||||||
// handles. Also, we don't want to try to erase an open file.
|
// handles. Also, we don't want to try to erase an open file.
|
||||||
OS.reset();
|
OS.reset();
|
||||||
|
|
||||||
if ((HadErrors || (PP.getDiagnostics().getNumErrors() != 0)) &&
|
// If we had errors, try to erase the output file.
|
||||||
!OutPath.isEmpty()) {
|
if (PP.getDiagnostics().getNumErrors() && !OutPath.isEmpty())
|
||||||
// If we had errors, try to erase the output file.
|
|
||||||
OutPath.eraseFromDisk();
|
OutPath.eraseFromDisk();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static llvm::cl::list<std::string>
|
static llvm::cl::list<std::string>
|
||||||
|
@ -2290,9 +2284,9 @@ int main(int argc, char **argv) {
|
||||||
if (MessageLength.getNumOccurrences() == 0)
|
if (MessageLength.getNumOccurrences() == 0)
|
||||||
MessageLength.setValue(llvm::sys::Process::StandardErrColumns());
|
MessageLength.setValue(llvm::sys::Process::StandardErrColumns());
|
||||||
|
|
||||||
if (!NoColorDiagnostic) {
|
// Disable color diagnostics if not supported on stderr.
|
||||||
NoColorDiagnostic.setValue(!llvm::sys::Process::StandardErrHasColors());
|
if (!NoColorDiagnostic && !llvm::sys::Process::StandardErrHasColors())
|
||||||
}
|
NoColorDiagnostic.setValue(true);
|
||||||
|
|
||||||
DiagClient.reset(new TextDiagnosticPrinter(llvm::errs(),
|
DiagClient.reset(new TextDiagnosticPrinter(llvm::errs(),
|
||||||
!NoShowColumn,
|
!NoShowColumn,
|
||||||
|
@ -2397,26 +2391,21 @@ int main(int argc, char **argv) {
|
||||||
*SourceMgr.get(), HeaderInfo);
|
*SourceMgr.get(), HeaderInfo);
|
||||||
|
|
||||||
llvm::OwningPtr<Preprocessor> PP(PPFactory.CreatePreprocessor());
|
llvm::OwningPtr<Preprocessor> PP(PPFactory.CreatePreprocessor());
|
||||||
|
|
||||||
if (!PP)
|
if (!PP)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Handle generating dependencies, if requested
|
// Handle generating dependencies, if requested.
|
||||||
if (!DependencyFile.empty()) {
|
if (!DependencyFile.empty()) {
|
||||||
llvm::raw_ostream *DependencyOS;
|
|
||||||
if (DependencyTargets.empty()) {
|
if (DependencyTargets.empty()) {
|
||||||
// FIXME: Use a proper diagnostic
|
Diags.Report(FullSourceLoc(), diag::err_fe_dependency_file_requires_MT);
|
||||||
llvm::errs() << "-dependency-file requires at least one -MT option\n";
|
|
||||||
HadErrors = true;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
std::string ErrStr;
|
std::string ErrStr;
|
||||||
DependencyOS =
|
llvm::raw_ostream *DependencyOS =
|
||||||
new llvm::raw_fd_ostream(DependencyFile.c_str(), ErrStr);
|
new llvm::raw_fd_ostream(DependencyFile.c_str(), ErrStr);
|
||||||
if (!ErrStr.empty()) {
|
if (!ErrStr.empty()) {
|
||||||
// FIXME: Use a proper diagnostic
|
Diags.Report(FullSourceLoc(), diag::err_fe_error_opening)
|
||||||
llvm::errs() << "unable to open dependency file: " + ErrStr;
|
<< DependencyFile << ErrStr;
|
||||||
HadErrors = true;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2465,5 +2454,5 @@ int main(int argc, char **argv) {
|
||||||
// -time-passes usable.
|
// -time-passes usable.
|
||||||
llvm::llvm_shutdown();
|
llvm::llvm_shutdown();
|
||||||
|
|
||||||
return HadErrors || (Diags.getNumErrors() != 0);
|
return (Diags.getNumErrors() != 0);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue