[PATCH] D57930: [Driver] Verify GCCInstallation is valid

Daniel Mentz via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 7 16:41:24 PST 2019

danielmentz created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Values returned by GCCInstallation.getParentLibPath() and
GCCInstallation.getTriple() are not valid unless
GCCInstallation.isValid() returns true. This has previously been
ignored, and the former two values were used without checking whether
GCCInstallation is valid. This led to the bad path "/../bin" being added
to the list of program paths.

  rG LLVM Github Monorepo



Index: clang/lib/Driver/ToolChains/Linux.cpp
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ clang/lib/Driver/ToolChains/Linux.cpp
@@ -229,9 +229,11 @@
   // used to target i386.
   // FIXME: This seems unlikely to be Linux-specific.
   ToolChain::path_list &PPaths = getProgramPaths();
-  PPaths.push_back(Twine(GCCInstallation.getParentLibPath() + "/../" +
-                         GCCInstallation.getTriple().str() + "/bin")
-                       .str());
+  if (GCCInstallation.isValid()) {
+    PPaths.push_back(Twine(GCCInstallation.getParentLibPath() + "/../" +
+                           GCCInstallation.getTriple().str() + "/bin")
+                         .str());
+  }
   Distro Distro(D.getVFS());

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D57930.185888.patch
Type: text/x-patch
Size: 784 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190208/9569a39b/attachment.bin>

More information about the cfe-commits mailing list