• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_MESSAGE_HANDLING_H
10 #define MCLD_MESSAGE_HANDLING_H
11 #ifdef ENABLE_UNITTEST
12 #include <gtest.h>
13 #endif
14 #include <mcld/LD/MsgHandler.h>
15 
16 namespace mcld {
17 
18 class LinkerConfig;
19 class DiagnosticPrinter;
20 class DiagnosticLineInfo;
21 
22 void InitializeDiagnosticEngine(const LinkerConfig& pConfig,
23                                 DiagnosticPrinter* pPrinter = NULL);
24 
25 void FinalizeDiagnosticEngine();
26 
27 bool Diagnose();
28 
29 DiagnosticEngine& getDiagnosticEngine();
30 
31 MsgHandler unreachable(unsigned int pID);
32 MsgHandler fatal(unsigned int pID);
33 MsgHandler error(unsigned int pID);
34 MsgHandler warning(unsigned int pID);
35 MsgHandler debug(unsigned int pID);
36 MsgHandler note(unsigned int pID);
37 MsgHandler ignore(unsigned int pID);
38 
39 } // namespace of mcld
40 
41 //===----------------------------------------------------------------------===//
42 //  Inline functions
43 //===----------------------------------------------------------------------===//
unreachable(unsigned int pID)44 inline mcld::MsgHandler mcld::unreachable(unsigned int pID)
45 {
46   return getDiagnosticEngine().report(pID, DiagnosticEngine::Unreachable);
47 }
48 
fatal(unsigned int pID)49 inline mcld::MsgHandler mcld::fatal(unsigned int pID)
50 {
51   return getDiagnosticEngine().report(pID, DiagnosticEngine::Fatal);
52 }
53 
error(unsigned int pID)54 inline mcld::MsgHandler mcld::error(unsigned int pID)
55 {
56   return getDiagnosticEngine().report(pID, DiagnosticEngine::Error);
57 }
58 
warning(unsigned int pID)59 inline mcld::MsgHandler mcld::warning(unsigned int pID)
60 {
61   return getDiagnosticEngine().report(pID, DiagnosticEngine::Warning);
62 }
63 
debug(unsigned int pID)64 inline mcld::MsgHandler mcld::debug(unsigned int pID)
65 {
66   return getDiagnosticEngine().report(pID, DiagnosticEngine::Debug);
67 }
68 
note(unsigned int pID)69 inline mcld::MsgHandler mcld::note(unsigned int pID)
70 {
71   return getDiagnosticEngine().report(pID, DiagnosticEngine::Note);
72 }
73 
ignore(unsigned int pID)74 inline mcld::MsgHandler mcld::ignore(unsigned int pID)
75 {
76   return getDiagnosticEngine().report(pID, DiagnosticEngine::Ignore);
77 }
78 
79 #endif
80 
81