MsgHandling.h revision 87f34658dec9097d987d254a990ea7f311bfc95f
1//===- MsgHandling.h ------------------------------------------------------===//
2//
3//                     The MCLinker Project
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9#ifndef MCLD_SUPPORT_MSGHANDLING_H
10#define MCLD_SUPPORT_MSGHANDLING_H
11#ifdef ENABLE_UNITTEST
12#include <gtest.h>
13#endif
14#include <mcld/LD/MsgHandler.h>
15
16namespace mcld {
17
18class LinkerConfig;
19class DiagnosticPrinter;
20class DiagnosticLineInfo;
21
22void InitializeDiagnosticEngine(const LinkerConfig& pConfig,
23                                DiagnosticPrinter* pPrinter = NULL);
24
25void FinalizeDiagnosticEngine();
26
27bool Diagnose();
28
29DiagnosticEngine& getDiagnosticEngine();
30
31MsgHandler unreachable(unsigned int pID);
32MsgHandler fatal(unsigned int pID);
33MsgHandler error(unsigned int pID);
34MsgHandler warning(unsigned int pID);
35MsgHandler debug(unsigned int pID);
36MsgHandler note(unsigned int pID);
37MsgHandler ignore(unsigned int pID);
38
39} // namespace of mcld
40
41//===----------------------------------------------------------------------===//
42//  Inline functions
43//===----------------------------------------------------------------------===//
44inline mcld::MsgHandler mcld::unreachable(unsigned int pID)
45{
46  return getDiagnosticEngine().report(pID, DiagnosticEngine::Unreachable);
47}
48
49inline mcld::MsgHandler mcld::fatal(unsigned int pID)
50{
51  return getDiagnosticEngine().report(pID, DiagnosticEngine::Fatal);
52}
53
54inline mcld::MsgHandler mcld::error(unsigned int pID)
55{
56  return getDiagnosticEngine().report(pID, DiagnosticEngine::Error);
57}
58
59inline mcld::MsgHandler mcld::warning(unsigned int pID)
60{
61  return getDiagnosticEngine().report(pID, DiagnosticEngine::Warning);
62}
63
64inline mcld::MsgHandler mcld::debug(unsigned int pID)
65{
66  return getDiagnosticEngine().report(pID, DiagnosticEngine::Debug);
67}
68
69inline mcld::MsgHandler mcld::note(unsigned int pID)
70{
71  return getDiagnosticEngine().report(pID, DiagnosticEngine::Note);
72}
73
74inline mcld::MsgHandler mcld::ignore(unsigned int pID)
75{
76  return getDiagnosticEngine().report(pID, DiagnosticEngine::Ignore);
77}
78
79#endif
80
81