summaryrefslogtreecommitdiff
path: root/chromium/base/notreached.h
blob: 009c2aa2d0cb4e6bbfa1eea68dfa0fd599524b3d (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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef BASE_NOTREACHED_H_
#define BASE_NOTREACHED_H_

#include "base/check.h"
#include "base/logging_buildflags.h"

namespace logging {

#if BUILDFLAG(ENABLE_LOG_ERROR_NOT_REACHED)
void BASE_EXPORT LogErrorNotReached(const char* file, int line);
#define NOTREACHED()                                       \
  true ? ::logging::LogErrorNotReached(__FILE__, __LINE__) \
       : EAT_CHECK_STREAM_PARAMS()
#else
#define NOTREACHED() DCHECK(false)
#endif

// The NOTIMPLEMENTED() macro annotates codepaths which have not been
// implemented yet. If output spam is a serious concern,
// NOTIMPLEMENTED_LOG_ONCE can be used.
#if DCHECK_IS_ON()
#ifdef _MSC_VER
#define NOTIMPLEMENTED()                                     \
  ::logging::CheckError::NotImplemented(__FILE__, __LINE__,  \
                                        __FUNCSIG__)         \
      .stream()
#else
#define NOTIMPLEMENTED()                                     \
  ::logging::CheckError::NotImplemented(__FILE__, __LINE__,  \
                                        __PRETTY_FUNCTION__) \
      .stream()
#endif
#else
#define NOTIMPLEMENTED() EAT_CHECK_STREAM_PARAMS()
#endif

#define NOTIMPLEMENTED_LOG_ONCE()    \
  {                                  \
    static bool logged_once = false; \
    if (!logged_once) {              \
      NOTIMPLEMENTED();              \
      logged_once = true;            \
    }                                \
  }                                  \
  EAT_CHECK_STREAM_PARAMS()

}  // namespace logging

#endif  // BASE_NOTREACHED_H_