Skip to content

Commit 3e57dd2

Browse files
authored
Add functions back in
1 parent 91b3a8b commit 3e57dd2

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

lib/Interpreter/Paths.cpp

+42
Original file line numberDiff line numberDiff line change
@@ -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 \"" << Path << "\"\n");
239+
#undef DEBUG_TYPE
240+
}
236241

237242
bool 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() << " " << Path << "\n");
362+
}
363+
364+
#undef DEBUG_TYPE
365+
}
366+
325367
} // namespace utils
326368
} // namespace Cpp

lib/Interpreter/Paths.h

+16
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,22 @@ bool SplitPaths(llvm::StringRef PathStr,
8383
llvm::StringRef Delim = Cpp::utils::platform::kEnvDelim,
8484
bool Verbose = false);
8585

86+
///\brief Adds multiple include paths separated by a delimter into the
87+
/// given HeaderSearchOptions. This adds the paths but does no further
88+
/// processing. See Interpreter::AddIncludePaths or CIFactory::createCI
89+
/// for examples of what needs to be done once the paths have been added.
90+
///
91+
///\param[in] PathStr - Path(s)
92+
///\param[in] Opts - HeaderSearchOptions to add paths into
93+
///\param[in] Delim - Delimiter to separate paths or NULL if a single path
94+
///
95+
void AddIncludePaths(llvm::StringRef PathStr, clang::HeaderSearchOptions& HOpts,
96+
const char* Delim = Cpp::utils::platform::kEnvDelim);
97+
98+
///\brief Write to cling::errs that directory does not exist in a format
99+
/// matching what 'clang -v' would do
100+
///
101+
void LogNonExistantDirectory(llvm::StringRef Path);
86102

87103
///\brief Copies the current include paths into the HeaderSearchOptions.
88104
///

0 commit comments

Comments
 (0)