[PATCH] D24954: [Driver] Disable OpenSUSE rules for OpenSUSE/SLES 10 and older

Michał Górny via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 20 14:48:21 PDT 2016


mgorny retitled this revision from "[ToolChains] Disable OpenSUSE rules for SLES10" to "[Driver] Disable OpenSUSE rules for OpenSUSE/SLES 10 and older".
mgorny updated the summary for this revision.
mgorny updated this revision to Diff 75357.

https://reviews.llvm.org/D24954

Files:
  lib/Driver/ToolChains.cpp


Index: lib/Driver/ToolChains.cpp
===================================================================
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -3931,8 +3931,26 @@
         .Default(UnknownDistro);
   }
 
-  if (VFS.exists("/etc/SuSE-release"))
-    return OpenSUSE;
+  File = VFS.getBufferForFile("/etc/SuSE-release");
+  if (File) {
+    StringRef Data = File.get()->getBuffer();
+    SmallVector<StringRef, 16> Lines;
+    Data.split(Lines, "\n");
+    for (const StringRef& Line : Lines) {
+      std::pair<StringRef, StringRef> SplitLine = Line.split('=');
+      int Version;
+      if (SplitLine.first.trim() == "VERSION" &&
+          !SplitLine.second.trim().getAsInteger(10, Version)) {
+        // OpenSUSE/SLES 10 and older are not supported and not compatible
+        // with our rules, so just treat them as UnknownDistro.
+        if (Version > 10)
+          return OpenSUSE;
+        else
+          return UnknownDistro;
+      }
+    }
+    return UnknownDistro;
+  }
 
   if (VFS.exists("/etc/exherbo-release"))
     return Exherbo;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D24954.75357.patch
Type: text/x-patch
Size: 1074 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161020/c1a85779/attachment.bin>


More information about the cfe-commits mailing list