diff options
author | dim <dim@FreeBSD.org> | 2011-02-27 01:32:10 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2011-02-27 01:32:10 +0000 |
commit | b951d621be1d00a520871c689c1cd687b6aa3ae6 (patch) | |
tree | 5c342f2374324ffec4626f558d9aa49f323f90b4 /contrib/llvm/tools/clang/lib/Frontend/InitHeaderSearch.cpp | |
parent | 4004d6a3076e94bd23e681411c43682267a202fe (diff) | |
parent | a0fb00f9837bd0d2e5948f16f6a6b82a7a628f51 (diff) | |
download | FreeBSD-src-b951d621be1d00a520871c689c1cd687b6aa3ae6.zip FreeBSD-src-b951d621be1d00a520871c689c1cd687b6aa3ae6.tar.gz |
Update llvm/clang to trunk r126547.
There are several bugfixes in this update, but the most important one is
to ensure __start_ and __stop_ symbols for linker sets and kernel module
metadata are always emitted in object files:
http://llvm.org/bugs/show_bug.cgi?id=9292
Before this fix, if you compiled kernel modules with clang, they would
not be properly processed by kldxref, and if they had any dependencies,
the kernel would fail to load those. Another problem occurred when
attempting to mount a tmpfs filesystem, which would result in 'operation
not supported by device'.
Diffstat (limited to 'contrib/llvm/tools/clang/lib/Frontend/InitHeaderSearch.cpp')
-rw-r--r-- | contrib/llvm/tools/clang/lib/Frontend/InitHeaderSearch.cpp | 107 |
1 files changed, 63 insertions, 44 deletions
diff --git a/contrib/llvm/tools/clang/lib/Frontend/InitHeaderSearch.cpp b/contrib/llvm/tools/clang/lib/Frontend/InitHeaderSearch.cpp index 69199e2..566b96c 100644 --- a/contrib/llvm/tools/clang/lib/Frontend/InitHeaderSearch.cpp +++ b/contrib/llvm/tools/clang/lib/Frontend/InitHeaderSearch.cpp @@ -46,7 +46,9 @@ namespace { /// a HeaderSearch object. InitHeaderSearch stores several search path lists /// internally, which can be sent to a HeaderSearch object in one swoop. class InitHeaderSearch { - std::vector<DirectoryLookup> IncludeGroup[4]; + std::vector<std::pair<IncludeDirGroup, DirectoryLookup> > IncludePath; + typedef std::vector<std::pair<IncludeDirGroup, + DirectoryLookup> >::const_iterator path_iterator; HeaderSearch& Headers; bool Verbose; std::string IncludeSysroot; @@ -98,7 +100,7 @@ public: /// Realize - Merges all search path lists into one list and send it to /// HeaderSearch. - void Realize(); + void Realize(const LangOptions &Lang); }; } @@ -135,8 +137,8 @@ void InitHeaderSearch::AddPath(const llvm::Twine &Path, // If the directory exists, add it. if (const DirectoryEntry *DE = FM.getDirectory(MappedPathStr)) { - IncludeGroup[Group].push_back(DirectoryLookup(DE, Type, isUserSupplied, - isFramework)); + IncludePath.push_back(std::make_pair(Group, DirectoryLookup(DE, Type, + isUserSupplied, isFramework))); return; } @@ -146,7 +148,8 @@ void InitHeaderSearch::AddPath(const llvm::Twine &Path, if (const FileEntry *FE = FM.getFile(MappedPathStr)) { if (const HeaderMap *HM = Headers.CreateHeaderMap(FE)) { // It is a headermap, add it to the search path. - IncludeGroup[Group].push_back(DirectoryLookup(HM, Type,isUserSupplied)); + IncludePath.push_back(std::make_pair(Group, DirectoryLookup(HM, Type, + isUserSupplied))); return; } } @@ -183,29 +186,29 @@ void InitHeaderSearch::AddGnuCPlusPlusIncludePaths(llvm::StringRef Base, llvm::StringRef Dir64, const llvm::Triple &triple) { // Add the base dir - AddPath(Base, System, true, false, false); + AddPath(Base, CXXSystem, true, false, 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, System, true, false, false); + AddPath(Base + "/" + ArchDir + "/" + Dir64, CXXSystem, true, false, false); else - AddPath(Base + "/" + ArchDir + "/" + Dir32, System, true, false, false); + AddPath(Base + "/" + ArchDir + "/" + Dir32, CXXSystem, true, false, false); // Add the backward dir - AddPath(Base + "/backward", System, true, false, false); + AddPath(Base + "/backward", CXXSystem, true, false, false); } void InitHeaderSearch::AddMinGWCPlusPlusIncludePaths(llvm::StringRef Base, llvm::StringRef Arch, llvm::StringRef Version) { AddPath(Base + "/" + Arch + "/" + Version + "/include/c++", - System, true, false, false); + CXXSystem, true, false, false); AddPath(Base + "/" + Arch + "/" + Version + "/include/c++/" + Arch, - System, true, false, false); + CXXSystem, true, false, false); AddPath(Base + "/" + Arch + "/" + Version + "/include/c++/backward", - System, true, false, false); + CXXSystem, true, false, false); } // FIXME: This probably should goto to some platform utils place. @@ -576,13 +579,17 @@ AddDefaultCPlusPlusIncludePaths(const llvm::Triple &triple) { break; case llvm::Triple::MinGW32: // mingw-w64-20110207 - AddPath("c:/MinGW/include/c++/4.5.3", System, true, false, false); - AddPath("c:/MinGW/include/c++/4.5.3/x86_64-w64-mingw32", System, true, false, false); - AddPath("c:/MinGW/include/c++/4.5.3/backward", System, true, false, false); + AddPath("c:/MinGW/include/c++/4.5.3", CXXSystem, true, false, false); + AddPath("c:/MinGW/include/c++/4.5.3/x86_64-w64-mingw32", CXXSystem, true, + false, false); + AddPath("c:/MinGW/include/c++/4.5.3/backward", CXXSystem, true, false, + false); // mingw-w64-20101129 - AddPath("c:/MinGW/include/c++/4.5.2", System, true, false, false); - AddPath("c:/MinGW/include/c++/4.5.2/x86_64-w64-mingw32", System, true, false, false); - AddPath("c:/MinGW/include/c++/4.5.2/backward", System, true, false, false); + AddPath("c:/MinGW/include/c++/4.5.2", CXXSystem, true, false, false); + AddPath("c:/MinGW/include/c++/4.5.2/x86_64-w64-mingw32", CXXSystem, true, + false, false); + AddPath("c:/MinGW/include/c++/4.5.2/backward", CXXSystem, true, false, + false); // Try gcc 4.5.0 AddMinGWCPlusPlusIncludePaths("c:/MinGW/lib/gcc", "mingw32", "4.5.0"); // Try gcc 4.4.0 @@ -622,7 +629,7 @@ AddDefaultCPlusPlusIncludePaths(const llvm::Triple &triple) { } break; case llvm::Triple::DragonFly: - AddPath("/usr/include/c++/4.1", System, true, false, false); + AddPath("/usr/include/c++/4.1", CXXSystem, true, false, false); break; case llvm::Triple::Linux: //===------------------------------------------------------------------===// @@ -821,13 +828,8 @@ AddDefaultCPlusPlusIncludePaths(const llvm::Triple &triple) { void InitHeaderSearch::AddDefaultSystemIncludePaths(const LangOptions &Lang, const llvm::Triple &triple, const HeaderSearchOptions &HSOpts) { - if (Lang.CPlusPlus && HSOpts.UseStandardCXXIncludes) { - if (!HSOpts.CXXSystemIncludes.empty()) { - for (unsigned i = 0, e = HSOpts.CXXSystemIncludes.size(); i != e; ++i) - AddPath(HSOpts.CXXSystemIncludes[i], System, true, false, false); - } else - AddDefaultCPlusPlusIncludePaths(triple); - } + if (Lang.CPlusPlus && HSOpts.UseStandardCXXIncludes) + AddDefaultCPlusPlusIncludePaths(triple); AddDefaultCIncludePaths(triple, HSOpts); @@ -841,11 +843,11 @@ void InitHeaderSearch::AddDefaultSystemIncludePaths(const LangOptions &Lang, /// RemoveDuplicates - If there are duplicate directory entries in the specified /// search list, remove the later (dead) ones. static void RemoveDuplicates(std::vector<DirectoryLookup> &SearchList, - bool Verbose) { + unsigned First, bool Verbose) { llvm::SmallPtrSet<const DirectoryEntry *, 8> SeenDirs; llvm::SmallPtrSet<const DirectoryEntry *, 8> SeenFrameworkDirs; llvm::SmallPtrSet<const HeaderMap *, 8> SeenHeaderMaps; - for (unsigned i = 0; i != SearchList.size(); ++i) { + for (unsigned i = First; i != SearchList.size(); ++i) { unsigned DirToRemove = i; const DirectoryLookup &CurEntry = SearchList[i]; @@ -920,32 +922,49 @@ static void RemoveDuplicates(std::vector<DirectoryLookup> &SearchList, } -void InitHeaderSearch::Realize() { +void InitHeaderSearch::Realize(const LangOptions &Lang) { // Concatenate ANGLE+SYSTEM+AFTER chains together into SearchList. std::vector<DirectoryLookup> SearchList; - SearchList = IncludeGroup[Angled]; - SearchList.insert(SearchList.end(), IncludeGroup[System].begin(), - IncludeGroup[System].end()); - SearchList.insert(SearchList.end(), IncludeGroup[After].begin(), - IncludeGroup[After].end()); - RemoveDuplicates(SearchList, Verbose); - RemoveDuplicates(IncludeGroup[Quoted], Verbose); + SearchList.reserve(IncludePath.size()); + + /* Quoted arguments go first. */ + for (path_iterator it = IncludePath.begin(), ie = IncludePath.end(); + it != ie; ++it) { + if (it->first == Quoted) + SearchList.push_back(it->second); + } + /* Deduplicate and remember index */ + RemoveDuplicates(SearchList, 0, Verbose); + unsigned quoted = SearchList.size(); + + for (path_iterator it = IncludePath.begin(), ie = IncludePath.end(); + it != ie; ++it) { + if (it->first == Angled) + SearchList.push_back(it->second); + } - // Prepend QUOTED list on the search list. - SearchList.insert(SearchList.begin(), IncludeGroup[Quoted].begin(), - IncludeGroup[Quoted].end()); + for (path_iterator it = IncludePath.begin(), ie = IncludePath.end(); + it != ie; ++it) { + if (it->first == System || (Lang.CPlusPlus && it->first == CXXSystem)) + SearchList.push_back(it->second); + } + + for (path_iterator it = IncludePath.begin(), ie = IncludePath.end(); + it != ie; ++it) { + if (it->first == After) + SearchList.push_back(it->second); + } + RemoveDuplicates(SearchList, quoted, Verbose); bool DontSearchCurDir = false; // TODO: set to true if -I- is set? - Headers.SetSearchPaths(SearchList, IncludeGroup[Quoted].size(), - DontSearchCurDir); + Headers.SetSearchPaths(SearchList, quoted, DontSearchCurDir); // If verbose, print the list of directories that will be searched. if (Verbose) { llvm::errs() << "#include \"...\" search starts here:\n"; - unsigned QuotedIdx = IncludeGroup[Quoted].size(); for (unsigned i = 0, e = SearchList.size(); i != e; ++i) { - if (i == QuotedIdx) + if (i == quoted) llvm::errs() << "#include <...> search starts here:\n"; const char *Name = SearchList[i].getName(); const char *Suffix; @@ -990,5 +1009,5 @@ void clang::ApplyHeaderSearchOptions(HeaderSearch &HS, if (HSOpts.UseStandardIncludes) Init.AddDefaultSystemIncludePaths(Lang, Triple, HSOpts); - Init.Realize(); + Init.Realize(Lang); } |