2009-11-18 14:59:57 +00:00
|
|
|
//===--- HeaderSearchOptions.h ----------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2012-12-02 13:20:44 +00:00
|
|
|
#ifndef LLVM_CLANG_LEX_HEADERSEARCHOPTIONS_H
|
|
|
|
#define LLVM_CLANG_LEX_HEADERSEARCHOPTIONS_H
|
2009-11-18 14:59:57 +00:00
|
|
|
|
2013-04-08 18:45:10 +00:00
|
|
|
#include "clang/Basic/LLVM.h"
|
2012-12-02 13:20:44 +00:00
|
|
|
#include "llvm/ADT/IntrusiveRefCntPtr.h"
|
2013-04-08 18:45:10 +00:00
|
|
|
#include "llvm/ADT/SetVector.h"
|
2009-11-18 14:59:57 +00:00
|
|
|
#include "llvm/ADT/StringRef.h"
|
2013-04-08 18:45:10 +00:00
|
|
|
#include <string>
|
2009-11-18 14:59:57 +00:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace clang {
|
|
|
|
|
|
|
|
namespace frontend {
|
|
|
|
/// IncludeDirGroup - Identifiers the group a include entry belongs to, which
|
2012-08-15 20:02:54 +00:00
|
|
|
/// represents its relative positive in the search list. A \#include of a ""
|
2011-07-17 15:40:56 +00:00
|
|
|
/// path starts at the -iquote group, then searches the Angled group, then
|
|
|
|
/// searches the system group, etc.
|
2009-11-18 14:59:57 +00:00
|
|
|
enum IncludeDirGroup {
|
2012-08-15 20:02:54 +00:00
|
|
|
Quoted = 0, ///< '\#include ""' paths, added by 'gcc -iquote'.
|
|
|
|
Angled, ///< Paths for '\#include <>' added by '-I'.
|
2011-10-20 21:14:49 +00:00
|
|
|
IndexHeaderMap, ///< Like Angled, but marks header maps used when
|
|
|
|
/// building frameworks.
|
2009-11-18 14:59:57 +00:00
|
|
|
System, ///< Like Angled, but marks system directories.
|
2013-04-08 18:45:10 +00:00
|
|
|
ExternCSystem, ///< Like System, but headers are implicitly wrapped in
|
|
|
|
/// extern "C".
|
2011-10-20 21:14:49 +00:00
|
|
|
CSystem, ///< Like System, but only used for C.
|
2011-02-26 22:09:03 +00:00
|
|
|
CXXSystem, ///< Like System, but only used for C++.
|
2011-10-20 21:14:49 +00:00
|
|
|
ObjCSystem, ///< Like System, but only used for ObjC.
|
|
|
|
ObjCXXSystem, ///< Like System, but only used for ObjC++.
|
2009-11-18 14:59:57 +00:00
|
|
|
After ///< Like System, but searched after the system directories.
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/// HeaderSearchOptions - Helper class for storing options related to the
|
|
|
|
/// initialization of the HeaderSearch object.
|
2013-04-08 18:45:10 +00:00
|
|
|
class HeaderSearchOptions : public RefCountedBase<HeaderSearchOptions> {
|
2009-11-18 14:59:57 +00:00
|
|
|
public:
|
|
|
|
struct Entry {
|
|
|
|
std::string Path;
|
|
|
|
frontend::IncludeDirGroup Group;
|
|
|
|
unsigned IsFramework : 1;
|
2010-09-17 15:54:40 +00:00
|
|
|
|
2011-07-17 15:40:56 +00:00
|
|
|
/// IgnoreSysRoot - This is false if an absolute path should be treated
|
|
|
|
/// relative to the sysroot, or true if it should always be the absolute
|
2010-09-17 15:54:40 +00:00
|
|
|
/// path.
|
2011-07-17 15:40:56 +00:00
|
|
|
unsigned IgnoreSysRoot : 1;
|
2010-09-17 15:54:40 +00:00
|
|
|
|
2013-04-08 18:45:10 +00:00
|
|
|
Entry(StringRef path, frontend::IncludeDirGroup group, bool isFramework,
|
|
|
|
bool ignoreSysRoot)
|
|
|
|
: Path(path), Group(group), IsFramework(isFramework),
|
|
|
|
IgnoreSysRoot(ignoreSysRoot) {}
|
2009-11-18 14:59:57 +00:00
|
|
|
};
|
|
|
|
|
2012-08-15 20:02:54 +00:00
|
|
|
struct SystemHeaderPrefix {
|
|
|
|
/// A prefix to be matched against paths in \#include directives.
|
|
|
|
std::string Prefix;
|
|
|
|
|
|
|
|
/// True if paths beginning with this prefix should be treated as system
|
|
|
|
/// headers.
|
|
|
|
bool IsSystemHeader;
|
|
|
|
|
|
|
|
SystemHeaderPrefix(StringRef Prefix, bool IsSystemHeader)
|
|
|
|
: Prefix(Prefix), IsSystemHeader(IsSystemHeader) {}
|
|
|
|
};
|
|
|
|
|
2009-11-18 14:59:57 +00:00
|
|
|
/// If non-empty, the directory to use as a "virtual system root" for include
|
|
|
|
/// paths.
|
|
|
|
std::string Sysroot;
|
|
|
|
|
|
|
|
/// User specified include entries.
|
|
|
|
std::vector<Entry> UserEntries;
|
|
|
|
|
2012-08-15 20:02:54 +00:00
|
|
|
/// User-specified system header prefixes.
|
|
|
|
std::vector<SystemHeaderPrefix> SystemHeaderPrefixes;
|
|
|
|
|
2009-12-15 18:49:47 +00:00
|
|
|
/// The directory which holds the compiler resource files (builtin includes,
|
|
|
|
/// etc.).
|
|
|
|
std::string ResourceDir;
|
|
|
|
|
2011-10-20 21:14:49 +00:00
|
|
|
/// \brief The directory used for the module cache.
|
|
|
|
std::string ModuleCachePath;
|
2013-04-08 18:45:10 +00:00
|
|
|
|
2014-11-24 09:15:30 +00:00
|
|
|
/// \brief The directory used for a user build.
|
|
|
|
std::string ModuleUserBuildPath;
|
|
|
|
|
2011-10-20 21:14:49 +00:00
|
|
|
/// \brief Whether we should disable the use of the hash string within the
|
|
|
|
/// module cache.
|
|
|
|
///
|
|
|
|
/// Note: Only used for testing!
|
|
|
|
unsigned DisableModuleHash : 1;
|
2013-04-08 18:45:10 +00:00
|
|
|
|
2015-06-21 14:00:56 +00:00
|
|
|
/// \brief Implicit module maps. This option is enabld by default when
|
|
|
|
/// modules is enabled.
|
|
|
|
unsigned ImplicitModuleMaps : 1;
|
2013-12-22 00:07:40 +00:00
|
|
|
|
2015-01-18 16:23:48 +00:00
|
|
|
/// \brief Set the 'home directory' of a module map file to the current
|
|
|
|
/// working directory (or the home directory of the module map file that
|
|
|
|
/// contained the 'extern module' directive importing this module map file
|
|
|
|
/// if any) rather than the directory containing the module map file.
|
|
|
|
//
|
|
|
|
/// The home directory is where we look for files named in the module map
|
|
|
|
/// file.
|
|
|
|
unsigned ModuleMapFileHomeIsCwd : 1;
|
|
|
|
|
2013-04-08 18:45:10 +00:00
|
|
|
/// \brief The interval (in seconds) between pruning operations.
|
|
|
|
///
|
|
|
|
/// This operation is expensive, because it requires Clang to walk through
|
|
|
|
/// the directory structure of the module cache, stat()'ing and removing
|
|
|
|
/// files.
|
|
|
|
///
|
|
|
|
/// The default value is large, e.g., the operation runs once a week.
|
|
|
|
unsigned ModuleCachePruneInterval;
|
|
|
|
|
|
|
|
/// \brief The time (in seconds) after which an unused module file will be
|
|
|
|
/// considered unused and will, therefore, be pruned.
|
|
|
|
///
|
|
|
|
/// When the module cache is pruned, any module file that has not been
|
|
|
|
/// accessed in this many seconds will be removed. The default value is
|
|
|
|
/// large, e.g., a month, to avoid forcing infrequently-used modules to be
|
|
|
|
/// regenerated often.
|
|
|
|
unsigned ModuleCachePruneAfter;
|
|
|
|
|
2014-11-24 09:15:30 +00:00
|
|
|
/// \brief The time in seconds when the build session started.
|
|
|
|
///
|
|
|
|
/// This time is used by other optimizations in header search and module
|
|
|
|
/// loading.
|
|
|
|
uint64_t BuildSessionTimestamp;
|
|
|
|
|
2013-04-08 18:45:10 +00:00
|
|
|
/// \brief The set of macro names that should be ignored for the purposes
|
|
|
|
/// of computing the module hash.
|
|
|
|
llvm::SetVector<std::string> ModulesIgnoreMacros;
|
|
|
|
|
2014-11-24 09:15:30 +00:00
|
|
|
/// \brief The set of user-provided virtual filesystem overlay files.
|
|
|
|
std::vector<std::string> VFSOverlayFiles;
|
|
|
|
|
2009-12-15 18:49:47 +00:00
|
|
|
/// Include the compiler builtin includes.
|
|
|
|
unsigned UseBuiltinIncludes : 1;
|
2009-11-18 14:59:57 +00:00
|
|
|
|
|
|
|
/// Include the system standard include search directories.
|
2011-10-20 21:14:49 +00:00
|
|
|
unsigned UseStandardSystemIncludes : 1;
|
2009-11-18 14:59:57 +00:00
|
|
|
|
2010-04-02 08:55:10 +00:00
|
|
|
/// Include the system standard C++ library include search directories.
|
|
|
|
unsigned UseStandardCXXIncludes : 1;
|
|
|
|
|
2011-07-17 15:40:56 +00:00
|
|
|
/// Use libc++ instead of the default libstdc++.
|
|
|
|
unsigned UseLibcxx : 1;
|
|
|
|
|
2009-11-18 14:59:57 +00:00
|
|
|
/// Whether header search information should be output as for -v.
|
|
|
|
unsigned Verbose : 1;
|
|
|
|
|
2014-11-24 09:15:30 +00:00
|
|
|
/// \brief If true, skip verifying input files used by modules if the
|
|
|
|
/// module was already verified during this build session (see
|
|
|
|
/// \c BuildSessionTimestamp).
|
|
|
|
unsigned ModulesValidateOncePerBuildSession : 1;
|
|
|
|
|
|
|
|
/// \brief Whether to validate system input files when a module is loaded.
|
|
|
|
unsigned ModulesValidateSystemHeaders : 1;
|
|
|
|
|
2009-11-18 14:59:57 +00:00
|
|
|
public:
|
2011-10-20 21:14:49 +00:00
|
|
|
HeaderSearchOptions(StringRef _Sysroot = "/")
|
2015-06-21 14:00:56 +00:00
|
|
|
: Sysroot(_Sysroot), DisableModuleHash(0), ImplicitModuleMaps(0),
|
2015-01-18 16:23:48 +00:00
|
|
|
ModuleMapFileHomeIsCwd(0),
|
2013-04-08 18:45:10 +00:00
|
|
|
ModuleCachePruneInterval(7*24*60*60),
|
|
|
|
ModuleCachePruneAfter(31*24*60*60),
|
2014-11-24 09:15:30 +00:00
|
|
|
BuildSessionTimestamp(0),
|
2013-04-08 18:45:10 +00:00
|
|
|
UseBuiltinIncludes(true),
|
2011-10-20 21:14:49 +00:00
|
|
|
UseStandardSystemIncludes(true), UseStandardCXXIncludes(true),
|
2014-11-24 09:15:30 +00:00
|
|
|
UseLibcxx(false), Verbose(false),
|
|
|
|
ModulesValidateOncePerBuildSession(false),
|
|
|
|
ModulesValidateSystemHeaders(false) {}
|
2009-11-18 14:59:57 +00:00
|
|
|
|
2012-12-02 13:20:44 +00:00
|
|
|
/// AddPath - Add the \p Path path to the specified \p Group list.
|
2011-10-20 21:14:49 +00:00
|
|
|
void AddPath(StringRef Path, frontend::IncludeDirGroup Group,
|
2013-04-08 18:45:10 +00:00
|
|
|
bool IsFramework, bool IgnoreSysRoot) {
|
2015-06-09 19:08:19 +00:00
|
|
|
UserEntries.emplace_back(Path, Group, IsFramework, IgnoreSysRoot);
|
2009-11-18 14:59:57 +00:00
|
|
|
}
|
2012-08-15 20:02:54 +00:00
|
|
|
|
|
|
|
/// AddSystemHeaderPrefix - Override whether \#include directives naming a
|
2012-12-02 13:20:44 +00:00
|
|
|
/// path starting with \p Prefix should be considered as naming a system
|
2012-08-15 20:02:54 +00:00
|
|
|
/// header.
|
|
|
|
void AddSystemHeaderPrefix(StringRef Prefix, bool IsSystemHeader) {
|
2015-06-09 19:08:19 +00:00
|
|
|
SystemHeaderPrefixes.emplace_back(Prefix, IsSystemHeader);
|
2012-08-15 20:02:54 +00:00
|
|
|
}
|
2014-11-24 09:15:30 +00:00
|
|
|
|
|
|
|
void AddVFSOverlayFile(StringRef Name) {
|
|
|
|
VFSOverlayFiles.push_back(Name);
|
|
|
|
}
|
2009-11-18 14:59:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace clang
|
|
|
|
|
|
|
|
#endif
|