Skip to content

Commit 111d0e5

Browse files
authored
Remove unused code (#356)
1 parent 056118a commit 111d0e5

File tree

2 files changed

+0
-151
lines changed

2 files changed

+0
-151
lines changed

lib/Interpreter/Paths.cpp

Lines changed: 0 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -121,21 +121,6 @@ namespace platform {
121121
return Lib;
122122
}
123123

124-
void* DLSym(const std::string& Name, std::string* Err /* = nullptr*/) {
125-
if (void* Self = ::dlopen(nullptr, RTLD_GLOBAL)) {
126-
// get dlopen error if there is one
127-
DLErr(Err);
128-
void* Sym = ::dlsym(Self, Name.c_str());
129-
// overwrite error if dlsym caused one
130-
DLErr(Err);
131-
// only get dlclose error if dlopen & dlsym haven't emited one
132-
DLClose(Self, Err && Err->empty() ? Err : nullptr);
133-
return Sym;
134-
}
135-
DLErr(Err);
136-
return nullptr;
137-
}
138-
139124
void DLClose(void* Lib, std::string* Err /* = nullptr*/) {
140125
::dlclose(Lib);
141126
DLErr(Err);
@@ -158,28 +143,6 @@ namespace platform {
158143

159144
} // namespace platform
160145

161-
bool ExpandEnvVars(std::string& Str, bool Path) {
162-
std::size_t DPos = Str.find("$");
163-
while (DPos != std::string::npos) {
164-
std::size_t SPos = Str.find("/", DPos + 1);
165-
std::size_t Length = Str.length();
166-
167-
if (SPos != std::string::npos) // if we found a "/"
168-
Length = SPos - DPos;
169-
170-
std::string EnvVar = Str.substr(DPos + 1, Length -1); //"HOME"
171-
std::string FullPath;
172-
if (const char* Tok = GetEnv(EnvVar.c_str()))
173-
FullPath = Tok;
174-
175-
Str.replace(DPos, Length, FullPath);
176-
DPos = Str.find("$", DPos + 1); // search for next env variable
177-
}
178-
if (!Path)
179-
return true;
180-
return llvm::sys::fs::exists(Str.c_str());
181-
}
182-
183146
using namespace llvm;
184147
using namespace clang;
185148

@@ -268,84 +231,12 @@ void CopyIncludePaths(const clang::HeaderSearchOptions& Opts,
268231
incpaths.push_back("-v");
269232
}
270233

271-
void DumpIncludePaths(const clang::HeaderSearchOptions& Opts,
272-
llvm::raw_ostream& Out,
273-
bool WithSystem, bool WithFlags) {
274-
llvm::SmallVector<std::string, 100> IncPaths;
275-
CopyIncludePaths(Opts, IncPaths, WithSystem, WithFlags);
276-
// print'em all
277-
for (unsigned i = 0; i < IncPaths.size(); ++i) {
278-
Out << IncPaths[i] <<"\n";
279-
}
280-
}
281-
282234
void LogNonExistantDirectory(llvm::StringRef Path) {
283235
#define DEBUG_TYPE "LogNonExistantDirectory"
284236
LLVM_DEBUG(dbgs() << " ignoring nonexistent directory \"" << Path << "\"\n");
285237
#undef DEBUG_TYPE
286238
}
287239

288-
static void LogFileStatus(const char* Prefix, const char* FileType,
289-
llvm::StringRef Path) {
290-
#define DEBUG_TYPE "LogFileStatus"
291-
LLVM_DEBUG(dbgs() << Prefix << " " << FileType << " '" << Path << "'\n";);
292-
#undef DEBUG_TYPE
293-
}
294-
295-
bool LookForFile(const std::vector<const char*>& Args, std::string& Path,
296-
const clang::FileManager* FM, const char* FileType) {
297-
if (llvm::sys::fs::is_regular_file(Path)) {
298-
if (FileType)
299-
LogFileStatus("Using", FileType, Path);
300-
return true;
301-
}
302-
if (FileType)
303-
LogFileStatus("Ignoring", FileType, Path);
304-
305-
SmallString<1024> FilePath;
306-
if (FM) {
307-
FilePath.assign(Path);
308-
if (FM->FixupRelativePath(FilePath) &&
309-
llvm::sys::fs::is_regular_file(FilePath)) {
310-
if (FileType)
311-
LogFileStatus("Using", FileType, FilePath.str());
312-
Path = FilePath.str().str();
313-
return true;
314-
}
315-
// Don't write same same log entry twice when FilePath == Path
316-
if (FileType && FilePath.str() != Path)
317-
LogFileStatus("Ignoring", FileType, FilePath);
318-
}
319-
else if (llvm::sys::path::is_absolute(Path))
320-
return false;
321-
322-
for (std::vector<const char*>::const_iterator It = Args.begin(),
323-
End = Args.end(); It < End; ++It) {
324-
const char* Arg = *It;
325-
// TODO: Suppport '-iquote' and MSVC equivalent
326-
if (!::strncmp("-I", Arg, 2) || !::strncmp("/I", Arg, 2)) {
327-
if (!Arg[2]) {
328-
if (++It >= End)
329-
break;
330-
FilePath.assign(*It);
331-
}
332-
else
333-
FilePath.assign(Arg + 2);
334-
335-
llvm::sys::path::append(FilePath, Path.c_str());
336-
if (llvm::sys::fs::is_regular_file(FilePath)) {
337-
if (FileType)
338-
LogFileStatus("Using", FileType, FilePath.str());
339-
Path = FilePath.str().str();
340-
return true;
341-
}
342-
if (FileType)
343-
LogFileStatus("Ignoring", FileType, FilePath);
344-
}
345-
}
346-
return false;
347-
}
348-
349240
bool SplitPaths(llvm::StringRef PathStr,
350241
llvm::SmallVectorImpl<llvm::StringRef>& Paths,
351242
SplitMode Mode, llvm::StringRef Delim, bool Verbose) {

lib/Interpreter/Paths.h

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@ std::string NormalizePath(const std::string& Path);
4949
///
5050
void* DLOpen(const std::string& Path, std::string* Err = nullptr);
5151

52-
void* DLSym(const std::string& Name, std::string* Err = nullptr);
53-
5452
///\brief Close a handle to a shared library.
5553
///
5654
/// \param [in] Lib - Handle to library from previous call to DLOpen
@@ -61,17 +59,6 @@ void* DLSym(const std::string& Name, std::string* Err = nullptr);
6159
void DLClose(void* Lib, std::string* Err = nullptr);
6260
} // namespace platform
6361

64-
///\brief Replace all $TOKENS in a string with environent variable values.
65-
///
66-
/// \param [in,out] Str - String with tokens to replace (in place)
67-
/// \param [in] Path - Check if the result is a valid filesystem path.
68-
///
69-
/// \returns When Path is true, return whether Str was expanded to an
70-
/// existing file-system object.
71-
/// Return value has no meaning when Path is false.
72-
///
73-
bool ExpandEnvVars(std::string& Str, bool Path = false);
74-
7562
enum SplitMode {
7663
kPruneNonExistant, ///< Don't add non-existant paths into output
7764
kFailNonExistant, ///< Fail on any non-existant paths
@@ -96,22 +83,6 @@ bool SplitPaths(llvm::StringRef PathStr,
9683
llvm::StringRef Delim = Cpp::utils::platform::kEnvDelim,
9784
bool Verbose = false);
9885

99-
///\brief Look for given file that can be reachable from current working
100-
/// directory or any user supplied include paths in Args. This is useful
101-
/// to look for a file (precompiled header) before a Preprocessor instance
102-
/// has been created.
103-
///
104-
/// \param [in] Args - The argv vector to look for '-I' & '/I' flags
105-
/// \param [in,out] File - File to look for, may mutate to an absolute path
106-
/// \param [in] FM - File manger to resolve current dir with (can be null)
107-
/// \param [in] FileType - File type for logging or nullptr for no logging
108-
///
109-
/// \return true if File is reachable and is a regular file
110-
///
111-
bool LookForFile(const std::vector<const char*>& Args, std::string& File,
112-
const clang::FileManager* FM = nullptr,
113-
const char* FileType = nullptr);
114-
11586
///\brief Adds multiple include paths separated by a delimter into the
11687
/// given HeaderSearchOptions. This adds the paths but does no further
11788
/// processing. See Interpreter::AddIncludePaths or CIFactory::createCI
@@ -145,19 +116,6 @@ void CopyIncludePaths(const clang::HeaderSearchOptions& Opts,
145116
llvm::SmallVectorImpl<std::string>& Paths,
146117
bool WithSystem, bool WithFlags);
147118

148-
///\brief Prints the current include paths into the HeaderSearchOptions.
149-
///
150-
///\param[in] Opts - HeaderSearchOptions to read from
151-
///\param[in] Out - Stream to dump to
152-
///\param[in] WithSystem - dump contain system paths (framework, STL etc).
153-
///\param[in] WithFlags - if true, each line will be prefixed
154-
/// with a "-I" or similar, and some entries of incpaths will signal
155-
/// a new include path region (e.g. "-cxx-isystem"). Also, flags
156-
/// defining header search behavior will be included in incpaths, e.g.
157-
/// "-nostdinc".
158-
///
159-
void DumpIncludePaths(const clang::HeaderSearchOptions& Opts,
160-
llvm::raw_ostream& Out, bool WithSystem, bool WithFlags);
161119
} // namespace utils
162120
} // namespace Cpp
163121

0 commit comments

Comments
 (0)