Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:36:49

0001 //===--- HeaderInclude.h - Header Include -----------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 ///
0009 /// \file
0010 /// Defines enums used when emitting included header information.
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 /// The format in which header information is emitted.
0022 enum HeaderIncludeFormatKind { HIFMT_None, HIFMT_Textual, HIFMT_JSON };
0023 
0024 /// Whether header information is filtered or not. If HIFIL_Only_Direct_System
0025 /// is used, only information on system headers directly included from
0026 /// non-system headers is emitted.
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 } // end namespace clang
0072 
0073 #endif // LLVM_CLANG_BASIC_HEADERINCLUDEFORMATKIND_H