@@ -449,5 +449,44 @@ void AddIncludePaths(llvm::StringRef PathStr,
449
449
#undef DEBUG_TYPE
450
450
}
451
451
452
+ void GetIncludePaths (
453
+ std::vector<std::string>& includePaths, llvm::StringRef PathStr,
454
+ clang::HeaderSearchOptions& HOpts,
455
+ const char * Delim /* = Cpp::utils::platform::kEnvDelim */ ) {
456
+ #define DEBUG_TYPE " GetIncludePaths"
457
+
458
+ llvm::SmallVector<llvm::StringRef, 10 > Paths;
459
+ if (Delim && *Delim)
460
+ SplitPaths (PathStr, Paths, kAllowNonExistant , Delim, HOpts.Verbose );
461
+ else
462
+ Paths.push_back (PathStr);
463
+
464
+ // Avoid duplicates
465
+ llvm::SmallVector<llvm::StringRef, 10 > PathsChecked;
466
+ for (llvm::StringRef Path : Paths) {
467
+ bool Exists = false ;
468
+ for (const clang::HeaderSearchOptions::Entry& E : HOpts.UserEntries ) {
469
+ if ((Exists = E.Path == Path))
470
+ break ;
471
+ }
472
+ if (!Exists)
473
+ PathsChecked.push_back (Path);
474
+ includePaths.push_back ((std::string)Path);
475
+ }
476
+
477
+ const bool IsFramework = false ;
478
+ const bool IsSysRootRelative = true ;
479
+ for (llvm::StringRef Path : PathsChecked)
480
+ HOpts.AddPath (Path, clang::frontend::Angled, IsFramework,
481
+ IsSysRootRelative);
482
+
483
+ if (HOpts.Verbose ) {
484
+ LLVM_DEBUG (dbgs () << " Added include paths:\n " );
485
+ for (llvm::StringRef Path : PathsChecked)
486
+ LLVM_DEBUG (dbgs () << " " << Path << " \n " );
487
+ }
488
+ #undef DEBUG_TYPE
489
+ }
490
+
452
491
} // namespace utils
453
492
} // namespace Cpp
0 commit comments