@@ -233,6 +233,11 @@ void CopyIncludePaths(const clang::HeaderSearchOptions& Opts,
233233    incpaths.push_back (" -v" 
234234}
235235
236+ void  LogNonExistantDirectory (llvm::StringRef Path) {
237+ #define  DEBUG_TYPE  " LogNonExistantDirectory" 
238+   LLVM_DEBUG (dbgs () << "   ignoring nonexistent directory \" " " \"\n " 
239+ #undef   DEBUG_TYPE
240+ }
236241
237242bool  SplitPaths (llvm::StringRef PathStr,
238243                llvm::SmallVectorImpl<llvm::StringRef>& Paths,
@@ -322,5 +327,42 @@ bool SplitPaths(llvm::StringRef PathStr,
322327}
323328
324329
330+ void  AddIncludePaths (llvm::StringRef PathStr,
331+                          clang::HeaderSearchOptions& HOpts,
332+                          const  char * Delim /*  = Cpp::utils::platform::kEnvDelim */ 
333+ #define  DEBUG_TYPE  " AddIncludePaths" 
334+ 
335+   llvm::SmallVector<llvm::StringRef, 10 > Paths;
336+   if  (Delim && *Delim)
337+     SplitPaths (PathStr, Paths, kAllowNonExistant , Delim, HOpts.Verbose );
338+   else 
339+     Paths.push_back (PathStr);
340+ 
341+   //  Avoid duplicates
342+   llvm::SmallVector<llvm::StringRef, 10 > PathsChecked;
343+   for  (llvm::StringRef Path : Paths) {
344+     bool  Exists = false ;
345+     for  (const  clang::HeaderSearchOptions::Entry& E : HOpts.UserEntries ) {
346+       if  ((Exists = E.Path  == Path))
347+         break ;
348+     }
349+     if  (!Exists)
350+       PathsChecked.push_back (Path);
351+   }
352+ 
353+   const  bool  IsFramework = false ;
354+   const  bool  IsSysRootRelative = true ;
355+   for  (llvm::StringRef Path : PathsChecked)
356+     HOpts.AddPath (Path, clang::frontend::Angled, IsFramework, IsSysRootRelative);
357+ 
358+   if  (HOpts.Verbose ) {
359+     LLVM_DEBUG (dbgs () << " Added include paths:\n " 
360+     for  (llvm::StringRef Path : PathsChecked)
361+       LLVM_DEBUG (dbgs () << "   " " \n " 
362+   }
363+ 
364+ #undef   DEBUG_TYPE
365+ }
366+ 
325367} //  namespace utils
326368} //  namespace Cpp
0 commit comments