зеркало из https://github.com/microsoft/clang-1.git
Add HeaderSearchOptions class, for packaging the information needed to
initialize HeaderSearch. Not used yet. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86338 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
e166582f8f
Коммит
63c8b77334
|
@ -0,0 +1,83 @@
|
|||
//===--- HeaderSearchOptions.h ----------------------------------*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_CLANG_FRONTEND_HEADERSEARCHOPTIONS_H
|
||||
#define LLVM_CLANG_FRONTEND_HEADERSEARCHOPTIONS_H
|
||||
|
||||
// FIXME: Drop this dependency.
|
||||
#include "clang/Frontend/InitHeaderSearch.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
|
||||
namespace clang {
|
||||
|
||||
/// HeaderSearchOptions - Helper class for storing options related to the
|
||||
/// initialization of the HeaderSearch object.
|
||||
class HeaderSearchOptions {
|
||||
public:
|
||||
struct Entry {
|
||||
std::string Path;
|
||||
InitHeaderSearch::IncludeDirGroup Group;
|
||||
unsigned IsCXXAware : 1;
|
||||
unsigned IsUserSupplied : 1;
|
||||
unsigned IsFramework : 1;
|
||||
unsigned IgnoreSysRoot : 1;
|
||||
|
||||
Entry(llvm::StringRef _Path, InitHeaderSearch::IncludeDirGroup _Group,
|
||||
bool _IsCXXAware, bool _IsUserSupplied, bool _IsFramework,
|
||||
bool _IgnoreSysRoot)
|
||||
: Path(_Path), Group(_Group), IsCXXAware(_IsCXXAware),
|
||||
IsUserSupplied(_IsUserSupplied), IsFramework(_IsFramework),
|
||||
IgnoreSysRoot(_IgnoreSysRoot) {}
|
||||
};
|
||||
|
||||
/// 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;
|
||||
|
||||
/// A (system-path) delimited list of include paths to be added from the
|
||||
/// environment following the user specified includes (but prior to builtin
|
||||
/// and standard includes). This is parsed in the same manner as the CPATH
|
||||
/// environment variable for gcc.
|
||||
std::string EnvIncPath;
|
||||
|
||||
/// A (system-path) delimited list of include paths to be added from the
|
||||
/// environment following the user specified includes and the \see EnvIncPath
|
||||
/// includes (but prior to builtin and standard includes). This is parsed in
|
||||
/// the same manner as the CPATH environment variable for gcc.
|
||||
std::string LangEnvIncPath;
|
||||
|
||||
/// If non-empty, the path to the compiler builtin include directory, which
|
||||
/// will be searched following the user and environment includes.
|
||||
std::string BuiltinIncludePath;
|
||||
|
||||
/// Include the system standard include search directories.
|
||||
unsigned UseStandardIncludes : 1;
|
||||
|
||||
/// Whether header search information should be output as for -v.
|
||||
unsigned Verbose : 1;
|
||||
|
||||
public:
|
||||
HeaderSearchOptions(llvm::StringRef _Sysroot)
|
||||
: Sysroot(_Sysroot), UseStandardIncludes(true) {}
|
||||
|
||||
/// AddPath - Add the \arg Path path to the specified \arg Group list.
|
||||
void AddPath(llvm::StringRef Path, InitHeaderSearch::IncludeDirGroup Group,
|
||||
bool IsCXXAware, bool IsUserSupplied,
|
||||
bool IsFramework, bool IgnoreSysRoot = false) {
|
||||
UserEntries.push_back(Entry(Path, Group, IsCXXAware, IsUserSupplied,
|
||||
IsFramework, IgnoreSysRoot));
|
||||
}
|
||||
};
|
||||
|
||||
} // end namespace clang
|
||||
|
||||
#endif
|
|
@ -23,6 +23,7 @@
|
|||
namespace clang {
|
||||
|
||||
class HeaderSearch;
|
||||
class HeaderSearchOptions;
|
||||
class LangOptions;
|
||||
|
||||
/// InitHeaderSearch - This class makes it easier to set the search paths of
|
||||
|
@ -86,6 +87,10 @@ public:
|
|||
void Realize();
|
||||
};
|
||||
|
||||
void ApplyHeaderSearchOptions(const HeaderSearchOptions &HSOpts,
|
||||
HeaderSearch &HS, const LangOptions &Lang,
|
||||
const llvm::Triple &triple);
|
||||
|
||||
} // end namespace clang
|
||||
|
||||
#endif
|
||||
|
|
|
@ -12,9 +12,10 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "clang/Frontend/InitHeaderSearch.h"
|
||||
#include "clang/Lex/HeaderSearch.h"
|
||||
#include "clang/Basic/FileManager.h"
|
||||
#include "clang/Basic/LangOptions.h"
|
||||
#include "clang/Frontend/HeaderSearchOptions.h"
|
||||
#include "clang/Lex/HeaderSearch.h"
|
||||
#include "llvm/ADT/SmallString.h"
|
||||
#include "llvm/ADT/SmallPtrSet.h"
|
||||
#include "llvm/Support/raw_ostream.h"
|
||||
|
@ -580,3 +581,32 @@ void InitHeaderSearch::Realize() {
|
|||
fprintf(stderr, "End of search list.\n");
|
||||
}
|
||||
}
|
||||
|
||||
void clang::ApplyHeaderSearchOptions(const HeaderSearchOptions &HSOpts,
|
||||
HeaderSearch &HS, const LangOptions &Lang,
|
||||
const llvm::Triple &Triple) {
|
||||
InitHeaderSearch Init(HS, HSOpts.Verbose, HSOpts.Sysroot);
|
||||
|
||||
// Add the user defined entries.
|
||||
for (unsigned i = 0, e = HSOpts.UserEntries.size(); i != e; ++i) {
|
||||
const HeaderSearchOptions::Entry &E = HSOpts.UserEntries[i];
|
||||
Init.AddPath(E.Path, E.Group, E.IsCXXAware, E.IsUserSupplied, E.IsFramework,
|
||||
E.IgnoreSysRoot);
|
||||
}
|
||||
|
||||
// Add entries from CPATH and friends.
|
||||
Init.AddDelimitedPaths(HSOpts.EnvIncPath.c_str());
|
||||
Init.AddDelimitedPaths(HSOpts.LangEnvIncPath.c_str());
|
||||
|
||||
if (!HSOpts.BuiltinIncludePath.empty()) {
|
||||
// Ignore the sys root, we *always* look for clang headers relative to
|
||||
// supplied path.
|
||||
Init.AddPath(HSOpts.BuiltinIncludePath, InitHeaderSearch::System,
|
||||
false, false, false, /*IgnoreSysRoot=*/ true);
|
||||
}
|
||||
|
||||
if (!HSOpts.UseStandardIncludes)
|
||||
Init.AddDefaultSystemIncludePaths(Lang, Triple);
|
||||
|
||||
Init.Realize();
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче