r188400 - Enhance the clang -v gcc debug printing to skip obviously bad and duplicate paths.
Eli Friedman
eli.friedman at gmail.com
Wed Aug 14 12:32:33 PDT 2013
On Wed, Aug 14, 2013 at 11:38 AM, Benjamin Kramer
<benny.kra at googlemail.com>wrote:
> Author: d0k
> Date: Wed Aug 14 13:38:51 2013
> New Revision: 188400
>
> URL: http://llvm.org/viewvc/llvm-project?rev=188400&view=rev
> Log:
> 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
>
Testcase?
>
> Modified:
> cfe/trunk/lib/Driver/ToolChains.cpp
> cfe/trunk/lib/Driver/ToolChains.h
>
> Modified: cfe/trunk/lib/Driver/ToolChains.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=188400&r1=188399&r2=188400&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Driver/ToolChains.cpp (original)
> +++ cfe/trunk/lib/Driver/ToolChains.cpp Wed Aug 14 13:38:51 2013
> @@ -1052,7 +1052,7 @@ Generic_GCC::GCCInstallationDetector::GC
> }
>
> void Generic_GCC::GCCInstallationDetector::print(raw_ostream &OS) const {
> - for (SmallVectorImpl<std::string>::const_iterator
> + for (std::set<std::string>::const_iterator
> I = CandidateGCCInstallPaths.begin(),
> E = CandidateGCCInstallPaths.end();
> I != E; ++I)
> @@ -1395,9 +1395,11 @@ void Generic_GCC::GCCInstallationDetecto
> 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)
>
> Modified: cfe/trunk/lib/Driver/ToolChains.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.h?rev=188400&r1=188399&r2=188400&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Driver/ToolChains.h (original)
> +++ cfe/trunk/lib/Driver/ToolChains.h Wed Aug 14 13:38:51 2013
> @@ -16,8 +16,8 @@
> #include "clang/Driver/ToolChain.h"
> #include "llvm/ADT/DenseMap.h"
> #include "llvm/Support/Compiler.h"
> -
> #include <vector>
> +#include <set>
>
> 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<std::string, 4> CandidateGCCInstallPaths;
> + std::set<std::string> CandidateGCCInstallPaths;
>
>
Maybe consider using StringSet?
-Eli
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20130814/7066e416/attachment.html>
More information about the cfe-commits
mailing list