[cfe-commits] r86338 - in /cfe/trunk: include/clang/Frontend/HeaderSearchOptions.h include/clang/Frontend/InitHeaderSearch.h lib/Frontend/InitHeaderSearch.cpp
Daniel Dunbar
daniel at zuster.org
Fri Nov 6 20:20:51 PST 2009
Author: ddunbar
Date: Fri Nov 6 22:20:50 2009
New Revision: 86338
URL: http://llvm.org/viewvc/llvm-project?rev=86338&view=rev
Log:
Add HeaderSearchOptions class, for packaging the information needed to
initialize HeaderSearch. Not used yet.
Added:
cfe/trunk/include/clang/Frontend/HeaderSearchOptions.h
Modified:
cfe/trunk/include/clang/Frontend/InitHeaderSearch.h
cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
Added: cfe/trunk/include/clang/Frontend/HeaderSearchOptions.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/HeaderSearchOptions.h?rev=86338&view=auto
==============================================================================
--- cfe/trunk/include/clang/Frontend/HeaderSearchOptions.h (added)
+++ cfe/trunk/include/clang/Frontend/HeaderSearchOptions.h Fri Nov 6 22:20:50 2009
@@ -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
Modified: cfe/trunk/include/clang/Frontend/InitHeaderSearch.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/InitHeaderSearch.h?rev=86338&r1=86337&r2=86338&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/InitHeaderSearch.h (original)
+++ cfe/trunk/include/clang/Frontend/InitHeaderSearch.h Fri Nov 6 22:20:50 2009
@@ -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 @@
void Realize();
};
+void ApplyHeaderSearchOptions(const HeaderSearchOptions &HSOpts,
+ HeaderSearch &HS, const LangOptions &Lang,
+ const llvm::Triple &triple);
+
} // end namespace clang
#endif
Modified: cfe/trunk/lib/Frontend/InitHeaderSearch.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitHeaderSearch.cpp?rev=86338&r1=86337&r2=86338&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/InitHeaderSearch.cpp (original)
+++ cfe/trunk/lib/Frontend/InitHeaderSearch.cpp Fri Nov 6 22:20:50 2009
@@ -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 @@
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();
+}
More information about the cfe-commits
mailing list