aboutsummaryrefslogtreecommitdiff
path: root/mod/diagnostics.cxx
blob: c2f3f52b6a17125ccd3007ac66b56e302fd8f0fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// file      : mod/diagnostics.cxx -*- C++ -*-
// copyright : Copyright (c) 2014-2017 Code Synthesis Ltd
// license   : MIT; see accompanying LICENSE file

#include <mod/diagnostics.hxx>

using namespace std;

namespace brep
{
  diag_record::
  ~diag_record () noexcept(false)
  {
    // Don't flush the record if this destructor was called as part of
    // the stack unwinding. Right now this means we cannot use this
    // mechanism in destructors, which is not a big deal, except for
    // one place: exception_guard. So for now we are going to have
    // this ugly special check which we will be able to get rid of
    // once C++17 uncaught_exceptions() becomes available.
    //
    if (!data_.empty () &&
        (!uncaught_exception () /*|| exception_unwinding_dtor*/))
    {
      data_.back ().msg = os_.str (); // Save last message.

      assert (epilogue_ != nullptr);
      (*epilogue_) (move (data_)); // Can throw.
    }
  }
}