diff options
| author | Daniel Dunbar <daniel@zuster.org> | 2009-12-03 09:14:12 +0000 |
|---|---|---|
| committer | Daniel Dunbar <daniel@zuster.org> | 2009-12-03 09:14:12 +0000 |
| commit | 6dac935b1f58227c21e1ef6846ed59cfef686ae0 (patch) | |
| tree | 893827949dc0e288637cb83c3be5fb9fbb960bf8 | |
| parent | f680e7d8550d9f1f3162d6ae675b14ba7ced8888 (diff) | |
| download | bcm5719-llvm-6dac935b1f58227c21e1ef6846ed59cfef686ae0.tar.gz bcm5719-llvm-6dac935b1f58227c21e1ef6846ed59cfef686ae0.zip | |
Fix two more diagnostic-on-stderr instances that thought they could hide from me -- they thought wrong.
llvm-svn: 90442
| -rw-r--r-- | clang/include/clang/Basic/DiagnosticFrontendKinds.td | 4 | ||||
| -rw-r--r-- | clang/lib/Frontend/InitPreprocessor.cpp | 20 |
2 files changed, 14 insertions, 10 deletions
diff --git a/clang/include/clang/Basic/DiagnosticFrontendKinds.td b/clang/include/clang/Basic/DiagnosticFrontendKinds.td index 4d6d82b9e1e..19a8b358837 100644 --- a/clang/include/clang/Basic/DiagnosticFrontendKinds.td +++ b/clang/include/clang/Basic/DiagnosticFrontendKinds.td @@ -55,6 +55,10 @@ def err_fe_pch_error_at_end_block : Error< "error at end of module block in PCH file: '%0'">; def err_fe_unable_to_open_output : Error< "unable to to open output file '%0': '%1'">; +def err_fe_pth_file_has_no_source_header : Error< + "PTH file '%0' does not designate an original source header file for -include-pth">; +def warn_fe_macro_contains_embedded_newline : Warning< + "macro '%0' contains embedded newline, text after the newline is ignored.">; def err_verify_bogus_characters : Error< "bogus characters before '{{' in expected string">; diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp index aa05b34ef5c..a9ca762cc12 100644 --- a/clang/lib/Frontend/InitPreprocessor.cpp +++ b/clang/lib/Frontend/InitPreprocessor.cpp @@ -28,7 +28,8 @@ using namespace clang; // Append a #define line to Buf for Macro. Macro should be of the form XXX, // in which case we emit "#define XXX 1" or "XXX=Y z W" in which case we emit // "#define XXX Y z W". To get a #define with no value, use "XXX=". -static void DefineBuiltinMacro(std::vector<char> &Buf, const char *Macro) { +static void DefineBuiltinMacro(std::vector<char> &Buf, const char *Macro, + Diagnostic *Diags = 0) { const char *Command = "#define "; Buf.insert(Buf.end(), Command, Command+strlen(Command)); if (const char *Equal = strchr(Macro, '=')) { @@ -39,9 +40,9 @@ static void DefineBuiltinMacro(std::vector<char> &Buf, const char *Macro) { // Per GCC -D semantics, the macro ends at \n if it exists. const char *End = strpbrk(Equal, "\n\r"); if (End) { - fprintf(stderr, "warning: macro '%s' contains embedded newline, text " - "after the newline is ignored.\n", - std::string(Macro, Equal).c_str()); + assert(Diags && "Unexpected macro with embedded newline!"); + Diags->Report(diag::warn_fe_macro_contains_embedded_newline) + << std::string(Macro, Equal); } else { End = Equal+strlen(Equal); } @@ -123,11 +124,9 @@ static void AddImplicitIncludePTH(std::vector<char> &Buf, Preprocessor &PP, const char *OriginalFile = P->getOriginalSourceFile(); if (!OriginalFile) { - assert(!ImplicitIncludePTH.empty()); - fprintf(stderr, "error: PTH file '%s' does not designate an original " - "source header file for -include-pth\n", - ImplicitIncludePTH.c_str()); - exit (1); + PP.getDiagnostics().Report(diag::err_fe_pth_file_has_no_source_header) + << ImplicitIncludePTH; + return; } AddImplicitInclude(Buf, OriginalFile); @@ -560,7 +559,8 @@ void clang::InitializePreprocessor(Preprocessor &PP, if (InitOpts.Macros[i].second) // isUndef UndefineBuiltinMacro(PredefineBuffer, InitOpts.Macros[i].first.c_str()); else - DefineBuiltinMacro(PredefineBuffer, InitOpts.Macros[i].first.c_str()); + DefineBuiltinMacro(PredefineBuffer, InitOpts.Macros[i].first.c_str(), + &PP.getDiagnostics()); } // If -imacros are specified, include them now. These are processed before |

