File indexing completed on 2026-05-10 08:36:49
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014 #ifndef LLVM_CLANG_BASIC_HEADERINCLUDEFORMATKIND_H
0015 #define LLVM_CLANG_BASIC_HEADERINCLUDEFORMATKIND_H
0016 #include "llvm/ADT/StringSwitch.h"
0017 #include "llvm/Support/ErrorHandling.h"
0018 #include <utility>
0019
0020 namespace clang {
0021
0022 enum HeaderIncludeFormatKind { HIFMT_None, HIFMT_Textual, HIFMT_JSON };
0023
0024
0025
0026
0027 enum HeaderIncludeFilteringKind { HIFIL_None, HIFIL_Only_Direct_System };
0028
0029 inline HeaderIncludeFormatKind
0030 stringToHeaderIncludeFormatKind(const char *Str) {
0031 return llvm::StringSwitch<HeaderIncludeFormatKind>(Str)
0032 .Case("textual", HIFMT_Textual)
0033 .Case("json", HIFMT_JSON)
0034 .Default(HIFMT_None);
0035 }
0036
0037 inline bool stringToHeaderIncludeFiltering(const char *Str,
0038 HeaderIncludeFilteringKind &Kind) {
0039 std::pair<bool, HeaderIncludeFilteringKind> P =
0040 llvm::StringSwitch<std::pair<bool, HeaderIncludeFilteringKind>>(Str)
0041 .Case("none", {true, HIFIL_None})
0042 .Case("only-direct-system", {true, HIFIL_Only_Direct_System})
0043 .Default({false, HIFIL_None});
0044 Kind = P.second;
0045 return P.first;
0046 }
0047
0048 inline const char *headerIncludeFormatKindToString(HeaderIncludeFormatKind K) {
0049 switch (K) {
0050 case HIFMT_None:
0051 llvm_unreachable("unexpected format kind");
0052 case HIFMT_Textual:
0053 return "textual";
0054 case HIFMT_JSON:
0055 return "json";
0056 }
0057 llvm_unreachable("Unknown HeaderIncludeFormatKind enum");
0058 }
0059
0060 inline const char *
0061 headerIncludeFilteringKindToString(HeaderIncludeFilteringKind K) {
0062 switch (K) {
0063 case HIFIL_None:
0064 return "none";
0065 case HIFIL_Only_Direct_System:
0066 return "only-direct-system";
0067 }
0068 llvm_unreachable("Unknown HeaderIncludeFilteringKind enum");
0069 }
0070
0071 }
0072
0073 #endif