6
6
//
7
7
// ===----------------------------------------------------------------------===//
8
8
9
- #ifndef LLVM_LIB_DWARFLINKER_PARALLEL_UTILS_H
10
- #define LLVM_LIB_DWARFLINKER_PARALLEL_UTILS_H
9
+ #ifndef LLVM_DWARFLINKER_UTILS_H
10
+ #define LLVM_DWARFLINKER_UTILS_H
11
11
12
+ #include " llvm/ADT/SmallString.h"
13
+ #include " llvm/ADT/Twine.h"
12
14
#include " llvm/Support/Error.h"
15
+ #include " llvm/Support/FileSystem.h"
16
+ #include " llvm/Support/Path.h"
13
17
14
18
namespace llvm {
15
19
namespace dwarf_linker {
16
- namespace parallel {
17
20
18
21
// / This function calls \p Iteration() until it returns false.
19
22
// / If number of iterations exceeds \p MaxCounter then an Error is returned.
@@ -27,16 +30,35 @@ inline Error finiteLoop(function_ref<Expected<bool>()> Iteration,
27
30
Expected<bool > IterationResultOrError = Iteration ();
28
31
if (!IterationResultOrError)
29
32
return IterationResultOrError.takeError ();
30
-
31
33
if (!IterationResultOrError.get ())
32
34
return Error::success ();
33
35
}
34
-
35
36
return createStringError (std::errc::invalid_argument, " Infinite recursion" );
36
37
}
37
38
38
- } // end of namespace parallel
39
+ // / Make a best effort to guess the
40
+ // / Xcode.app/Contents/Developer/Toolchains/ path from an SDK path.
41
+ inline SmallString<128 > guessToolchainBaseDir (StringRef SysRoot) {
42
+ SmallString<128 > Result;
43
+ // Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
44
+ StringRef Base = sys::path::parent_path (SysRoot);
45
+ if (sys::path::filename (Base) != " SDKs" )
46
+ return Result;
47
+ Base = sys::path::parent_path (Base);
48
+ Result = Base;
49
+ Result += " /Toolchains" ;
50
+ return Result;
51
+ }
52
+
53
+ inline bool isPathAbsoluteOnWindowsOrPosix (const Twine &Path) {
54
+ // Debug info can contain paths from any OS, not necessarily
55
+ // an OS we're currently running on. Moreover different compilation units can
56
+ // be compiled on different operating systems and linked together later.
57
+ return sys::path::is_absolute (Path, sys::path::Style::posix) ||
58
+ sys::path::is_absolute (Path, sys::path::Style::windows);
59
+ }
60
+
39
61
} // end of namespace dwarf_linker
40
62
} // end of namespace llvm
41
63
42
- #endif // LLVM_LIB_DWARFLINKER_PARALLEL_UTILS_H
64
+ #endif // LLVM_DWARFLINKER_UTILS_H
0 commit comments