@@ -121,21 +121,6 @@ namespace platform {
121
121
return Lib;
122
122
}
123
123
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
-
139
124
void DLClose (void * Lib, std::string* Err /* = nullptr*/ ) {
140
125
::dlclose (Lib);
141
126
DLErr (Err);
@@ -158,28 +143,6 @@ namespace platform {
158
143
159
144
} // namespace platform
160
145
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
-
183
146
using namespace llvm ;
184
147
using namespace clang ;
185
148
@@ -268,84 +231,12 @@ void CopyIncludePaths(const clang::HeaderSearchOptions& Opts,
268
231
incpaths.push_back (" -v" );
269
232
}
270
233
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
-
282
234
void LogNonExistantDirectory (llvm::StringRef Path) {
283
235
#define DEBUG_TYPE " LogNonExistantDirectory"
284
236
LLVM_DEBUG (dbgs () << " ignoring nonexistent directory \" " << Path << " \"\n " );
285
237
#undef DEBUG_TYPE
286
238
}
287
239
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
-
349
240
bool SplitPaths (llvm::StringRef PathStr,
350
241
llvm::SmallVectorImpl<llvm::StringRef>& Paths,
351
242
SplitMode Mode, llvm::StringRef Delim, bool Verbose) {
0 commit comments