benshi001 created this revision.
benshi001 added reviewers: MaskRay, dylanmckay.
Herald added a subscriber: Jim.
benshi001 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107682

Files:
  clang/lib/Driver/ToolChains/AVR.cpp


Index: clang/lib/Driver/ToolChains/AVR.cpp
===================================================================
--- clang/lib/Driver/ToolChains/AVR.cpp
+++ clang/lib/Driver/ToolChains/AVR.cpp
@@ -297,12 +297,6 @@
   return Optional<unsigned>();
 }
 
-const StringRef PossibleAVRLibcLocations[] = {
-    "/avr",
-    "/usr/avr",
-    "/usr/lib/avr",
-};
-
 } // end anonymous namespace
 
 /// AVR Toolchain
@@ -453,12 +447,9 @@
 }
 
 llvm::Optional<std::string> AVRToolChain::findAVRLibcInstallation() const {
-  for (StringRef PossiblePath : PossibleAVRLibcLocations) {
-    std::string Path = getDriver().SysRoot + PossiblePath.str();
-    // Return the first avr-libc installation that exists.
-    if (llvm::sys::fs::is_directory(Path))
-      return Optional<std::string>(Path);
-  }
-
+  std::string GCCRoot(GCCInstallation.getInstallPath());
+  std::string Path(GCCRoot + "/../../../avr");
+  if (llvm::sys::fs::is_directory(Path))
+    return Optional<std::string>(Path);
   return llvm::None;
 }


Index: clang/lib/Driver/ToolChains/AVR.cpp
===================================================================
--- clang/lib/Driver/ToolChains/AVR.cpp
+++ clang/lib/Driver/ToolChains/AVR.cpp
@@ -297,12 +297,6 @@
   return Optional<unsigned>();
 }
 
-const StringRef PossibleAVRLibcLocations[] = {
-    "/avr",
-    "/usr/avr",
-    "/usr/lib/avr",
-};
-
 } // end anonymous namespace
 
 /// AVR Toolchain
@@ -453,12 +447,9 @@
 }
 
 llvm::Optional<std::string> AVRToolChain::findAVRLibcInstallation() const {
-  for (StringRef PossiblePath : PossibleAVRLibcLocations) {
-    std::string Path = getDriver().SysRoot + PossiblePath.str();
-    // Return the first avr-libc installation that exists.
-    if (llvm::sys::fs::is_directory(Path))
-      return Optional<std::string>(Path);
-  }
-
+  std::string GCCRoot(GCCInstallation.getInstallPath());
+  std::string Path(GCCRoot + "/../../../avr");
+  if (llvm::sys::fs::is_directory(Path))
+    return Optional<std::string>(Path);
   return llvm::None;
 }
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to