aboutsummaryrefslogtreecommitdiff
path: root/include/clang/Frontend
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2012-10-24 16:19:39 +0000
committerDouglas Gregor <dgregor@apple.com>2012-10-24 16:19:39 +0000
commitc042edd54face617a3b9d0b4b9d5a3ff229d0f48 (patch)
treea7058afb6aa780a5a94dbf4bf3275cba5dedbfc3 /include/clang/Frontend
parent04d25fcb26610601466fb52a75ce9b4e9d18eed5 (diff)
Move HeaderSearchOptions into the Lex library, make it intrusively
reference-counted, and hold a reference to it in HeaderSearch. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166583 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/clang/Frontend')
-rw-r--r--include/clang/Frontend/ASTUnit.h20
-rw-r--r--include/clang/Frontend/CompilerInvocation.h18
-rw-r--r--include/clang/Frontend/HeaderSearchOptions.h146
3 files changed, 20 insertions, 164 deletions
diff --git a/include/clang/Frontend/ASTUnit.h b/include/clang/Frontend/ASTUnit.h
index c2bde120a0..d0fd48f24f 100644
--- a/include/clang/Frontend/ASTUnit.h
+++ b/include/clang/Frontend/ASTUnit.h
@@ -19,6 +19,7 @@
#include "clang/Sema/CodeCompleteConsumer.h"
#include "clang/Lex/ModuleLoader.h"
#include "clang/Lex/PreprocessingRecord.h"
+#include "clang/Lex/HeaderSearchOptions.h"
#include "clang/AST/ASTContext.h"
#include "clang/Basic/LangOptions.h"
#include "clang/Basic/SourceManager.h"
@@ -63,15 +64,16 @@ class ASTDeserializationListener;
///
class ASTUnit : public ModuleLoader {
private:
- IntrusiveRefCntPtr<LangOptions> LangOpts;
- IntrusiveRefCntPtr<DiagnosticsEngine> Diagnostics;
- IntrusiveRefCntPtr<FileManager> FileMgr;
- IntrusiveRefCntPtr<SourceManager> SourceMgr;
- OwningPtr<HeaderSearch> HeaderInfo;
- IntrusiveRefCntPtr<TargetInfo> Target;
- IntrusiveRefCntPtr<Preprocessor> PP;
- IntrusiveRefCntPtr<ASTContext> Ctx;
- IntrusiveRefCntPtr<TargetOptions> TargetOpts;
+ IntrusiveRefCntPtr<LangOptions> LangOpts;
+ IntrusiveRefCntPtr<DiagnosticsEngine> Diagnostics;
+ IntrusiveRefCntPtr<FileManager> FileMgr;
+ IntrusiveRefCntPtr<SourceManager> SourceMgr;
+ OwningPtr<HeaderSearch> HeaderInfo;
+ IntrusiveRefCntPtr<TargetInfo> Target;
+ IntrusiveRefCntPtr<Preprocessor> PP;
+ IntrusiveRefCntPtr<ASTContext> Ctx;
+ IntrusiveRefCntPtr<TargetOptions> TargetOpts;
+ IntrusiveRefCntPtr<HeaderSearchOptions> HSOpts;
ASTReader *Reader;
struct ASTWriterData;
diff --git a/include/clang/Frontend/CompilerInvocation.h b/include/clang/Frontend/CompilerInvocation.h
index de8f60049a..5509e77a1b 100644
--- a/include/clang/Frontend/CompilerInvocation.h
+++ b/include/clang/Frontend/CompilerInvocation.h
@@ -14,12 +14,12 @@
#include "clang/Basic/TargetOptions.h"
#include "clang/Basic/FileSystemOptions.h"
#include "clang/Basic/DiagnosticOptions.h"
+#include "clang/Lex/HeaderSearchOptions.h"
#include "clang/StaticAnalyzer/Core/AnalyzerOptions.h"
#include "clang/Frontend/MigratorOptions.h"
#include "clang/Frontend/CodeGenOptions.h"
#include "clang/Frontend/DependencyOutputOptions.h"
#include "clang/Frontend/FrontendOptions.h"
-#include "clang/Frontend/HeaderSearchOptions.h"
#include "clang/Frontend/LangStandard.h"
#include "clang/Frontend/PreprocessorOptions.h"
#include "clang/Frontend/PreprocessorOutputOptions.h"
@@ -59,6 +59,9 @@ protected:
/// Options controlling the diagnostic engine.
IntrusiveRefCntPtr<DiagnosticOptions> DiagnosticOpts;
+ /// Options controlling the \#include directive.
+ IntrusiveRefCntPtr<HeaderSearchOptions> HeaderSearchOpts;
+
public:
CompilerInvocationBase();
@@ -73,6 +76,11 @@ public:
}
DiagnosticOptions &getDiagnosticOpts() const { return *DiagnosticOpts; }
+
+ HeaderSearchOptions &getHeaderSearchOpts() { return *HeaderSearchOpts; }
+ const HeaderSearchOptions &getHeaderSearchOpts() const {
+ return *HeaderSearchOpts;
+ }
};
/// \brief Helper class for holding the data necessary to invoke the compiler.
@@ -98,9 +106,6 @@ class CompilerInvocation : public CompilerInvocationBase {
/// Options controlling the frontend itself.
FrontendOptions FrontendOpts;
- /// Options controlling the \#include directive.
- HeaderSearchOptions HeaderSearchOpts;
-
/// Options controlling the preprocessor (aside from \#include handling).
PreprocessorOptions PreprocessorOpts;
@@ -182,11 +187,6 @@ public:
return FileSystemOpts;
}
- HeaderSearchOptions &getHeaderSearchOpts() { return HeaderSearchOpts; }
- const HeaderSearchOptions &getHeaderSearchOpts() const {
- return HeaderSearchOpts;
- }
-
FrontendOptions &getFrontendOpts() { return FrontendOpts; }
const FrontendOptions &getFrontendOpts() const {
return FrontendOpts;
diff --git a/include/clang/Frontend/HeaderSearchOptions.h b/include/clang/Frontend/HeaderSearchOptions.h
deleted file mode 100644
index e12884d100..0000000000
--- a/include/clang/Frontend/HeaderSearchOptions.h
+++ /dev/null
@@ -1,146 +0,0 @@
-//===--- 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
-
-#include "llvm/ADT/StringRef.h"
-#include <vector>
-
-namespace clang {
-
-namespace frontend {
- /// IncludeDirGroup - Identifiers the group a include entry belongs to, which
- /// represents its relative positive in the search list. A \#include of a ""
- /// path starts at the -iquote group, then searches the Angled group, then
- /// searches the system group, etc.
- enum IncludeDirGroup {
- Quoted = 0, ///< '\#include ""' paths, added by 'gcc -iquote'.
- Angled, ///< Paths for '\#include <>' added by '-I'.
- IndexHeaderMap, ///< Like Angled, but marks header maps used when
- /// building frameworks.
- System, ///< Like Angled, but marks system directories.
- CSystem, ///< Like System, but only used for C.
- CXXSystem, ///< Like System, but only used for C++.
- ObjCSystem, ///< Like System, but only used for ObjC.
- ObjCXXSystem, ///< Like System, but only used for ObjC++.
- After ///< Like System, but searched after the system directories.
- };
-}
-
-/// HeaderSearchOptions - Helper class for storing options related to the
-/// initialization of the HeaderSearch object.
-class HeaderSearchOptions {
-public:
- struct Entry {
- std::string Path;
- frontend::IncludeDirGroup Group;
- unsigned IsUserSupplied : 1;
- unsigned IsFramework : 1;
-
- /// IgnoreSysRoot - This is false if an absolute path should be treated
- /// relative to the sysroot, or true if it should always be the absolute
- /// path.
- unsigned IgnoreSysRoot : 1;
-
- /// \brief True if this entry is an internal search path.
- ///
- /// This typically indicates that users didn't directly provide it, but
- /// instead it was provided by a compatibility layer for a particular
- /// system. This isn't redundant with IsUserSupplied (even though perhaps
- /// it should be) because that is false for user provided '-iwithprefix'
- /// header search entries.
- unsigned IsInternal : 1;
-
- /// \brief True if this entry's headers should be wrapped in extern "C".
- unsigned ImplicitExternC : 1;
-
- Entry(StringRef path, frontend::IncludeDirGroup group,
- bool isUserSupplied, bool isFramework, bool ignoreSysRoot,
- bool isInternal, bool implicitExternC)
- : Path(path), Group(group), IsUserSupplied(isUserSupplied),
- IsFramework(isFramework), IgnoreSysRoot(ignoreSysRoot),
- IsInternal(isInternal), ImplicitExternC(implicitExternC) {}
- };
-
- 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) {}
- };
-
- /// 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;
-
- /// User-specified system header prefixes.
- std::vector<SystemHeaderPrefix> SystemHeaderPrefixes;
-
- /// The directory which holds the compiler resource files (builtin includes,
- /// etc.).
- std::string ResourceDir;
-
- /// \brief The directory used for the module cache.
- std::string ModuleCachePath;
-
- /// \brief Whether we should disable the use of the hash string within the
- /// module cache.
- ///
- /// Note: Only used for testing!
- unsigned DisableModuleHash : 1;
-
- /// Include the compiler builtin includes.
- unsigned UseBuiltinIncludes : 1;
-
- /// Include the system standard include search directories.
- unsigned UseStandardSystemIncludes : 1;
-
- /// Include the system standard C++ library include search directories.
- unsigned UseStandardCXXIncludes : 1;
-
- /// Use libc++ instead of the default libstdc++.
- unsigned UseLibcxx : 1;
-
- /// Whether header search information should be output as for -v.
- unsigned Verbose : 1;
-
-public:
- HeaderSearchOptions(StringRef _Sysroot = "/")
- : Sysroot(_Sysroot), DisableModuleHash(0), UseBuiltinIncludes(true),
- UseStandardSystemIncludes(true), UseStandardCXXIncludes(true),
- UseLibcxx(false), Verbose(false) {}
-
- /// AddPath - Add the \p Path path to the specified \p Group list.
- void AddPath(StringRef Path, frontend::IncludeDirGroup Group,
- bool IsUserSupplied, bool IsFramework, bool IgnoreSysRoot,
- bool IsInternal = false, bool ImplicitExternC = false) {
- UserEntries.push_back(Entry(Path, Group, IsUserSupplied, IsFramework,
- IgnoreSysRoot, IsInternal, ImplicitExternC));
- }
-
- /// AddSystemHeaderPrefix - Override whether \#include directives naming a
- /// path starting with \p Prefix should be considered as naming a system
- /// header.
- void AddSystemHeaderPrefix(StringRef Prefix, bool IsSystemHeader) {
- SystemHeaderPrefixes.push_back(SystemHeaderPrefix(Prefix, IsSystemHeader));
- }
-};
-
-} // end namespace clang
-
-#endif