mirror of
https://gitlab.kitware.com/cmake/cmake.git
synced 2026-09-25 04:09:36 +03:00
Create new cmDiagnosticContext used to capture the diagnostic state for instances when the issuing of a diagnostic might happen at a point far separated from processing the CMake command ultimately responsible for the diagnostic. (This is particularly the case for diagnostics that get emitted during the generation phase.) In such cases, it is preferred that we record the diagnostic state that pertained when the ultimately instigating command was processed, so that users can control the diagnostic in a natural manner. Copying the entire cmStateSnapshot is unreasonably expensive; this will provide a lighter-weight mechanism for capturing the relevant diagnostic state for later use. Since it is almost universal that the points where we would capture this state also capture a stack trace (which is likewise used to issue diagnostics), the new class contains a stack trace, and replaces the stack trace in some diagnostic calls. (In some instances, an overload which implicitly converts a stack trace to the new context class is retained for convenience. These will behave the same, since capturing diagnostic state is an optional function of the new class.)
15 lines
471 B
C++
15 lines
471 B
C++
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
file LICENSE.rst or https://cmake.org/licensing for details. */
|
|
#include "cmDiagnosticContext.h"
|
|
|
|
#include <array>
|
|
|
|
#include "cmStateSnapshot.h"
|
|
|
|
void cmDiagnosticContext::RecordDiagnostic(cmDiagnosticCategory category,
|
|
cmStateSnapshot const& state)
|
|
{
|
|
this->DiagnosticState[category] = state.GetDiagnostic(category);
|
|
this->HasState = true;
|
|
}
|