clang 22.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 files is emitted. The HIFIL_Direct_Per_File filtering shows the
27/// direct imports and includes for each non-system source and header file
28/// separately.
34
35inline HeaderIncludeFormatKind
37 return llvm::StringSwitch<HeaderIncludeFormatKind>(Str)
38 .Case("textual", HIFMT_Textual)
39 .Case("json", HIFMT_JSON)
40 .Default(HIFMT_None);
41}
42
43inline bool stringToHeaderIncludeFiltering(const char *Str,
45 std::pair<bool, HeaderIncludeFilteringKind> P =
46 llvm::StringSwitch<std::pair<bool, HeaderIncludeFilteringKind>>(Str)
47 .Case("none", {true, HIFIL_None})
48 .Case("only-direct-system", {true, HIFIL_Only_Direct_System})
49 .Case("direct-per-file", {true, HIFIL_Direct_Per_File})
50 .Default({false, HIFIL_None});
51 Kind = P.second;
52 return P.first;
53}
54
56 switch (K) {
57 case HIFMT_None:
58 llvm_unreachable("unexpected format kind");
59 case HIFMT_Textual:
60 return "textual";
61 case HIFMT_JSON:
62 return "json";
63 }
64 llvm_unreachable("Unknown HeaderIncludeFormatKind enum");
65}
66
67inline const char *
69 switch (K) {
70 case HIFIL_None:
71 return "none";
73 return "only-direct-system";
75 return "direct-per-file";
76 }
77 llvm_unreachable("Unknown HeaderIncludeFilteringKind enum");
78}
79
80} // end namespace clang
81
82#endif // LLVM_CLANG_BASIC_HEADERINCLUDEFORMATKIND_H
The JSON file list parser is used to communicate input to InstallAPI.
const char * headerIncludeFormatKindToString(HeaderIncludeFormatKind K)
const char * headerIncludeFilteringKindToString(HeaderIncludeFilteringKind K)
HeaderIncludeFilteringKind
Whether header information is filtered or not.
@ HIFIL_Direct_Per_File
@ HIFIL_Only_Direct_System
HeaderIncludeFormatKind stringToHeaderIncludeFormatKind(const char *Str)
bool stringToHeaderIncludeFiltering(const char *Str, HeaderIncludeFilteringKind &Kind)
HeaderIncludeFormatKind
The format in which header information is emitted.
@ HIFMT_Textual