@@ -2629,17 +2629,24 @@ LibraryLevel
2629
2629
ModuleLibraryLevelRequest::evaluate (Evaluator &evaluator,
2630
2630
const ModuleDecl *module ) const {
2631
2631
auto &ctx = module ->getASTContext ();
2632
+ namespace path = llvm::sys::path;
2633
+ SmallString<128 > scratch;
2634
+
2635
+ // / Is \p path under the folder SDK/a/b/c/d/e?
2636
+ auto hasSDKPrefix =
2637
+ [&](StringRef path, const Twine &a, const Twine &b = " " ,
2638
+ const Twine &c = " " , const Twine &d = " " , const Twine &e = " " ) {
2639
+ scratch = ctx.SearchPathOpts .getSDKPath ();
2640
+ path::append (scratch, a, b, c, d);
2641
+ path::append (scratch, e);
2642
+ return path.startswith (scratch);
2643
+ };
2632
2644
2633
2645
// / Is \p modulePath from System/Library/PrivateFrameworks/?
2634
2646
auto fromPrivateFrameworks = [&](StringRef modulePath) -> bool {
2635
2647
if (!ctx.LangOpts .Target .isOSDarwin ()) return false ;
2636
2648
2637
- namespace path = llvm::sys::path;
2638
- SmallString<128 > scratch;
2639
- scratch = ctx.SearchPathOpts .getSDKPath ();
2640
- path::append (scratch, " System" , " Library" , " PrivateFrameworks" );
2641
- return hasPrefix (path::begin (modulePath), path::end (modulePath),
2642
- path::begin (scratch), path::end (scratch));
2649
+ return hasSDKPrefix (modulePath, " System" , " Library" , " PrivateFrameworks" );
2643
2650
};
2644
2651
2645
2652
if (module ->isNonSwiftModule ()) {
0 commit comments