diff options
author | Daniel Dunbar <daniel@zuster.org> | 2013-01-30 00:19:24 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2013-01-30 00:19:24 +0000 |
commit | ef84554239d77cc52a14b42f2bff8c2d02e7630e (patch) | |
tree | 3ac01de517c6bccbe3b5dbab215bcdae76e0c021 /lib/Frontend | |
parent | 4b1a0e4ab6648894c63bffe8564a669c1df3d683 (diff) |
[Frontend] Add an ExternCSystem include entry group.
- The only group where it makes sense for the "ExternC" bit is System, so this
simplifies having to have the extra isCXXAware (or ImplicitExternC, depending
on what code you talk to) bit caried around.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@173859 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend')
-rw-r--r-- | lib/Frontend/CompilerInvocation.cpp | 11 | ||||
-rw-r--r-- | lib/Frontend/InitHeaderSearch.cpp | 143 |
2 files changed, 76 insertions, 78 deletions
diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp index b6a83b24d8..49f89d4c79 100644 --- a/lib/Frontend/CompilerInvocation.cpp +++ b/lib/Frontend/CompilerInvocation.cpp @@ -885,10 +885,13 @@ static void ParseHeaderSearchArgs(HeaderSearchOptions &Opts, ArgList &Args) { for (arg_iterator I = Args.filtered_begin(OPT_internal_isystem, OPT_internal_externc_isystem), E = Args.filtered_end(); - I != E; ++I) - Opts.AddPath((*I)->getValue(), frontend::System, - false, /*IgnoreSysRoot=*/true, /*IsInternal=*/true, - (*I)->getOption().matches(OPT_internal_externc_isystem)); + I != E; ++I) { + frontend::IncludeDirGroup Group = frontend::System; + if ((*I)->getOption().matches(OPT_internal_externc_isystem)) + Group = frontend::ExternCSystem; + Opts.AddPath((*I)->getValue(), Group, false, /*IgnoreSysRoot=*/true, + /*IsInternal=*/true); + } // Add the path prefixes which are implicitly treated as being system headers. for (arg_iterator I = Args.filtered_begin(OPT_isystem_prefix, diff --git a/lib/Frontend/InitHeaderSearch.cpp b/lib/Frontend/InitHeaderSearch.cpp index ba3abbaebc..16b5dd25d0 100644 --- a/lib/Frontend/InitHeaderSearch.cpp +++ b/lib/Frontend/InitHeaderSearch.cpp @@ -53,8 +53,8 @@ public: } /// AddPath - Add the specified path to the specified group list. - void AddPath(const Twine &Path, IncludeDirGroup Group, - bool isCXXAware, bool isFramework, bool IgnoreSysRoot = false); + void AddPath(const Twine &Path, IncludeDirGroup Group, bool isFramework, + bool IgnoreSysRoot = false); /// AddSystemHeaderPrefix - Add the specified prefix to the system header /// prefix list. @@ -111,8 +111,7 @@ static bool CanPrefixSysroot(StringRef Path) { #endif } -void InitHeaderSearch::AddPath(const Twine &Path, - IncludeDirGroup Group, bool isCXXAware, +void InitHeaderSearch::AddPath(const Twine &Path, IncludeDirGroup Group, bool isFramework, bool IgnoreSysRoot) { assert(!Path.isTriviallyEmpty() && "can't handle empty path here"); FileManager &FM = Headers.getFileMgr(); @@ -129,13 +128,13 @@ void InitHeaderSearch::AddPath(const Twine &Path, // Compute the DirectoryLookup type. SrcMgr::CharacteristicKind Type; - if (Group == Quoted || Group == Angled || Group == IndexHeaderMap) + if (Group == Quoted || Group == Angled || Group == IndexHeaderMap) { Type = SrcMgr::C_User; - else if (isCXXAware) - Type = SrcMgr::C_System; - else + } else if (Group == ExternCSystem) { Type = SrcMgr::C_ExternCSystem; - + } else { + Type = SrcMgr::C_System; + } // If the directory exists, add it. if (const DirectoryEntry *DE = FM.getDirectory(MappedPathStr)) { @@ -169,42 +168,42 @@ void InitHeaderSearch::AddGnuCPlusPlusIncludePaths(StringRef Base, StringRef Dir64, const llvm::Triple &triple) { // Add the base dir - AddPath(Base, CXXSystem, true, false); + AddPath(Base, CXXSystem, false); // Add the multilib dirs llvm::Triple::ArchType arch = triple.getArch(); bool is64bit = arch == llvm::Triple::ppc64 || arch == llvm::Triple::x86_64; if (is64bit) - AddPath(Base + "/" + ArchDir + "/" + Dir64, CXXSystem, true, false); + AddPath(Base + "/" + ArchDir + "/" + Dir64, CXXSystem, false); else - AddPath(Base + "/" + ArchDir + "/" + Dir32, CXXSystem, true, false); + AddPath(Base + "/" + ArchDir + "/" + Dir32, CXXSystem, false); // Add the backward dir - AddPath(Base + "/backward", CXXSystem, true, false); + AddPath(Base + "/backward", CXXSystem, false); } void InitHeaderSearch::AddMinGWCPlusPlusIncludePaths(StringRef Base, StringRef Arch, StringRef Version) { AddPath(Base + "/" + Arch + "/" + Version + "/include/c++", - CXXSystem, true, false); + CXXSystem, false); AddPath(Base + "/" + Arch + "/" + Version + "/include/c++/" + Arch, - CXXSystem, true, false); + CXXSystem, false); AddPath(Base + "/" + Arch + "/" + Version + "/include/c++/backward", - CXXSystem, true, false); + CXXSystem, false); } void InitHeaderSearch::AddMinGW64CXXPaths(StringRef Base, StringRef Version) { // Assumes Base is HeaderSearchOpts' ResourceDir AddPath(Base + "/../../../include/c++/" + Version, - CXXSystem, true, false); + CXXSystem, false); AddPath(Base + "/../../../include/c++/" + Version + "/x86_64-w64-mingw32", - CXXSystem, true, false); + CXXSystem, false); AddPath(Base + "/../../../include/c++/" + Version + "/i686-w64-mingw32", - CXXSystem, true, false); + CXXSystem, false); AddPath(Base + "/../../../include/c++/" + Version + "/backward", - CXXSystem, true, false); + CXXSystem, false); } void InitHeaderSearch::AddDefaultCIncludePaths(const llvm::Triple &triple, @@ -220,7 +219,7 @@ void InitHeaderSearch::AddDefaultCIncludePaths(const llvm::Triple &triple, break; default: // FIXME: temporary hack: hard-coded paths. - AddPath("/usr/local/include", System, true, false); + AddPath("/usr/local/include", System, false); break; } } @@ -232,7 +231,7 @@ void InitHeaderSearch::AddDefaultCIncludePaths(const llvm::Triple &triple, // supplied path. llvm::sys::Path P(HSOpts.ResourceDir); P.appendComponent("include"); - AddPath(P.str(), System, false, false, /*IgnoreSysRoot=*/ true); + AddPath(P.str(), ExternCSystem, false, /*IgnoreSysRoot=*/true); } // All remaining additions are for system include directories, early exit if @@ -248,7 +247,7 @@ void InitHeaderSearch::AddDefaultCIncludePaths(const llvm::Triple &triple, for (SmallVectorImpl<StringRef>::iterator i = dirs.begin(); i != dirs.end(); ++i) - AddPath(*i, System, false, false); + AddPath(*i, ExternCSystem, false); return; } @@ -258,62 +257,59 @@ void InitHeaderSearch::AddDefaultCIncludePaths(const llvm::Triple &triple, llvm_unreachable("Include management is handled in the driver."); case llvm::Triple::Haiku: - AddPath("/boot/common/include", System, true, false); - AddPath("/boot/develop/headers/os", System, true, false); - AddPath("/boot/develop/headers/os/app", System, true, false); - AddPath("/boot/develop/headers/os/arch", System, true, false); - AddPath("/boot/develop/headers/os/device", System, true, false); - AddPath("/boot/develop/headers/os/drivers", System, true, false); - AddPath("/boot/develop/headers/os/game", System, true, false); - AddPath("/boot/develop/headers/os/interface", System, true, false); - AddPath("/boot/develop/headers/os/kernel", System, true, false); - AddPath("/boot/develop/headers/os/locale", System, true, false); - AddPath("/boot/develop/headers/os/mail", System, true, false); - AddPath("/boot/develop/headers/os/media", System, true, false); - AddPath("/boot/develop/headers/os/midi", System, true, false); - AddPath("/boot/develop/headers/os/midi2", System, true, false); - AddPath("/boot/develop/headers/os/net", System, true, false); - AddPath("/boot/develop/headers/os/storage", System, true, false); - AddPath("/boot/develop/headers/os/support", System, true, false); - AddPath("/boot/develop/headers/os/translation", System, true, false); - AddPath("/boot/develop/headers/os/add-ons/graphics", System, true, false); - AddPath("/boot/develop/headers/os/add-ons/input_server", - System, true, false); - AddPath("/boot/develop/headers/os/add-ons/screen_saver", - System, true, false); - AddPath("/boot/develop/headers/os/add-ons/tracker", System, true, false); - AddPath("/boot/develop/headers/os/be_apps/Deskbar", System, true, false); - AddPath("/boot/develop/headers/os/be_apps/NetPositive", - System, true, false); - AddPath("/boot/develop/headers/os/be_apps/Tracker", System, true, false); - AddPath("/boot/develop/headers/cpp", System, true, false); - AddPath("/boot/develop/headers/cpp/i586-pc-haiku", System, true, false); - AddPath("/boot/develop/headers/3rdparty", System, true, false); - AddPath("/boot/develop/headers/bsd", System, true, false); - AddPath("/boot/develop/headers/glibc", System, true, false); - AddPath("/boot/develop/headers/posix", System, true, false); - AddPath("/boot/develop/headers", System, true, false); + AddPath("/boot/common/include", System, false); + AddPath("/boot/develop/headers/os", System, false); + AddPath("/boot/develop/headers/os/app", System, false); + AddPath("/boot/develop/headers/os/arch", System, false); + AddPath("/boot/develop/headers/os/device", System, false); + AddPath("/boot/develop/headers/os/drivers", System, false); + AddPath("/boot/develop/headers/os/game", System, false); + AddPath("/boot/develop/headers/os/interface", System, false); + AddPath("/boot/develop/headers/os/kernel", System, false); + AddPath("/boot/develop/headers/os/locale", System, false); + AddPath("/boot/develop/headers/os/mail", System, false); + AddPath("/boot/develop/headers/os/media", System, false); + AddPath("/boot/develop/headers/os/midi", System, false); + AddPath("/boot/develop/headers/os/midi2", System, false); + AddPath("/boot/develop/headers/os/net", System, false); + AddPath("/boot/develop/headers/os/storage", System, false); + AddPath("/boot/develop/headers/os/support", System, false); + AddPath("/boot/develop/headers/os/translation", System, false); + AddPath("/boot/develop/headers/os/add-ons/graphics", System, false); + AddPath("/boot/develop/headers/os/add-ons/input_server", System, false); + AddPath("/boot/develop/headers/os/add-ons/screen_saver", System, false); + AddPath("/boot/develop/headers/os/add-ons/tracker", System, false); + AddPath("/boot/develop/headers/os/be_apps/Deskbar", System, false); + AddPath("/boot/develop/headers/os/be_apps/NetPositive", System, false); + AddPath("/boot/develop/headers/os/be_apps/Tracker", System, false); + AddPath("/boot/develop/headers/cpp", System, false); + AddPath("/boot/develop/headers/cpp/i586-pc-haiku", System, false); + AddPath("/boot/develop/headers/3rdparty", System, false); + AddPath("/boot/develop/headers/bsd", System, false); + AddPath("/boot/develop/headers/glibc", System, false); + AddPath("/boot/develop/headers/posix", System, false); + AddPath("/boot/develop/headers", System, false); break; case llvm::Triple::RTEMS: break; case llvm::Triple::Cygwin: - AddPath("/usr/include/w32api", System, true, false); + AddPath("/usr/include/w32api", System, false); break; case llvm::Triple::MinGW32: { // mingw-w64 crt include paths llvm::sys::Path P(HSOpts.ResourceDir); P.appendComponent("../../../i686-w64-mingw32/include"); // <sysroot>/i686-w64-mingw32/include - AddPath(P.str(), System, true, false); + AddPath(P.str(), System, false); P = llvm::sys::Path(HSOpts.ResourceDir); P.appendComponent("../../../x86_64-w64-mingw32/include"); // <sysroot>/x86_64-w64-mingw32/include - AddPath(P.str(), System, true, false); + AddPath(P.str(), System, false); // mingw.org crt include paths P = llvm::sys::Path(HSOpts.ResourceDir); P.appendComponent("../../../include"); // <sysroot>/include - AddPath(P.str(), System, true, false); - AddPath("/mingw/include", System, true, false); + AddPath(P.str(), System, false); + AddPath("/mingw/include", System, false); #if defined(_WIN32) - AddPath("c:/mingw/include", System, true, false); + AddPath("c:/mingw/include", System, false); #endif } break; @@ -323,7 +319,7 @@ void InitHeaderSearch::AddDefaultCIncludePaths(const llvm::Triple &triple, } if ( os != llvm::Triple::RTEMS ) - AddPath("/usr/include", System, false, false); + AddPath("/usr/include", ExternCSystem, false); } void InitHeaderSearch:: @@ -400,7 +396,7 @@ AddDefaultCPlusPlusIncludePaths(const llvm::Triple &triple, const HeaderSearchOp #endif break; case llvm::Triple::DragonFly: - AddPath("/usr/include/c++/4.1", CXXSystem, true, false); + AddPath("/usr/include/c++/4.1", CXXSystem, false); break; case llvm::Triple::FreeBSD: // FreeBSD 8.0 @@ -466,15 +462,15 @@ void InitHeaderSearch::AddDefaultIncludePaths(const LangOptions &Lang, // Get foo/lib/c++/v1 P.appendComponent("c++"); P.appendComponent("v1"); - AddPath(P.str(), CXXSystem, true, false, true); + AddPath(P.str(), CXXSystem, false, true); } } // On Solaris, include the support directory for things like xlocale and // fudged system headers. if (triple.getOS() == llvm::Triple::Solaris) - AddPath("/usr/include/c++/v1/support/solaris", CXXSystem, true, false); + AddPath("/usr/include/c++/v1/support/solaris", CXXSystem, false); - AddPath("/usr/include/c++/v1", CXXSystem, true, false); + AddPath("/usr/include/c++/v1", CXXSystem, false); } else { AddDefaultCPlusPlusIncludePaths(triple, HSOpts); } @@ -485,8 +481,8 @@ void InitHeaderSearch::AddDefaultIncludePaths(const LangOptions &Lang, // Add the default framework include paths on Darwin. if (HSOpts.UseStandardSystemIncludes) { if (triple.isOSDarwin()) { - AddPath("/System/Library/Frameworks", System, true, true); - AddPath("/Library/Frameworks", System, true, true); + AddPath("/System/Library/Frameworks", System, true); + AddPath("/Library/Frameworks", System, true); } } } @@ -604,7 +600,7 @@ void InitHeaderSearch::Realize(const LangOptions &Lang) { for (path_iterator it = IncludePath.begin(), ie = IncludePath.end(); it != ie; ++it) { - if (it->first == System || + if (it->first == System || it->first == ExternCSystem || (!Lang.ObjC1 && !Lang.CPlusPlus && it->first == CSystem) || (/*FIXME !Lang.ObjC1 && */Lang.CPlusPlus && it->first == CXXSystem) || (Lang.ObjC1 && !Lang.CPlusPlus && it->first == ObjCSystem) || @@ -660,8 +656,7 @@ void clang::ApplyHeaderSearchOptions(HeaderSearch &HS, // 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.ImplicitExternC, E.IsFramework, - E.IgnoreSysRoot); + Init.AddPath(E.Path, E.Group, E.IsFramework, E.IgnoreSysRoot); } Init.AddDefaultIncludePaths(Lang, Triple, HSOpts); |