]> granicus.if.org Git - clang/commitdiff
Enhance the clang -v gcc debug printing to skip obviously bad and duplicate paths.
authorBenjamin Kramer <benny.kra@googlemail.com>
Wed, 14 Aug 2013 18:38:51 +0000 (18:38 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Wed, 14 Aug 2013 18:38:51 +0000 (18:38 +0000)
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

lib/Driver/ToolChains.cpp
lib/Driver/ToolChains.h

index 21fb2a60a2534a88483b8b2c6929d9aa76bcc1ee..7ca69ef285052ba63887c0a1b51c1b5f4c11a4de 100644 (file)
@@ -1052,7 +1052,7 @@ Generic_GCC::GCCInstallationDetector::GCCInstallationDetector(
 }
 
 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::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)
index 395826ea5f747dc3ef1fad582d4adc06b34a2fad..d5c57a96f043376069dcd82624ef29a30fb9182b 100644 (file)
@@ -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;
 
   public:
     GCCInstallationDetector(const Driver &D, const llvm::Triple &TargetTriple,