[Frontend] Factor out helper function, for clarity.
authorDaniel Dunbar <daniel@zuster.org>
Tue, 29 Jan 2013 23:59:37 +0000 (23:59 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Tue, 29 Jan 2013 23:59:37 +0000 (23:59 +0000)
llvm-svn: 173853

clang/lib/Frontend/InitHeaderSearch.cpp

index f378fc2..f595fb1 100644 (file)
@@ -103,6 +103,14 @@ public:
 
 }  // end anonymous namespace.
 
+static bool CanPrefixSysroot(StringRef Path) {
+#if defined(_WIN32)
+  return !Path.empty() && llvm::sys::path::is_separator(Path[0]);
+#else
+  return llvm::sys::path::is_absolute(Path);
+#endif
+}
+
 void InitHeaderSearch::AddPath(const Twine &Path,
                                IncludeDirGroup Group, bool isCXXAware,
                                bool isFramework, bool IgnoreSysRoot) {
@@ -115,16 +123,9 @@ void InitHeaderSearch::AddPath(const Twine &Path,
 
   // Handle isysroot.
   if ((Group == System || Group == CXXSystem) && !IgnoreSysRoot &&
-#if defined(_WIN32)
-      !MappedPathStr.empty() &&
-      llvm::sys::path::is_separator(MappedPathStr[0]) &&
-#else
-      llvm::sys::path::is_absolute(MappedPathStr) &&
-#endif
-      IsNotEmptyOrRoot) {
+      CanPrefixSysroot(MappedPathStr) && IsNotEmptyOrRoot) {
     MappedPathStorage.clear();
-    MappedPathStr =
-      (IncludeSysroot + Path).toStringRef(MappedPathStorage);
+    MappedPathStr = (IncludeSysroot + Path).toStringRef(MappedPathStorage);
   }
 
   // Compute the DirectoryLookup type.