@@ -233,6 +233,11 @@ void CopyIncludePaths(const clang::HeaderSearchOptions& Opts,
233
233
incpaths.push_back (" -v" );
234
234
}
235
235
236
+ void LogNonExistantDirectory (llvm::StringRef Path) {
237
+ #define DEBUG_TYPE " LogNonExistantDirectory"
238
+ LLVM_DEBUG (dbgs () << " ignoring nonexistent directory \" " << Path << " \"\n " );
239
+ #undef DEBUG_TYPE
240
+ }
236
241
237
242
bool SplitPaths (llvm::StringRef PathStr,
238
243
llvm::SmallVectorImpl<llvm::StringRef>& Paths,
@@ -322,5 +327,42 @@ bool SplitPaths(llvm::StringRef PathStr,
322
327
}
323
328
324
329
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 () << " " << Path << " \n " );
362
+ }
363
+
364
+ #undef DEBUG_TYPE
365
+ }
366
+
325
367
} // namespace utils
326
368
} // namespace Cpp
0 commit comments