blob: b6466b8a493f56d004a58252553595d733ab857c [file] [log] [blame]
Hans Wennborg0472f8c2020-04-23 19:27:27 +00001// Copyright 2020 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef BASE_NOTREACHED_H_
6#define BASE_NOTREACHED_H_
7
8#include "base/check.h"
9#include "base/logging_buildflags.h"
Hans Wennborg0472f8c2020-04-23 19:27:27 +000010
11namespace logging {
12
13#if BUILDFLAG(ENABLE_LOG_ERROR_NOT_REACHED)
14void BASE_EXPORT LogErrorNotReached(const char* file, int line);
15#define NOTREACHED() \
16 true ? ::logging::LogErrorNotReached(__FILE__, __LINE__) \
17 : EAT_CHECK_STREAM_PARAMS()
18#else
19#define NOTREACHED() DCHECK(false)
20#endif
21
22// The NOTIMPLEMENTED() macro annotates codepaths which have not been
23// implemented yet. If output spam is a serious concern,
24// NOTIMPLEMENTED_LOG_ONCE can be used.
25#if DCHECK_IS_ON()
Hans Wennborg0472f8c2020-04-23 19:27:27 +000026#define NOTIMPLEMENTED() \
27 ::logging::CheckError::NotImplemented(__FILE__, __LINE__, \
28 __PRETTY_FUNCTION__) \
29 .stream()
30#else
Hans Wennborg0472f8c2020-04-23 19:27:27 +000031#define NOTIMPLEMENTED() EAT_CHECK_STREAM_PARAMS()
32#endif
33
34#define NOTIMPLEMENTED_LOG_ONCE() \
35 { \
36 static bool logged_once = false; \
37 if (!logged_once) { \
38 NOTIMPLEMENTED(); \
39 logged_once = true; \
40 } \
41 } \
42 EAT_CHECK_STREAM_PARAMS()
43
44} // namespace logging
45
46#endif // BASE_NOTREACHED_H_