clang API Documentation

HeaderSearchOptions.h
Go to the documentation of this file.
00001 //===--- HeaderSearchOptions.h ----------------------------------*- C++ -*-===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 
00010 #ifndef LLVM_CLANG_FRONTEND_HEADERSEARCHOPTIONS_H
00011 #define LLVM_CLANG_FRONTEND_HEADERSEARCHOPTIONS_H
00012 
00013 #include "llvm/ADT/StringRef.h"
00014 #include <vector>
00015 
00016 namespace clang {
00017 
00018 namespace frontend {
00019   /// IncludeDirGroup - Identifiers the group a include entry belongs to, which
00020   /// represents its relative positive in the search list.  A #include of a ""
00021   /// path starts at the -iquote group, then searches the Angled group, then
00022   /// searches the system group, etc.
00023   enum IncludeDirGroup {
00024     Quoted = 0,     ///< '#include ""' paths, added by'gcc -iquote'.
00025     Angled,         ///< Paths for '#include <>' added by '-I'.
00026     IndexHeaderMap, ///< Like Angled, but marks header maps used when
00027                        ///  building frameworks.
00028     System,         ///< Like Angled, but marks system directories.
00029     CSystem,        ///< Like System, but only used for C.
00030     CXXSystem,      ///< Like System, but only used for C++.
00031     ObjCSystem,     ///< Like System, but only used for ObjC.
00032     ObjCXXSystem,   ///< Like System, but only used for ObjC++.
00033     After           ///< Like System, but searched after the system directories.
00034   };
00035 }
00036 
00037 /// HeaderSearchOptions - Helper class for storing options related to the
00038 /// initialization of the HeaderSearch object.
00039 class HeaderSearchOptions {
00040 public:
00041   struct Entry {
00042     std::string Path;
00043     frontend::IncludeDirGroup Group;
00044     unsigned IsUserSupplied : 1;
00045     unsigned IsFramework : 1;
00046     
00047     /// IgnoreSysRoot - This is false if an absolute path should be treated
00048     /// relative to the sysroot, or true if it should always be the absolute
00049     /// path.
00050     unsigned IgnoreSysRoot : 1;
00051 
00052     /// \brief True if this entry is an internal search path.
00053     ///
00054     /// This typically indicates that users didn't directly provide it, but
00055     /// instead it was provided by a compatibility layer for a particular
00056     /// system. This isn't redundant with IsUserSupplied (even though perhaps
00057     /// it should be) because that is false for user provided '-iwithprefix'
00058     /// header search entries.
00059     unsigned IsInternal : 1;
00060 
00061     /// \brief True if this entry's headers should be wrapped in extern "C".
00062     unsigned ImplicitExternC : 1;
00063 
00064     Entry(StringRef path, frontend::IncludeDirGroup group,
00065           bool isUserSupplied, bool isFramework, bool ignoreSysRoot,
00066           bool isInternal, bool implicitExternC)
00067       : Path(path), Group(group), IsUserSupplied(isUserSupplied),
00068         IsFramework(isFramework), IgnoreSysRoot(ignoreSysRoot),
00069         IsInternal(isInternal), ImplicitExternC(implicitExternC) {}
00070   };
00071 
00072   /// If non-empty, the directory to use as a "virtual system root" for include
00073   /// paths.
00074   std::string Sysroot;
00075 
00076   /// User specified include entries.
00077   std::vector<Entry> UserEntries;
00078 
00079   /// The directory which holds the compiler resource files (builtin includes,
00080   /// etc.).
00081   std::string ResourceDir;
00082 
00083   /// \brief The directory used for the module cache.
00084   std::string ModuleCachePath;
00085   
00086   /// \brief Whether we should disable the use of the hash string within the
00087   /// module cache.
00088   ///
00089   /// Note: Only used for testing!
00090   unsigned DisableModuleHash : 1;
00091   
00092   /// Include the compiler builtin includes.
00093   unsigned UseBuiltinIncludes : 1;
00094 
00095   /// Include the system standard include search directories.
00096   unsigned UseStandardSystemIncludes : 1;
00097 
00098   /// Include the system standard C++ library include search directories.
00099   unsigned UseStandardCXXIncludes : 1;
00100 
00101   /// Use libc++ instead of the default libstdc++.
00102   unsigned UseLibcxx : 1;
00103 
00104   /// Whether header search information should be output as for -v.
00105   unsigned Verbose : 1;
00106 
00107 public:
00108   HeaderSearchOptions(StringRef _Sysroot = "/")
00109     : Sysroot(_Sysroot), DisableModuleHash(0), UseBuiltinIncludes(true),
00110       UseStandardSystemIncludes(true), UseStandardCXXIncludes(true),
00111       UseLibcxx(false), Verbose(false) {}
00112 
00113   /// AddPath - Add the \arg Path path to the specified \arg Group list.
00114   void AddPath(StringRef Path, frontend::IncludeDirGroup Group,
00115                bool IsUserSupplied, bool IsFramework, bool IgnoreSysRoot,
00116                bool IsInternal = false, bool ImplicitExternC = false) {
00117     UserEntries.push_back(Entry(Path, Group, IsUserSupplied, IsFramework,
00118                                 IgnoreSysRoot, IsInternal, ImplicitExternC));
00119   }
00120 };
00121 
00122 } // end namespace clang
00123 
00124 #endif