diff options
Diffstat (limited to 'lib/Frontend/TextDiagnosticPrinter.cpp')
| -rw-r--r-- | lib/Frontend/TextDiagnosticPrinter.cpp | 30 | 
1 files changed, 7 insertions, 23 deletions
diff --git a/lib/Frontend/TextDiagnosticPrinter.cpp b/lib/Frontend/TextDiagnosticPrinter.cpp index 6445a0cc79bb..382e1567c7f4 100644 --- a/lib/Frontend/TextDiagnosticPrinter.cpp +++ b/lib/Frontend/TextDiagnosticPrinter.cpp @@ -27,7 +27,7 @@ using namespace clang;  TextDiagnosticPrinter::TextDiagnosticPrinter(raw_ostream &os,                                               const DiagnosticOptions &diags,                                               bool _OwnsOutputStream) -  : OS(os), LangOpts(0), DiagOpts(&diags), SM(0), +  : OS(os), DiagOpts(&diags),      OwnsOutputStream(_OwnsOutputStream) {  } @@ -38,11 +38,11 @@ TextDiagnosticPrinter::~TextDiagnosticPrinter() {  void TextDiagnosticPrinter::BeginSourceFile(const LangOptions &LO,                                              const Preprocessor *PP) { -  LangOpts = &LO; +  // Build the TextDiagnostic utility. +  TextDiag.reset(new TextDiagnostic(OS, LO, *DiagOpts));  }  void TextDiagnosticPrinter::EndSourceFile() { -  LangOpts = 0;    TextDiag.reset(0);  } @@ -79,16 +79,6 @@ static void printDiagnosticOptions(raw_ostream &OS,        Started = true;      } -    // If the diagnostic is an extension diagnostic and not enabled by default -    // then it must have been turned on with -pedantic. -    bool EnabledByDefault; -    if (DiagnosticIDs::isBuiltinExtensionDiag(Info.getID(), -                                              EnabledByDefault) && -        !EnabledByDefault) { -      OS << (Started ? "," : " [") << "-pedantic"; -      Started = true; -    } -      StringRef Opt = DiagnosticIDs::getWarningOptionForDiag(Info.getID());      if (!Opt.empty()) {        OS << (Started ? "," : " [") << "-W" << Opt; @@ -128,7 +118,7 @@ void TextDiagnosticPrinter::HandleDiagnostic(DiagnosticsEngine::Level Level,    llvm::raw_svector_ostream DiagMessageStream(OutStr);    printDiagnosticOptions(DiagMessageStream, Level, Info, *DiagOpts); -  // Keeps track of the the starting position of the location +  // Keeps track of the starting position of the location    // information (e.g., "foo.c:10:4:") that precedes the error    // message. We use this information to determine how long the    // file+line+column number prefix is. @@ -152,22 +142,16 @@ void TextDiagnosticPrinter::HandleDiagnostic(DiagnosticsEngine::Level Level,    }    // Assert that the rest of our infrastructure is setup properly. -  assert(LangOpts && "Unexpected diagnostic outside source file processing");    assert(DiagOpts && "Unexpected diagnostic without options set");    assert(Info.hasSourceManager() &&           "Unexpected diagnostic with no source manager"); - -  // Rebuild the TextDiagnostic utility if missing or the source manager has -  // changed. -  if (!TextDiag || SM != &Info.getSourceManager()) { -    SM = &Info.getSourceManager(); -    TextDiag.reset(new TextDiagnostic(OS, *SM, *LangOpts, *DiagOpts)); -  } +  assert(TextDiag && "Unexpected diagnostic outside source file processing");    TextDiag->emitDiagnostic(Info.getLocation(), Level, DiagMessageStream.str(),                             Info.getRanges(),                             llvm::makeArrayRef(Info.getFixItHints(), -                                              Info.getNumFixItHints())); +                                              Info.getNumFixItHints()), +                           &Info.getSourceManager());    OS.flush();  }  | 
