aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-12-17 06:44:29 +0000
committerChris Lattner <sabre@nondot.org>2007-12-17 06:44:29 +0000
commitb94c707350ee2099996a80c8d97f28b61ff98c7b (patch)
tree2708c797d30d80476e55cecf762349f849a86e7b
parent822da61b74ce14e89b3fa8774db18c833aa5748b (diff)
teach RemoveDuplicates about header maps.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45090 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--Driver/clang.cpp23
-rw-r--r--include/clang/Lex/DirectoryLookup.h18
2 files changed, 31 insertions, 10 deletions
diff --git a/Driver/clang.cpp b/Driver/clang.cpp
index 4f6ea926d2..5e102b9edf 100644
--- a/Driver/clang.cpp
+++ b/Driver/clang.cpp
@@ -676,15 +676,30 @@ static void AddPath(const std::string &Path, IncludeDirGroup Group,
/// search list, remove the later (dead) ones.
static void RemoveDuplicates(std::vector<DirectoryLookup> &SearchList) {
llvm::SmallPtrSet<const DirectoryEntry *, 8> SeenDirs;
+ llvm::SmallPtrSet<const HeaderMap *, 8> SeenHeaderMaps;
for (unsigned i = 0; i != SearchList.size(); ++i) {
- // If this isn't the first time we've seen this dir, remove it.
- if (!SeenDirs.insert(SearchList[i].getDir())) {
+ if (SearchList[i].isNormalDir()) {
+ // If this isn't the first time we've seen this dir, remove it.
+ if (SeenDirs.insert(SearchList[i].getDir()))
+ continue;
+
+ if (Verbose)
+ fprintf(stderr, "ignoring duplicate directory \"%s\"\n",
+ SearchList[i].getDir()->getName());
+ } else {
+ assert(SearchList[i].isHeaderMap() && "Not a headermap or normal dir?");
+ // If this isn't the first time we've seen this headermap, remove it.
+ if (SeenHeaderMaps.insert(SearchList[i].getHeaderMap()))
+ continue;
+
if (Verbose)
fprintf(stderr, "ignoring duplicate directory \"%s\"\n",
SearchList[i].getDir()->getName());
- SearchList.erase(SearchList.begin()+i);
- --i;
}
+
+ // This is reached if the current entry is a duplicate.
+ SearchList.erase(SearchList.begin()+i);
+ --i;
}
}
diff --git a/include/clang/Lex/DirectoryLookup.h b/include/clang/Lex/DirectoryLookup.h
index 817c1597bc..b57ebf013e 100644
--- a/include/clang/Lex/DirectoryLookup.h
+++ b/include/clang/Lex/DirectoryLookup.h
@@ -53,16 +53,16 @@ private:
///
bool Framework : 1;
- /// isHeaderMap - True if the HeaderMap field is valid, false if the Dir field
+ /// IsHeaderMap - True if the HeaderMap field is valid, false if the Dir field
/// is valid.
- bool isHeaderMap : 1;
+ bool IsHeaderMap : 1;
public:
/// DirectoryLookup ctor - Note that this ctor *does not take ownership* of
/// 'dir'.
DirectoryLookup(const DirectoryEntry *dir, DirType DT, bool isUser,
bool isFramework)
: DirCharacteristic(DT), UserSupplied(isUser),
- Framework(isFramework), isHeaderMap(false) {
+ Framework(isFramework), IsHeaderMap(false) {
u.Dir = dir;
}
@@ -70,17 +70,23 @@ public:
/// 'map'.
DirectoryLookup(const HeaderMap *map, DirType DT, bool isUser, bool isFWork)
: DirCharacteristic(DT), UserSupplied(isUser), Framework(isFWork),
- isHeaderMap(true) {
+ IsHeaderMap(true) {
u.Map = map;
}
/// getDir - Return the directory that this entry refers to.
///
- const DirectoryEntry *getDir() const { return !isHeaderMap ? u.Dir : 0; }
+ const DirectoryEntry *getDir() const { return !IsHeaderMap ? u.Dir : 0; }
/// getHeaderMap - Return the directory that this entry refers to.
///
- const HeaderMap *getHeaderMap() const { return isHeaderMap ? u.Map : 0; }
+ const HeaderMap *getHeaderMap() const { return IsHeaderMap ? u.Map : 0; }
+
+ /// isNormalDir - Return true if this is a normal directory, not a header map.
+ bool isNormalDir() const { return !IsHeaderMap; }
+
+ /// isHeaderMap - Return true if this is a header map, not a normal directory.
+ bool isHeaderMap() const { return IsHeaderMap; }
/// DirCharacteristic - The type of directory this is, one of the DirType enum
/// values.