Subversion Repositories QNX 8.QNX8 LLVM/Clang compiler suite

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
14 pmbaty 1
//===--- HeaderInclude.h - Header Include -----------------------*- C++ -*-===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
///
9
/// \file
10
/// Defines enums used when emitting included header information.
11
///
12
//===----------------------------------------------------------------------===//
13
 
14
#ifndef LLVM_CLANG_BASIC_HEADERINCLUDEFORMATKIND_H
15
#define LLVM_CLANG_BASIC_HEADERINCLUDEFORMATKIND_H
16
#include "llvm/ADT/StringSwitch.h"
17
#include "llvm/Support/ErrorHandling.h"
18
#include <utility>
19
 
20
namespace clang {
21
/// The format in which header information is emitted.
22
enum HeaderIncludeFormatKind { HIFMT_None, HIFMT_Textual, HIFMT_JSON };
23
 
24
/// Whether header information is filtered or not. If HIFIL_Only_Direct_System
25
/// is used, only information on system headers directly included from
26
/// non-system headers is emitted.
27
enum HeaderIncludeFilteringKind { HIFIL_None, HIFIL_Only_Direct_System };
28
 
29
inline HeaderIncludeFormatKind
30
stringToHeaderIncludeFormatKind(const char *Str) {
31
  return llvm::StringSwitch<HeaderIncludeFormatKind>(Str)
32
      .Case("textual", HIFMT_Textual)
33
      .Case("json", HIFMT_JSON)
34
      .Default(HIFMT_None);
35
}
36
 
37
inline bool stringToHeaderIncludeFiltering(const char *Str,
38
                                           HeaderIncludeFilteringKind &Kind) {
39
  std::pair<bool, HeaderIncludeFilteringKind> P =
40
      llvm::StringSwitch<std::pair<bool, HeaderIncludeFilteringKind>>(Str)
41
          .Case("none", {true, HIFIL_None})
42
          .Case("only-direct-system", {true, HIFIL_Only_Direct_System})
43
          .Default({false, HIFIL_None});
44
  Kind = P.second;
45
  return P.first;
46
}
47
 
48
inline const char *headerIncludeFormatKindToString(HeaderIncludeFormatKind K) {
49
  switch (K) {
50
  case HIFMT_None:
51
    llvm_unreachable("unexpected format kind");
52
  case HIFMT_Textual:
53
    return "textual";
54
  case HIFMT_JSON:
55
    return "json";
56
  }
57
  llvm_unreachable("Unknown HeaderIncludeFormatKind enum");
58
}
59
 
60
inline const char *
61
headerIncludeFilteringKindToString(HeaderIncludeFilteringKind K) {
62
  switch (K) {
63
  case HIFIL_None:
64
    return "none";
65
  case HIFIL_Only_Direct_System:
66
    return "only-direct-system";
67
  }
68
  llvm_unreachable("Unknown HeaderIncludeFilteringKind enum");
69
}
70
 
71
} // end namespace clang
72
 
73
#endif // LLVM_CLANG_BASIC_HEADERINCLUDEFORMATKIND_H