HeaderSearchOptions.h revision 9946fc735d7285f2195f89635370f534afd9877e
163c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar//===--- HeaderSearchOptions.h ----------------------------------*- C++ -*-===// 263c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar// 363c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar// The LLVM Compiler Infrastructure 463c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar// 563c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar// This file is distributed under the University of Illinois Open Source 663c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar// License. See LICENSE.TXT for details. 763c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar// 863c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar//===----------------------------------------------------------------------===// 963c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar 10c042edd54face617a3b9d0b4b9d5a3ff229d0f48Douglas Gregor#ifndef LLVM_CLANG_LEX_HEADERSEARCHOPTIONS_H 11c042edd54face617a3b9d0b4b9d5a3ff229d0f48Douglas Gregor#define LLVM_CLANG_LEX_HEADERSEARCHOPTIONS_H 1263c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar 139946fc735d7285f2195f89635370f534afd9877eDmitri Gribenko#include "clang/Basic/LLVM.h" 14c042edd54face617a3b9d0b4b9d5a3ff229d0f48Douglas Gregor#include "llvm/ADT/IntrusiveRefCntPtr.h" 1563c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar#include "llvm/ADT/StringRef.h" 16a61066310d4544d6343154eb3f4448fec0b15420Douglas Gregor#include <vector> 1763c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar 1863c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbarnamespace clang { 1963c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar 202cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbarnamespace frontend { 212cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar /// IncludeDirGroup - Identifiers the group a include entry belongs to, which 22809d1be9820039b4cf6efa48246a0d70ffa13394James Dennett /// represents its relative positive in the search list. A \#include of a "" 2312ee102774c747874f0a6904089100667153b0c0Chris Lattner /// path starts at the -iquote group, then searches the Angled group, then 2412ee102774c747874f0a6904089100667153b0c0Chris Lattner /// searches the system group, etc. 252cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar enum IncludeDirGroup { 26809d1be9820039b4cf6efa48246a0d70ffa13394James Dennett Quoted = 0, ///< '\#include ""' paths, added by 'gcc -iquote'. 27809d1be9820039b4cf6efa48246a0d70ffa13394James Dennett Angled, ///< Paths for '\#include <>' added by '-I'. 2865e02fa80e1c185f18e5f81cefc30d75383a7301Douglas Gregor IndexHeaderMap, ///< Like Angled, but marks header maps used when 2965e02fa80e1c185f18e5f81cefc30d75383a7301Douglas Gregor /// building frameworks. 302cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar System, ///< Like Angled, but marks system directories. 3147adebef0df6dce752fe9a45e9190e8005b5d07cBenjamin Kramer CSystem, ///< Like System, but only used for C. 322df6647847af283302834dadae5d9dcefa7e0ad4Joerg Sonnenberger CXXSystem, ///< Like System, but only used for C++. 3347adebef0df6dce752fe9a45e9190e8005b5d07cBenjamin Kramer ObjCSystem, ///< Like System, but only used for ObjC. 3447adebef0df6dce752fe9a45e9190e8005b5d07cBenjamin Kramer ObjCXXSystem, ///< Like System, but only used for ObjC++. 352cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar After ///< Like System, but searched after the system directories. 362cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar }; 372cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar} 382cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar 3963c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar/// HeaderSearchOptions - Helper class for storing options related to the 4063c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar/// initialization of the HeaderSearch object. 41c042edd54face617a3b9d0b4b9d5a3ff229d0f48Douglas Gregorclass HeaderSearchOptions : public llvm::RefCountedBase<HeaderSearchOptions> { 4263c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbarpublic: 4363c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar struct Entry { 4463c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar std::string Path; 452cdafa8001ee69b75d2906cbb36f16cf8e1dc60aDaniel Dunbar frontend::IncludeDirGroup Group; 4663c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar unsigned IsUserSupplied : 1; 4763c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar unsigned IsFramework : 1; 4823637beead1fce7dac755890c9482bcdce538b87Chris Lattner 495dd45f13dc4463f0c18b923fe6795ce55103301dBob Wilson /// IgnoreSysRoot - This is false if an absolute path should be treated 505dd45f13dc4463f0c18b923fe6795ce55103301dBob Wilson /// relative to the sysroot, or true if it should always be the absolute 5123637beead1fce7dac755890c9482bcdce538b87Chris Lattner /// path. 525dd45f13dc4463f0c18b923fe6795ce55103301dBob Wilson unsigned IgnoreSysRoot : 1; 5323637beead1fce7dac755890c9482bcdce538b87Chris Lattner 54ac2bc4d220a6263be96b943e9162f4a11149e26dChandler Carruth /// \brief True if this entry is an internal search path. 55ac2bc4d220a6263be96b943e9162f4a11149e26dChandler Carruth /// 56ac2bc4d220a6263be96b943e9162f4a11149e26dChandler Carruth /// This typically indicates that users didn't directly provide it, but 57ac2bc4d220a6263be96b943e9162f4a11149e26dChandler Carruth /// instead it was provided by a compatibility layer for a particular 58ac2bc4d220a6263be96b943e9162f4a11149e26dChandler Carruth /// system. This isn't redundant with IsUserSupplied (even though perhaps 59ac2bc4d220a6263be96b943e9162f4a11149e26dChandler Carruth /// it should be) because that is false for user provided '-iwithprefix' 60ac2bc4d220a6263be96b943e9162f4a11149e26dChandler Carruth /// header search entries. 61ac2bc4d220a6263be96b943e9162f4a11149e26dChandler Carruth unsigned IsInternal : 1; 62ac2bc4d220a6263be96b943e9162f4a11149e26dChandler Carruth 63ac2bc4d220a6263be96b943e9162f4a11149e26dChandler Carruth /// \brief True if this entry's headers should be wrapped in extern "C". 64ac2bc4d220a6263be96b943e9162f4a11149e26dChandler Carruth unsigned ImplicitExternC : 1; 65ac2bc4d220a6263be96b943e9162f4a11149e26dChandler Carruth 66686775deca8b8685eb90801495880e3abdd844c2Chris Lattner Entry(StringRef path, frontend::IncludeDirGroup group, 67ac2bc4d220a6263be96b943e9162f4a11149e26dChandler Carruth bool isUserSupplied, bool isFramework, bool ignoreSysRoot, 68ac2bc4d220a6263be96b943e9162f4a11149e26dChandler Carruth bool isInternal, bool implicitExternC) 6923637beead1fce7dac755890c9482bcdce538b87Chris Lattner : Path(path), Group(group), IsUserSupplied(isUserSupplied), 70ac2bc4d220a6263be96b943e9162f4a11149e26dChandler Carruth IsFramework(isFramework), IgnoreSysRoot(ignoreSysRoot), 71ac2bc4d220a6263be96b943e9162f4a11149e26dChandler Carruth IsInternal(isInternal), ImplicitExternC(implicitExternC) {} 7263c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar }; 7363c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar 74f122a138e39dbb29162abfa9a3d44091d8efa7afRichard Smith struct SystemHeaderPrefix { 752edbc98b046de22f3aba3c5142e85e7f3437fd03James Dennett /// A prefix to be matched against paths in \#include directives. 76f122a138e39dbb29162abfa9a3d44091d8efa7afRichard Smith std::string Prefix; 77f122a138e39dbb29162abfa9a3d44091d8efa7afRichard Smith 78f122a138e39dbb29162abfa9a3d44091d8efa7afRichard Smith /// True if paths beginning with this prefix should be treated as system 79f122a138e39dbb29162abfa9a3d44091d8efa7afRichard Smith /// headers. 80f122a138e39dbb29162abfa9a3d44091d8efa7afRichard Smith bool IsSystemHeader; 81f122a138e39dbb29162abfa9a3d44091d8efa7afRichard Smith 82f122a138e39dbb29162abfa9a3d44091d8efa7afRichard Smith SystemHeaderPrefix(StringRef Prefix, bool IsSystemHeader) 83f122a138e39dbb29162abfa9a3d44091d8efa7afRichard Smith : Prefix(Prefix), IsSystemHeader(IsSystemHeader) {} 84f122a138e39dbb29162abfa9a3d44091d8efa7afRichard Smith }; 85f122a138e39dbb29162abfa9a3d44091d8efa7afRichard Smith 8663c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar /// If non-empty, the directory to use as a "virtual system root" for include 8763c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar /// paths. 8863c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar std::string Sysroot; 8963c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar 9063c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar /// User specified include entries. 9163c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar std::vector<Entry> UserEntries; 9263c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar 93f122a138e39dbb29162abfa9a3d44091d8efa7afRichard Smith /// User-specified system header prefixes. 94f122a138e39dbb29162abfa9a3d44091d8efa7afRichard Smith std::vector<SystemHeaderPrefix> SystemHeaderPrefixes; 95f122a138e39dbb29162abfa9a3d44091d8efa7afRichard Smith 968b9adfea5e834eaee0f45d8cc7fb052d68df4a46Daniel Dunbar /// The directory which holds the compiler resource files (builtin includes, 978b9adfea5e834eaee0f45d8cc7fb052d68df4a46Daniel Dunbar /// etc.). 988b9adfea5e834eaee0f45d8cc7fb052d68df4a46Daniel Dunbar std::string ResourceDir; 9963c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar 1009a6da6930644b4f2dbe4885b0eb4fc1274ff56a4Douglas Gregor /// \brief The directory used for the module cache. 1019a6da6930644b4f2dbe4885b0eb4fc1274ff56a4Douglas Gregor std::string ModuleCachePath; 1029a6da6930644b4f2dbe4885b0eb4fc1274ff56a4Douglas Gregor 1036e975c4517958bcc11c834336d340797356058dbDouglas Gregor /// \brief Whether we should disable the use of the hash string within the 1046e975c4517958bcc11c834336d340797356058dbDouglas Gregor /// module cache. 1056e975c4517958bcc11c834336d340797356058dbDouglas Gregor /// 1066e975c4517958bcc11c834336d340797356058dbDouglas Gregor /// Note: Only used for testing! 1076e975c4517958bcc11c834336d340797356058dbDouglas Gregor unsigned DisableModuleHash : 1; 1086e975c4517958bcc11c834336d340797356058dbDouglas Gregor 1091e69fe3a9f0a42b32a3000bda51677d51416564eDaniel Dunbar /// Include the compiler builtin includes. 1101e69fe3a9f0a42b32a3000bda51677d51416564eDaniel Dunbar unsigned UseBuiltinIncludes : 1; 1111e69fe3a9f0a42b32a3000bda51677d51416564eDaniel Dunbar 11263c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar /// Include the system standard include search directories. 113a268fc0f2229eb132ebc8501b140093aeb5516bfDaniel Dunbar unsigned UseStandardSystemIncludes : 1; 11463c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar 1154c2bcad7b843c10fd4a2ffd43da40bfefb4dc8baDouglas Gregor /// Include the system standard C++ library include search directories. 1164c2bcad7b843c10fd4a2ffd43da40bfefb4dc8baDouglas Gregor unsigned UseStandardCXXIncludes : 1; 1174c2bcad7b843c10fd4a2ffd43da40bfefb4dc8baDouglas Gregor 11813c4f2144b35bda21746eb60ad90e52a9bd8dcdaBob Wilson /// Use libc++ instead of the default libstdc++. 11913c4f2144b35bda21746eb60ad90e52a9bd8dcdaBob Wilson unsigned UseLibcxx : 1; 12013c4f2144b35bda21746eb60ad90e52a9bd8dcdaBob Wilson 12163c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar /// Whether header search information should be output as for -v. 12263c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar unsigned Verbose : 1; 12363c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar 12463c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbarpublic: 125686775deca8b8685eb90801495880e3abdd844c2Chris Lattner HeaderSearchOptions(StringRef _Sysroot = "/") 1266e975c4517958bcc11c834336d340797356058dbDouglas Gregor : Sysroot(_Sysroot), DisableModuleHash(0), UseBuiltinIncludes(true), 127a268fc0f2229eb132ebc8501b140093aeb5516bfDaniel Dunbar UseStandardSystemIncludes(true), UseStandardCXXIncludes(true), 128a268fc0f2229eb132ebc8501b140093aeb5516bfDaniel Dunbar UseLibcxx(false), Verbose(false) {} 12963c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar 1301824d54df85a462ada812dadda18130f951d40f3Dmitri Gribenko /// AddPath - Add the \p Path path to the specified \p Group list. 131686775deca8b8685eb90801495880e3abdd844c2Chris Lattner void AddPath(StringRef Path, frontend::IncludeDirGroup Group, 132ac2bc4d220a6263be96b943e9162f4a11149e26dChandler Carruth bool IsUserSupplied, bool IsFramework, bool IgnoreSysRoot, 133ac2bc4d220a6263be96b943e9162f4a11149e26dChandler Carruth bool IsInternal = false, bool ImplicitExternC = false) { 13423637beead1fce7dac755890c9482bcdce538b87Chris Lattner UserEntries.push_back(Entry(Path, Group, IsUserSupplied, IsFramework, 135ac2bc4d220a6263be96b943e9162f4a11149e26dChandler Carruth IgnoreSysRoot, IsInternal, ImplicitExternC)); 13663c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar } 137f122a138e39dbb29162abfa9a3d44091d8efa7afRichard Smith 1382edbc98b046de22f3aba3c5142e85e7f3437fd03James Dennett /// AddSystemHeaderPrefix - Override whether \#include directives naming a 1391824d54df85a462ada812dadda18130f951d40f3Dmitri Gribenko /// path starting with \p Prefix should be considered as naming a system 140f122a138e39dbb29162abfa9a3d44091d8efa7afRichard Smith /// header. 141f122a138e39dbb29162abfa9a3d44091d8efa7afRichard Smith void AddSystemHeaderPrefix(StringRef Prefix, bool IsSystemHeader) { 142f122a138e39dbb29162abfa9a3d44091d8efa7afRichard Smith SystemHeaderPrefixes.push_back(SystemHeaderPrefix(Prefix, IsSystemHeader)); 143f122a138e39dbb29162abfa9a3d44091d8efa7afRichard Smith } 14463c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar}; 14563c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar 14663c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar} // end namespace clang 14763c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar 14863c8b77334f90472260d2f48df2742ed5067261eDaniel Dunbar#endif 149