diff options
author | Chad Rosier <mcrosier@apple.com> | 2011-10-10 18:44:24 +0000 |
---|---|---|
committer | Chad Rosier <mcrosier@apple.com> | 2011-10-10 18:44:24 +0000 |
commit | fd3c90c62094f3b8d46f1b10a9d9a88e292275e0 (patch) | |
tree | 79b554b67fe98d7ac9273032a3acd2b2a288b973 /clang/lib/Frontend/InitHeaderSearch.cpp | |
parent | cc6659b2ae761a61321c185b49d7f6d0365a3f37 (diff) | |
download | bcm5719-llvm-fd3c90c62094f3b8d46f1b10a9d9a88e292275e0.tar.gz bcm5719-llvm-fd3c90c62094f3b8d46f1b10a9d9a88e292275e0.zip |
When an included non-system directory duplicates a system directory the clang
frontend removes the non-system directory to maintain gcc compatibility. When
this happens NumAngled needs to be updated.
PR11097
llvm-svn: 141565
Diffstat (limited to 'clang/lib/Frontend/InitHeaderSearch.cpp')
-rw-r--r-- | clang/lib/Frontend/InitHeaderSearch.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/clang/lib/Frontend/InitHeaderSearch.cpp b/clang/lib/Frontend/InitHeaderSearch.cpp index 16a905e8761..76cda2c9b35 100644 --- a/clang/lib/Frontend/InitHeaderSearch.cpp +++ b/clang/lib/Frontend/InitHeaderSearch.cpp @@ -968,12 +968,14 @@ 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, - unsigned First, bool Verbose) { +/// search list, remove the later (dead) ones. Returns the number of non-system +/// headers removed, which is used to update NumAngled. +static unsigned RemoveDuplicates(std::vector<DirectoryLookup> &SearchList, + unsigned First, bool Verbose) { llvm::SmallPtrSet<const DirectoryEntry *, 8> SeenDirs; llvm::SmallPtrSet<const DirectoryEntry *, 8> SeenFrameworkDirs; llvm::SmallPtrSet<const HeaderMap *, 8> SeenHeaderMaps; + unsigned NonSystemRemoved = 0; for (unsigned i = First; i != SearchList.size(); ++i) { unsigned DirToRemove = i; @@ -1040,12 +1042,15 @@ static void RemoveDuplicates(std::vector<DirectoryLookup> &SearchList, llvm::errs() << " as it is a non-system directory that duplicates " << "a system directory\n"; } + if (DirToRemove != i) + ++NonSystemRemoved; // This is reached if the current entry is a duplicate. Remove the // DirToRemove (usually the current dir). SearchList.erase(SearchList.begin()+DirToRemove); --i; } + return NonSystemRemoved; } @@ -1092,7 +1097,8 @@ void InitHeaderSearch::Realize(const LangOptions &Lang) { // Remove duplicates across both the Angled and System directories. GCC does // this and failing to remove duplicates across these two groups breaks // #include_next. - RemoveDuplicates(SearchList, NumQuoted, Verbose); + unsigned NonSystemRemoved = RemoveDuplicates(SearchList, NumQuoted, Verbose); + NumAngled -= NonSystemRemoved; bool DontSearchCurDir = false; // TODO: set to true if -I- is set? Headers.SetSearchPaths(SearchList, NumQuoted, NumAngled, DontSearchCurDir); |