Home | History | Annotate | Download | only in Frontend
      1 //===--- HeaderSearchOptions.h ----------------------------------*- C++ -*-===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is distributed under the University of Illinois Open Source
      6 // License. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 
     10 #ifndef LLVM_CLANG_FRONTEND_HEADERSEARCHOPTIONS_H
     11 #define LLVM_CLANG_FRONTEND_HEADERSEARCHOPTIONS_H
     12 
     13 #include "llvm/ADT/StringRef.h"
     14 #include <vector>
     15 
     16 namespace clang {
     17 
     18 namespace frontend {
     19   /// IncludeDirGroup - Identifiers the group a include entry belongs to, which
     20   /// represents its relative positive in the search list.  A #include of a ""
     21   /// path starts at the -iquote group, then searches the Angled group, then
     22   /// searches the system group, etc.
     23   enum IncludeDirGroup {
     24     Quoted = 0,     ///< '#include ""' paths, added by'gcc -iquote'.
     25     Angled,         ///< Paths for '#include <>' added by '-I'.
     26     IndexHeaderMap, ///< Like Angled, but marks header maps used when
     27                        ///  building frameworks.
     28     System,         ///< Like Angled, but marks system directories.
     29     CSystem,        ///< Like System, but only used for C.
     30     CXXSystem,      ///< Like System, but only used for C++.
     31     ObjCSystem,     ///< Like System, but only used for ObjC.
     32     ObjCXXSystem,   ///< Like System, but only used for ObjC++.
     33     After           ///< Like System, but searched after the system directories.
     34   };
     35 }
     36 
     37 /// HeaderSearchOptions - Helper class for storing options related to the
     38 /// initialization of the HeaderSearch object.
     39 class HeaderSearchOptions {
     40 public:
     41   struct Entry {
     42     std::string Path;
     43     frontend::IncludeDirGroup Group;
     44     unsigned IsUserSupplied : 1;
     45     unsigned IsFramework : 1;
     46 
     47     /// IgnoreSysRoot - This is false if an absolute path should be treated
     48     /// relative to the sysroot, or true if it should always be the absolute
     49     /// path.
     50     unsigned IgnoreSysRoot : 1;
     51 
     52     Entry(StringRef path, frontend::IncludeDirGroup group,
     53           bool isUserSupplied, bool isFramework, bool ignoreSysRoot)
     54       : Path(path), Group(group), IsUserSupplied(isUserSupplied),
     55         IsFramework(isFramework), IgnoreSysRoot(ignoreSysRoot) {}
     56   };
     57 
     58   /// If non-empty, the directory to use as a "virtual system root" for include
     59   /// paths.
     60   std::string Sysroot;
     61 
     62   /// User specified include entries.
     63   std::vector<Entry> UserEntries;
     64 
     65   /// The directory which holds the compiler resource files (builtin includes,
     66   /// etc.).
     67   std::string ResourceDir;
     68 
     69   /// \brief The directory used for the module cache.
     70   std::string ModuleCachePath;
     71 
     72   /// \brief Whether we should disable the use of the hash string within the
     73   /// module cache.
     74   ///
     75   /// Note: Only used for testing!
     76   unsigned DisableModuleHash : 1;
     77 
     78   /// Include the compiler builtin includes.
     79   unsigned UseBuiltinIncludes : 1;
     80 
     81   /// Include the system standard include search directories.
     82   unsigned UseStandardSystemIncludes : 1;
     83 
     84   /// Include the system standard C++ library include search directories.
     85   unsigned UseStandardCXXIncludes : 1;
     86 
     87   /// Use libc++ instead of the default libstdc++.
     88   unsigned UseLibcxx : 1;
     89 
     90   /// Whether header search information should be output as for -v.
     91   unsigned Verbose : 1;
     92 
     93 public:
     94   HeaderSearchOptions(StringRef _Sysroot = "/")
     95     : Sysroot(_Sysroot), DisableModuleHash(0), UseBuiltinIncludes(true),
     96       UseStandardSystemIncludes(true), UseStandardCXXIncludes(true),
     97       UseLibcxx(false), Verbose(false) {}
     98 
     99   /// AddPath - Add the \arg Path path to the specified \arg Group list.
    100   void AddPath(StringRef Path, frontend::IncludeDirGroup Group,
    101                bool IsUserSupplied, bool IsFramework, bool IgnoreSysRoot) {
    102     UserEntries.push_back(Entry(Path, Group, IsUserSupplied, IsFramework,
    103                                 IgnoreSysRoot));
    104   }
    105 };
    106 
    107 } // end namespace clang
    108 
    109 #endif
    110