From: Benjamin Kramer Date: Wed, 14 Aug 2013 18:38:51 +0000 (+0000) Subject: Enhance the clang -v gcc debug printing to skip obviously bad and duplicate paths. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f15b26cf378ac4706a861444fccb177f6116087e;p=clang Enhance the clang -v gcc debug printing to skip obviously bad and duplicate paths. Otherwise it lists all files (e.g. shared libraries) that happen to be in the same paths the GCC installations usually reside in. On a x86_64 Debian 7 system with i386 multilibs. before: clang -v 2>&1|wc -l 3059 after: clang -v 2>&1|wc -l 10 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@188400 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp index 21fb2a60a2..7ca69ef285 100644 --- a/lib/Driver/ToolChains.cpp +++ b/lib/Driver/ToolChains.cpp @@ -1052,7 +1052,7 @@ Generic_GCC::GCCInstallationDetector::GCCInstallationDetector( } void Generic_GCC::GCCInstallationDetector::print(raw_ostream &OS) const { - for (SmallVectorImpl::const_iterator + for (std::set::const_iterator I = CandidateGCCInstallPaths.begin(), E = CandidateGCCInstallPaths.end(); I != E; ++I) @@ -1395,9 +1395,11 @@ void Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple( llvm::error_code EC; for (llvm::sys::fs::directory_iterator LI(LibDir + LibSuffix, EC), LE; !EC && LI != LE; LI = LI.increment(EC)) { - CandidateGCCInstallPaths.push_back(LI->path()); StringRef VersionText = llvm::sys::path::filename(LI->path()); GCCVersion CandidateVersion = GCCVersion::Parse(VersionText); + if (CandidateVersion.Major != -1) // Filter obviously bad entries. + if (!CandidateGCCInstallPaths.insert(LI->path()).second) + continue; // Saw this path before; no need to look at it again. if (CandidateVersion.isOlderThan(4, 1, 1)) continue; if (CandidateVersion <= Version) diff --git a/lib/Driver/ToolChains.h b/lib/Driver/ToolChains.h index 395826ea5f..d5c57a96f0 100644 --- a/lib/Driver/ToolChains.h +++ b/lib/Driver/ToolChains.h @@ -16,8 +16,8 @@ #include "clang/Driver/ToolChain.h" #include "llvm/ADT/DenseMap.h" #include "llvm/Support/Compiler.h" - #include +#include namespace clang { namespace driver { @@ -84,7 +84,7 @@ protected: // We retain the list of install paths that were considered and rejected in // order to print out detailed information in verbose mode. - SmallVector CandidateGCCInstallPaths; + std::set CandidateGCCInstallPaths; public: GCCInstallationDetector(const Driver &D, const llvm::Triple &TargetTriple,