clang 19.0.0git
HeaderInclude.h
Go to the documentation of this file.
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
20namespace clang {
21/// The format in which header information is emitted.
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.
28
31 return llvm::StringSwitch<HeaderIncludeFormatKind>(Str)
32 .Case("textual", HIFMT_Textual)
33 .Case("json", HIFMT_JSON)
34 .Default(HIFMT_None);
35}
36
37inline bool stringToHeaderIncludeFiltering(const char *Str,
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
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
60inline const char *
62 switch (K) {
63 case HIFIL_None:
64 return "none";
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
StringRef P
The JSON file list parser is used to communicate input to InstallAPI.
const char * headerIncludeFormatKindToString(HeaderIncludeFormatKind K)
Definition: HeaderInclude.h:48
const char * headerIncludeFilteringKindToString(HeaderIncludeFilteringKind K)
Definition: HeaderInclude.h:61
HeaderIncludeFilteringKind
Whether header information is filtered or not.
Definition: HeaderInclude.h:27
@ HIFIL_None
Definition: HeaderInclude.h:27
@ HIFIL_Only_Direct_System
Definition: HeaderInclude.h:27
HeaderIncludeFormatKind stringToHeaderIncludeFormatKind(const char *Str)
Definition: HeaderInclude.h:30
bool stringToHeaderIncludeFiltering(const char *Str, HeaderIncludeFilteringKind &Kind)
Definition: HeaderInclude.h:37
HeaderIncludeFormatKind
The format in which header information is emitted.
Definition: HeaderInclude.h:22
@ HIFMT_None
Definition: HeaderInclude.h:22
@ HIFMT_JSON
Definition: HeaderInclude.h:22
@ HIFMT_Textual
Definition: HeaderInclude.h:22