llvm.org GIT mirror llvm / 07adb28
Stop propagating method names that violate the coding standard git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@17498 91177308-0d34-0410-b5e6-96231b3b80d8 Reid Spencer 14 years ago
28 changed file(s) with 418 addition(s) and 407 deletion(s). Raw diff Collapse all Expand all
3333 /// one invalid Path which is the empty path. The class should never allow any
3434 /// other syntactically invalid non-empty path name to be assigned. Empty
3535 /// paths are required in order to indicate an error result. If the path is
36 /// empty, the is_valid operation will return false. All operations will fail
37 /// if is_valid is false. Operations that change the path will either return
36 /// empty, the isValid operation will return false. All operations will fail
37 /// if isValid is false. Operations that change the path will either return
3838 /// false if it would cause a syntactically invalid path name (in which case
3939 /// the Path object is left unchanged) or throw an std::string exception
4040 /// indicating the error.
137137 /// the program. However, if the path is not valid, the Path object will
138138 /// be set to an empty string and an exception will be thrown.
139139 /// @throws std::string if the path string is not legal.
140 /// @param unvalidated_path The path to verify and assign.
140 /// @param unverified_path The path to verify and assign.
141141 /// @brief Construct a Path from a string.
142142 explicit Path(std::string unverified_path);
143143
192192 /// @returns true iff the path name is syntactically legal for the
193193 /// host operating system.
194194 /// @brief Determine if a path is syntactically valid or not.
195 bool is_valid() const;
195 bool isValid() const;
196196
197197 /// This function determines if the contents of the path name are
198198 /// empty. That is, the path has a zero length.
199199 /// @returns true iff the path is empty.
200200 /// @brief Determines if the path name is empty (invalid).
201 bool is_empty() const { return path.empty(); }
201 bool isEmpty() const { return path.empty(); }
202202
203203 /// This function determines if the path name in this object is intended
204204 /// to reference a legal file name (as opposed to a directory name). This
206206 /// determines if the syntax of the path represents a file name or not.
207207 /// @returns true if this path name references a file.
208208 /// @brief Determines if the path name references a file.
209 bool is_file() const;
209 bool isFile() const;
210210
211211 /// This function determines if the path name in this object is intended
212212 /// to reference a legal directory name (as opposed to a file name). This
215215 /// not.
216216 /// @returns true if the path name references a directory
217217 /// @brief Determines if the path name references a directory.
218 bool is_directory() const;
218 bool isDirectory() const;
219219
220220 /// This function determines if the path name in this object references
221221 /// the root (top level directory) of the file system. The details of what
223223 /// will do the necessary checking.
224224 /// @returns true iff the path name references the root directory.
225225 /// @brief Determines if the path references the root directory.
226 bool is_root_directory() const;
226 bool isRootDirectory() const;
227227
228228 /// This function opens the file associated with the path name provided by
229229 /// the Path object and reads its magic number. If the magic number at the
231231 /// cases (file not found, file not accessible, etc.) it returns false.
232232 /// @returns true if the magic number of the file matches \p magic.
233233 /// @brief Determine if file has a specific magic number
234 bool has_magic_number(const std::string& magic) const;
234 bool hasMagicNumber(const std::string& magic) const;
235235
236236 /// This function determines if the path name in the object references an
237237 /// archive file by looking at its magic number.
238238 /// @returns true if the file starts with the magic number for an archive
239239 /// file.
240240 /// @brief Determine if the path references an archive file.
241 bool is_archive() const;
241 bool isArchive() const;
242242
243243 /// This function determines if the path name in the object references an
244244 /// LLVM Bytecode file by looking at its magic number.
245245 /// @returns true if the file starts with the magic number for LLVM
246246 /// bytecode files.
247247 /// @brief Determine if the path references a bytecode file.
248 bool is_bytecode_file() const;
248 bool isBytecodeFile() const;
249249
250250 /// This function determines if the path name references an existing file
251 /// or directory in the file system. Unlike is_file and is_directory, this
251 /// or directory in the file system. Unlike isFile and isDirectory, this
252252 /// function actually checks for the existence of the file or directory.
253253 /// @returns true if the pathname references an existing file.
254254 /// @brief Determines if the path is a file or directory in
256256 bool exists() const;
257257
258258 /// This function determines if the path name references a readable file
259 /// or directory in the file system. Unlike is_file and is_directory, this
259 /// or directory in the file system. Unlike isFile and isDirectory, this
260260 /// function actually checks for the existence and readability (by the
261261 /// current program) of the file or directory.
262262 /// @returns true if the pathname references a readable file.
265265 bool readable() const;
266266
267267 /// This function determines if the path name references a writable file
268 /// or directory in the file system. Unlike is_file and is_directory, this
268 /// or directory in the file system. Unlike isFile and isDirectory, this
269269 /// function actually checks for the existence and writability (by the
270270 /// current program) of the file or directory.
271271 /// @returns true if the pathname references a writable file.
274274 bool writable() const;
275275
276276 /// This function determines if the path name references an executable
277 /// file in the file system. Unlike is_file and is_directory, this
277 /// file in the file system. Unlike isFile and isDirectory, this
278278 /// function actually checks for the existence and executability (by
279279 /// the current program) of the file.
280280 /// @returns true if the pathname references an executable file.
290290 std::string get() const { return path; }
291291
292292 /// This function returns the last component of the path name. If the
293 /// is_directory() function would return true then this returns the name
294 /// of the last directory in the path. If the is_file() function would
293 /// isDirectory() function would return true then this returns the name
294 /// of the last directory in the path. If the isFile() function would
295295 /// return true then this function returns the name of the file without
296296 /// any of the preceding directories.
297297 /// @returns std::string containing the last component of the path name.
303303 /// @returns std::string containing the basename of the path
304304 /// @throws nothing
305305 /// @brief Get the base name of the path
306 std::string get_basename() const;
306 std::string getBasename() const;
307307
308308 /// @returns a c string containing the path name.
309309 /// @brief Returns the path as a C string.
328328 /// @param unverified_path The path to be set in Path object.
329329 /// @throws nothing
330330 /// @brief Set a full path from a std::string
331 bool set_directory(const std::string& unverified_path);
331 bool setDirectory(const std::string& unverified_path);
332332
333333 /// This method attempts to set the Path object to \p unverified_path
334334 /// and interpret the name as a file name. The \p unverified_path
339339 /// @param unverified_path The path to be set in Path object.
340340 /// @throws nothing
341341 /// @brief Set a full path from a std::string
342 bool set_file(const std::string& unverified_path);
342 bool setFile(const std::string& unverified_path);
343343
344344 /// The \p dirname is added to the end of the Path if it is a legal
345345 /// directory name for the operating system. The precondition for this
346346 /// function is that the Path must reference a directory name (i.e.
347 /// is_directory() returns true).
347 /// isDirectory() returns true).
348348 /// @param dirname A string providing the directory name to
349349 /// be added to the end of the path.
350350 /// @returns false if the directory name could not be added
351351 /// @throws nothing
352352 /// @brief Adds the name of a directory to a Path.
353 bool append_directory( const std::string& dirname );
353 bool appendDirectory( const std::string& dirname );
354354
355355 /// One directory component is removed from the Path name. The Path must
356 /// refer to a non-root directory name (i.e. is_directory() returns true
357 /// but is_root_directory() returns false). Upon exit, the Path will
356 /// refer to a non-root directory name (i.e. isDirectory() returns true
357 /// but isRootDirectory() returns false). Upon exit, the Path will
358358 /// refer to the directory above it.
359359 /// @throws nothing
360360 /// @returns false if the directory name could not be removed.
361361 /// @brief Removes the last directory component of the Path.
362 bool elide_directory();
362 bool elideDirectory();
363363
364364 /// The \p filename is added to the end of the Path if it is a legal
365365 /// directory name for the operating system. The precondition for this
366366 /// function is that the Path reference a directory name (i.e.
367 /// is_directory() returns true).
367 /// isDirectory() returns true).
368368 /// @throws nothing
369369 /// @returns false if the file name could not be added.
370370 /// @brief Appends the name of a file.
371 bool append_file( const std::string& filename );
371 bool appendFile( const std::string& filename );
372372
373373 /// One file component is removed from the Path name. The Path must
374 /// refer to a file (i.e. is_file() returns true). Upon exit,
374 /// refer to a file (i.e. isFile() returns true). Upon exit,
375375 /// the Path will refer to the directory above it.
376376 /// @throws nothing
377377 /// @returns false if the file name could not be removed
378378 /// @brief Removes the last file component of the path.
379 bool elide_file();
379 bool elideFile();
380380
381381 /// A period and the \p suffix are appended to the end of the pathname.
382382 /// The precondition for this function is that the Path reference a file
383 /// name (i.e. is_file() returns true). If the Path is not a file, no
383 /// name (i.e. isFile() returns true). If the Path is not a file, no
384384 /// action is taken and the function returns false. If the path would
385385 /// become invalid for the host operating system, false is returned.
386386 /// @returns false if the suffix could not be added, true if it was.
387387 /// @throws nothing
388388 /// @brief Adds a period and the \p suffix to the end of the pathname.
389 bool append_suffix(const std::string& suffix);
389 bool appendSuffix(const std::string& suffix);
390390
391391 /// The suffix of the filename is removed. The suffix begins with and
392392 /// includes the last . character in the filename after the last directory
397397 /// @returns false if there was no suffix to remove, true otherwise.
398398 /// @throws nothing
399399 /// @brief Remove the suffix from a path name.
400 bool elide_suffix();
400 bool elideSuffix();
401401
402402 /// This method attempts to create a directory in the file system with the
403403 /// same name as the Path object. The \p create_parents parameter controls
412412 /// components other than the last one (the "parents") are created or not.
413413 /// @throws std::string if an error occurs.
414414 /// @brief Create the directory this Path refers to.
415 bool create_directory( bool create_parents = false );
415 bool createDirectory( bool create_parents = false );
416416
417417 /// This method attempts to create a file in the file system with the same
418418 /// name as the Path object. The intermediate directories must all exist
419 /// at the time this method is called. Use create_directories to
419 /// at the time this method is called. Use createDirectories to
420420 /// accomplish that. The created file will be empty upon return from this
421421 /// function.
422422 /// @returns false if the Path does not reference a file, true otherwise.
423423 /// @throws std::string if an error occurs.
424424 /// @brief Create the file this Path refers to.
425 bool create_file();
425 bool createFile();
426426
427427 /// This method attempts to destroy the directory named by the last in
428428 /// the Path name. If \p remove_contents is false, an attempt will be
436436 /// otherwise.
437437 /// @throws std::string if there is an error.
438438 /// @brief Removes the file or directory from the filesystem.
439 bool destroy_directory( bool destroy_contents = false );
439 bool destroyDirectory( bool destroy_contents = false );
440440
441441 /// This method attempts to destroy the file named by the last item in the
442442 /// Path name.
443443 /// @returns false if the Path does not refer to a file, true otherwise.
444444 /// @throws std::string if there is an error.
445445 /// @brief Destroy the file this Path refers to.
446 bool destroy_file();
446 bool destroyFile();
447447
448448 /// @}
449449 /// @name Data
945945 // If the source library's module id is in the dependent library list of the
946946 // destination library, remove it since that module is now linked in.
947947 sys::Path modId;
948 modId.set_file(Src->getModuleIdentifier());
949 if (!modId.is_empty())
950 Dest->removeLibrary(modId.get_basename());
948 modId.setFile(Src->getModuleIdentifier());
949 if (!modId.isEmpty())
950 Dest->removeLibrary(modId.getBasename());
951951
952952 return false;
953953 }
2323 //===----------------------------------------------------------------------===//
2424
2525 bool
26 Path::is_valid() const {
26 Path::isValid() const {
2727 if (path.empty())
2828 return false;
2929 if (path.length() >= MAXPATHLEN)
4242 if (!mkdir(TmpName, S_IRWXU))
4343 ThrowErrno(std::string(TmpName) + ": Can't create temporary directory");
4444 Path result;
45 result.set_directory(TmpName);
46 assert(result.is_valid() && "mkdtemp didn't create a valid pathname!");
45 result.setDirectory(TmpName);
46 assert(result.isValid() && "mkdtemp didn't create a valid pathname!");
4747 return result;
4848 }
4949
2222 using namespace sys;
2323
2424 bool
25 Path::is_valid() const {
25 Path::isValid() const {
2626 if (path.empty())
2727 return false;
2828 char pathname[MAXPATHLEN];
3838 if (0 == pathname)
3939 ThrowErrno(std::string("Can't create temporary directory name"));
4040 Path result;
41 result.set_directory(pathname);
41 result.setDirectory(pathname);
4242 free(pathname);
43 assert(result.is_valid() && "tempnam didn't create a valid pathname!");
43 assert(result.isValid() && "tempnam didn't create a valid pathname!");
4444 if (0 != mkdir(result.c_str(), S_IRWXU))
4545 ThrowErrno(result.get() + ": Can't create temporary directory");
4646 return result;
2222 using namespace sys;
2323
2424 bool
25 Path::is_valid() const {
25 Path::isValid() const {
2626 if (path.empty())
2727 return false;
2828 if (path.length() >= MAXPATHLEN)
3737 if (0 == mkdtemp(pathname))
3838 ThrowErrno(std::string(pathname) + ": Can't create temporary directory");
3939 Path result;
40 result.set_directory(pathname);
41 assert(result.is_valid() && "mkdtemp didn't create a valid pathname!");
40 result.setDirectory(pathname);
41 assert(result.isValid() && "mkdtemp didn't create a valid pathname!");
4242 return result;
4343 }
4444
2222 using namespace sys;
2323
2424 bool
25 Path::is_valid() const {
25 Path::isvalid() const {
2626 if (path.empty())
2727 return false;
2828 char pathname[MAXPATHLEN];
3939 if (0 == mkdtemp(pathname))
4040 ThrowErrno(std::string(pathname) + ": Can't create temporary directory");
4141 Path result;
42 result.set_directory(pathname);
43 assert(result.is_valid() && "mkdtemp didn't create a valid pathname!");
42 result.setDirectory(pathname);
43 assert(result.isValid() && "mkdtemp didn't create a valid pathname!");
4444 return result;
4545 }
4646
2222 using namespace sys;
2323
2424 bool
25 Path::is_valid() const {
25 Path::isValid() const {
2626 if (path.empty())
2727 return false;
2828 char pathname[MAXPATHLEN];
3939 if (0 == mkdtemp(pathname))
4040 ThrowErrno(std::string(pathname) + ": Can't create temporary directory");
4141 Path result;
42 result.set_directory(pathname);
43 assert(result.is_valid() && "mkdtemp didn't create a valid pathname!");
42 result.setDirectory(pathname);
43 assert(result.isValid() && "mkdtemp didn't create a valid pathname!");
4444 return result;
4545 }
4646
2222 using namespace sys;
2323
2424 bool
25 Path::is_valid() const {
25 Path::isValid() const {
2626 if (path.empty())
2727 return false;
2828 char pathname[MAXPATHLEN];
3939 if (0 == mkdtemp(pathname))
4040 ThrowErrno(std::string(pathname) + ": Can't create temporary directory");
4141 Path result;
42 result.set_directory(pathname);
43 assert(result.is_valid() && "mkdtemp didn't create a valid pathname!");
42 result.setDirectory(pathname);
43 assert(result.isValid() && "mkdtemp didn't create a valid pathname!");
4444 return result;
4545 }
4646
2222 using namespace sys;
2323
2424 bool
25 Path::is_valid() const {
25 Path::isValid() const {
2626 if (path.empty())
2727 return false;
2828 char pathname[MAXPATHLEN];
3838 if (0 == pathname)
3939 ThrowErrno(std::string("Can't create temporary directory name"));
4040 Path result;
41 result.set_directory(pathname);
41 result.setDirectory(pathname);
4242 free(pathname);
43 assert(result.is_valid() && "tempnam didn't create a valid pathname!");
43 assert(result.isValid() && "tempnam didn't create a valid pathname!");
4444 if (0 != mkdir(result.c_str(), S_IRWXU))
4545 ThrowErrno(result.get() + ": Can't create temporary directory");
4646 return result;
2929 {
3030 if (unverified_path.empty())
3131 return;
32 if (this->is_valid())
32 if (this->isValid())
3333 return;
3434 // oops, not valid.
3535 path.clear();
3939 Path
4040 Path::GetRootDirectory() {
4141 Path result;
42 result.set_directory("/");
42 result.setDirectory("/");
4343 return result;
4444 }
4545
4646 static inline bool IsLibrary(Path& path, const std::string& basename) {
47 if (path.append_file(std::string("lib") + basename)) {
48 if (path.append_suffix(Path::GetDLLSuffix()) && path.readable())
49 return true;
50 else if (path.elide_suffix() && path.append_suffix("a") && path.readable())
51 return true;
52 else if (path.elide_suffix() && path.append_suffix("o") && path.readable())
53 return true;
54 else if (path.elide_suffix() && path.append_suffix("bc") && path.readable())
55 return true;
56 } else if (path.elide_file() && path.append_file(basename)) {
57 if (path.append_suffix(Path::GetDLLSuffix()) && path.readable())
58 return true;
59 else if (path.elide_suffix() && path.append_suffix("a") && path.readable())
60 return true;
61 else if (path.elide_suffix() && path.append_suffix("o") && path.readable())
62 return true;
63 else if (path.elide_suffix() && path.append_suffix("bc") && path.readable())
47 if (path.appendFile(std::string("lib") + basename)) {
48 if (path.appendSuffix(Path::GetDLLSuffix()) && path.readable())
49 return true;
50 else if (path.elideSuffix() && path.appendSuffix("a") && path.readable())
51 return true;
52 else if (path.elideSuffix() && path.appendSuffix("o") && path.readable())
53 return true;
54 else if (path.elideSuffix() && path.appendSuffix("bc") && path.readable())
55 return true;
56 } else if (path.elideFile() && path.appendFile(basename)) {
57 if (path.appendSuffix(Path::GetDLLSuffix()) && path.readable())
58 return true;
59 else if (path.elideSuffix() && path.appendSuffix("a") && path.readable())
60 return true;
61 else if (path.elideSuffix() && path.appendSuffix("o") && path.readable())
62 return true;
63 else if (path.elideSuffix() && path.appendSuffix("bc") && path.readable())
6464 return true;
6565 }
6666 path.clear();
7575 // Try the paths provided
7676 for (std::vector::const_iterator I = LibPaths.begin(),
7777 E = LibPaths.end(); I != E; ++I ) {
78 if (result.set_directory(*I) && IsLibrary(result,basename))
78 if (result.setDirectory(*I) && IsLibrary(result,basename))
7979 return result;
8080 }
8181
8282 // Try the LLVM lib directory in the LLVM install area
83 if (result.set_directory(LLVM_LIBDIR) && IsLibrary(result,basename))
83 if (result.setDirectory(LLVM_LIBDIR) && IsLibrary(result,basename))
8484 return result;
8585
8686 // Try /usr/lib
87 if (result.set_directory("/usr/lib/") && IsLibrary(result,basename))
87 if (result.setDirectory("/usr/lib/") && IsLibrary(result,basename))
8888 return result;
8989
9090 // Try /lib
91 if (result.set_directory("/lib/") && IsLibrary(result,basename))
91 if (result.setDirectory("/lib/") && IsLibrary(result,basename))
9292 return result;
9393
9494 // Can't find it, give up and return invalid path.
114114 Path
115115 Path::GetLLVMConfigDir() {
116116 Path result;
117 if (result.set_directory(LLVM_ETCDIR))
117 if (result.setDirectory(LLVM_ETCDIR))
118118 return result;
119119 return GetLLVMDefaultConfigDir();
120120 }
124124 const char* home = getenv("HOME");
125125 if (home) {
126126 Path result;
127 if (result.set_directory(home))
127 if (result.setDirectory(home))
128128 return result;
129129 }
130130 return GetRootDirectory();
131131 }
132132
133133 bool
134 Path::is_file() const {
135 return (is_valid() && path[path.length()-1] != '/');
136 }
137
138 bool
139 Path::is_directory() const {
140 return (is_valid() && path[path.length()-1] == '/');
134 Path::isFile() const {
135 return (isValid() && path[path.length()-1] != '/');
136 }
137
138 bool
139 Path::isDirectory() const {
140 return (isValid() && path[path.length()-1] == '/');
141141 }
142142
143143 std::string
144 Path::get_basename() const {
144 Path::getBasename() const {
145145 // Find the last slash
146146 size_t slash = path.rfind('/');
147147 if (slash == std::string::npos)
152152 return path.substr(slash, path.rfind('.'));
153153 }
154154
155 bool Path::has_magic_number(const std::string &Magic) const {
155 bool Path::hasMagicNumber(const std::string &Magic) const {
156156 size_t len = Magic.size();
157157 char buf[ 1 + len];
158158 std::ifstream f(path.c_str());
162162 }
163163
164164 bool
165 Path::is_bytecode_file() const {
165 Path::isBytecodeFile() const {
166166 if (readable()) {
167 return has_magic_number("llvm");
167 return hasMagicNumber("llvm");
168168 }
169169 return false;
170170 }
171171
172172 bool
173 Path::is_archive() const {
173 Path::isArchive() const {
174174 if (readable()) {
175 return has_magic_number("!\012");
175 return hasMagicNumber("!\012");
176176 }
177177 return false;
178178 }
220220 }
221221
222222 bool
223 Path::set_directory(const std::string& a_path) {
223 Path::setDirectory(const std::string& a_path) {
224224 if (a_path.size() == 0)
225225 return false;
226226 Path save(*this);
228228 size_t last = a_path.size() -1;
229229 if (last != 0 && a_path[last] != '/')
230230 path += '/';
231 if (!is_valid()) {
231 if (!isValid()) {
232232 path = save.path;
233233 return false;
234234 }
236236 }
237237
238238 bool
239 Path::set_file(const std::string& a_path) {
239 Path::setFile(const std::string& a_path) {
240240 if (a_path.size() == 0)
241241 return false;
242242 Path save(*this);
245245 while (last > 0 && a_path[last] == '/')
246246 last--;
247247 path.erase(last+1);
248 if (!is_valid()) {
248 if (!isValid()) {
249249 path = save.path;
250250 return false;
251251 }
253253 }
254254
255255 bool
256 Path::append_directory(const std::string& dir) {
257 if (is_file())
256 Path::appendDirectory(const std::string& dir) {
257 if (isFile())
258258 return false;
259259 Path save(*this);
260260 path += dir;
261261 path += "/";
262 if (!is_valid()) {
262 if (!isValid()) {
263263 path = save.path;
264264 return false;
265265 }
267267 }
268268
269269 bool
270 Path::elide_directory() {
271 if (is_file())
270 Path::elideDirectory() {
271 if (isFile())
272272 return false;
273273 size_t slashpos = path.rfind('/',path.size());
274274 if (slashpos == 0 || slashpos == std::string::npos)
282282 }
283283
284284 bool
285 Path::append_file(const std::string& file) {
286 if (!is_directory())
285 Path::appendFile(const std::string& file) {
286 if (!isDirectory())
287287 return false;
288288 Path save(*this);
289289 path += file;
290 if (!is_valid()) {
290 if (!isValid()) {
291291 path = save.path;
292292 return false;
293293 }
295295 }
296296
297297 bool
298 Path::elide_file() {
299 if (is_directory())
298 Path::elideFile() {
299 if (isDirectory())
300300 return false;
301301 size_t slashpos = path.rfind('/',path.size());
302302 if (slashpos == std::string::npos)
306306 }
307307
308308 bool
309 Path::append_suffix(const std::string& suffix) {
310 if (is_directory())
309 Path::appendSuffix(const std::string& suffix) {
310 if (isDirectory())
311311 return false;
312312 Path save(*this);
313313 path.append(".");
314314 path.append(suffix);
315 if (!is_valid()) {
315 if (!isValid()) {
316316 path = save.path;
317317 return false;
318318 }
320320 }
321321
322322 bool
323 Path::elide_suffix() {
324 if (is_directory()) return false;
323 Path::elideSuffix() {
324 if (isDirectory()) return false;
325325 size_t dotpos = path.rfind('.',path.size());
326326 size_t slashpos = path.rfind('/',path.size());
327327 if (slashpos != std::string::npos && dotpos != std::string::npos &&
334334
335335
336336 bool
337 Path::create_directory( bool create_parents) {
337 Path::createDirectory( bool create_parents) {
338338 // Make sure we're dealing with a directory
339 if (!is_directory()) return false;
339 if (!isDirectory()) return false;
340340
341341 // Get a writeable copy of the path name
342342 char pathname[MAXPATHLEN];
371371 }
372372
373373 bool
374 Path::create_file() {
374 Path::createFile() {
375375 // Make sure we're dealing with a file
376 if (!is_file()) return false;
376 if (!isFile()) return false;
377377
378378 // Create the file
379379 int fd = ::creat(path.c_str(), S_IRUSR | S_IWUSR);
385385 }
386386
387387 bool
388 Path::destroy_directory(bool remove_contents) {
388 Path::destroyDirectory(bool remove_contents) {
389389 // Make sure we're dealing with a directory
390 if (!is_directory()) return false;
390 if (!isDirectory()) return false;
391391
392392 // If it doesn't exist, we're done.
393393 if (!exists()) return true;
411411 }
412412
413413 bool
414 Path::destroy_file() {
415 if (!is_file()) return false;
414 Path::destroyFile() {
415 if (!isFile()) return false;
416416 if (0 != unlink(path.c_str()))
417417 ThrowErrno(std::string(path.c_str()) + ": Can't destroy file");
418418 return true;
2929 {
3030 if (unverified_path.empty())
3131 return;
32 if (this->is_valid())
32 if (this->isValid())
3333 return;
3434 // oops, not valid.
3535 path.clear();
3939 Path
4040 Path::GetRootDirectory() {
4141 Path result;
42 result.set_directory("/");
42 result.setDirectory("/");
4343 return result;
4444 }
4545
4646 static inline bool IsLibrary(Path& path, const std::string& basename) {
47 if (path.append_file(std::string("lib") + basename)) {
48 if (path.append_suffix(Path::GetDLLSuffix()) && path.readable())
49 return true;
50 else if (path.elide_suffix() && path.append_suffix("a") && path.readable())
51 return true;
52 else if (path.elide_suffix() && path.append_suffix("o") && path.readable())
53 return true;
54 else if (path.elide_suffix() && path.append_suffix("bc") && path.readable())
55 return true;
56 } else if (path.elide_file() && path.append_file(basename)) {
57 if (path.append_suffix(Path::GetDLLSuffix()) && path.readable())
58 return true;
59 else if (path.elide_suffix() && path.append_suffix("a") && path.readable())
60 return true;
61 else if (path.elide_suffix() && path.append_suffix("o") && path.readable())
62 return true;
63 else if (path.elide_suffix() && path.append_suffix("bc") && path.readable())
47 if (path.appendFile(std::string("lib") + basename)) {
48 if (path.appendSuffix(Path::GetDLLSuffix()) && path.readable())
49 return true;
50 else if (path.elideSuffix() && path.appendSuffix("a") && path.readable())
51 return true;
52 else if (path.elideSuffix() && path.appendSuffix("o") && path.readable())
53 return true;
54 else if (path.elideSuffix() && path.appendSuffix("bc") && path.readable())
55 return true;
56 } else if (path.elideFile() && path.appendFile(basename)) {
57 if (path.appendSuffix(Path::GetDLLSuffix()) && path.readable())
58 return true;
59 else if (path.elideSuffix() && path.appendSuffix("a") && path.readable())
60 return true;
61 else if (path.elideSuffix() && path.appendSuffix("o") && path.readable())
62 return true;
63 else if (path.elideSuffix() && path.appendSuffix("bc") && path.readable())
6464 return true;
6565 }
6666 path.clear();
7575 // Try the paths provided
7676 for (std::vector::const_iterator I = LibPaths.begin(),
7777 E = LibPaths.end(); I != E; ++I ) {
78 if (result.set_directory(*I) && IsLibrary(result,basename))
78 if (result.setDirectory(*I) && IsLibrary(result,basename))
7979 return result;
8080 }
8181
8282 // Try the LLVM lib directory in the LLVM install area
83 if (result.set_directory(LLVM_LIBDIR) && IsLibrary(result,basename))
83 if (result.setDirectory(LLVM_LIBDIR) && IsLibrary(result,basename))
8484 return result;
8585
8686 // Try /usr/lib
87 if (result.set_directory("/usr/lib/") && IsLibrary(result,basename))
87 if (result.setDirectory("/usr/lib/") && IsLibrary(result,basename))
8888 return result;
8989
9090 // Try /lib
91 if (result.set_directory("/lib/") && IsLibrary(result,basename))
91 if (result.setDirectory("/lib/") && IsLibrary(result,basename))
9292 return result;
9393
9494 // Can't find it, give up and return invalid path.
114114 Path
115115 Path::GetLLVMConfigDir() {
116116 Path result;
117 if (result.set_directory(LLVM_ETCDIR))
117 if (result.setDirectory(LLVM_ETCDIR))
118118 return result;
119119 return GetLLVMDefaultConfigDir();
120120 }
124124 const char* home = getenv("HOME");
125125 if (home) {
126126 Path result;
127 if (result.set_directory(home))
127 if (result.setDirectory(home))
128128 return result;
129129 }
130130 return GetRootDirectory();
131131 }
132132
133133 bool
134 Path::is_file() const {
135 return (is_valid() && path[path.length()-1] != '/');
136 }
137
138 bool
139 Path::is_directory() const {
140 return (is_valid() && path[path.length()-1] == '/');
134 Path::isFile() const {
135 return (isValid() && path[path.length()-1] != '/');
136 }
137
138 bool
139 Path::isDirectory() const {
140 return (isValid() && path[path.length()-1] == '/');
141141 }
142142
143143 std::string
144 Path::get_basename() const {
144 Path::getBasename() const {
145145 // Find the last slash
146146 size_t slash = path.rfind('/');
147147 if (slash == std::string::npos)
152152 return path.substr(slash, path.rfind('.'));
153153 }
154154
155 bool Path::has_magic_number(const std::string &Magic) const {
155 bool Path::hasMagicNumber(const std::string &Magic) const {
156156 size_t len = Magic.size();
157157 char buf[ 1 + len];
158158 std::ifstream f(path.c_str());
162162 }
163163
164164 bool
165 Path::is_bytecode_file() const {
165 Path::isBytecodeFile() const {
166166 if (readable()) {
167 return has_magic_number("llvm");
167 return hasMagicNumber("llvm");
168168 }
169169 return false;
170170 }
171171
172172 bool
173 Path::is_archive() const {
173 Path::isArchive() const {
174174 if (readable()) {
175 return has_magic_number("!\012");
175 return hasMagicNumber("!\012");
176176 }
177177 return false;
178178 }
220220 }
221221
222222 bool
223 Path::set_directory(const std::string& a_path) {
223 Path::setDirectory(const std::string& a_path) {
224224 if (a_path.size() == 0)
225225 return false;
226226 Path save(*this);
228228 size_t last = a_path.size() -1;
229229 if (last != 0 && a_path[last] != '/')
230230 path += '/';
231 if (!is_valid()) {
231 if (!isValid()) {
232232 path = save.path;
233233 return false;
234234 }
236236 }
237237
238238 bool
239 Path::set_file(const std::string& a_path) {
239 Path::setFile(const std::string& a_path) {
240240 if (a_path.size() == 0)
241241 return false;
242242 Path save(*this);
245245 while (last > 0 && a_path[last] == '/')
246246 last--;
247247 path.erase(last+1);
248 if (!is_valid()) {
248 if (!isValid()) {
249249 path = save.path;
250250 return false;
251251 }
253253 }
254254
255255 bool
256 Path::append_directory(const std::string& dir) {
257 if (is_file())
256 Path::appendDirectory(const std::string& dir) {
257 if (isFile())
258258 return false;
259259 Path save(*this);
260260 path += dir;
261261 path += "/";
262 if (!is_valid()) {
262 if (!isValid()) {
263263 path = save.path;
264264 return false;
265265 }
267267 }
268268
269269 bool
270 Path::elide_directory() {
271 if (is_file())
270 Path::elideDirectory() {
271 if (isFile())
272272 return false;
273273 size_t slashpos = path.rfind('/',path.size());
274274 if (slashpos == 0 || slashpos == std::string::npos)
282282 }
283283
284284 bool
285 Path::append_file(const std::string& file) {
286 if (!is_directory())
285 Path::appendFile(const std::string& file) {
286 if (!isDirectory())
287287 return false;
288288 Path save(*this);
289289 path += file;
290 if (!is_valid()) {
290 if (!isValid()) {
291291 path = save.path;
292292 return false;
293293 }
295295 }
296296
297297 bool
298 Path::elide_file() {
299 if (is_directory())
298 Path::elideFile() {
299 if (isDirectory())
300300 return false;
301301 size_t slashpos = path.rfind('/',path.size());
302302 if (slashpos == std::string::npos)
306306 }
307307
308308 bool
309 Path::append_suffix(const std::string& suffix) {
310 if (is_directory())
309 Path::appendSuffix(const std::string& suffix) {
310 if (isDirectory())
311311 return false;
312312 Path save(*this);
313313 path.append(".");
314314 path.append(suffix);
315 if (!is_valid()) {
315 if (!isValid()) {
316316 path = save.path;
317317 return false;
318318 }
320320 }
321321
322322 bool
323 Path::elide_suffix() {
324 if (is_directory()) return false;
323 Path::elideSuffix() {
324 if (isDirectory()) return false;
325325 size_t dotpos = path.rfind('.',path.size());
326326 size_t slashpos = path.rfind('/',path.size());
327327 if (slashpos != std::string::npos && dotpos != std::string::npos &&
334334
335335
336336 bool
337 Path::create_directory( bool create_parents) {
337 Path::createDirectory( bool create_parents) {
338338 // Make sure we're dealing with a directory
339 if (!is_directory()) return false;
339 if (!isDirectory()) return false;
340340
341341 // Get a writeable copy of the path name
342342 char pathname[MAXPATHLEN];
371371 }
372372
373373 bool
374 Path::create_file() {
374 Path::createFile() {
375375 // Make sure we're dealing with a file
376 if (!is_file()) return false;
376 if (!isFile()) return false;
377377
378378 // Create the file
379379 int fd = ::creat(path.c_str(), S_IRUSR | S_IWUSR);
385385 }
386386
387387 bool
388 Path::destroy_directory(bool remove_contents) {
388 Path::destroyDirectory(bool remove_contents) {
389389 // Make sure we're dealing with a directory
390 if (!is_directory()) return false;
390 if (!isDirectory()) return false;
391391
392392 // If it doesn't exist, we're done.
393393 if (!exists()) return true;
411411 }
412412
413413 bool
414 Path::destroy_file() {
415 if (!is_file()) return false;
414 Path::destroyFile() {
415 if (!isFile()) return false;
416416 if (0 != unlink(path.c_str()))
417417 ThrowErrno(std::string(path.c_str()) + ": Can't destroy file");
418418 return true;
3636 if (progName.length() == 0) // no program
3737 return Path();
3838 Path temp;
39 if (!temp.set_file(progName)) // invalid name
39 if (!temp.setFile(progName)) // invalid name
4040 return Path();
4141 if (temp.executable()) // already executable as is
4242 return temp;
5656
5757 // Check to see if this first directory contains the executable...
5858 Path FilePath;
59 if (FilePath.set_directory(std::string(PathStr,Colon))) {
60 FilePath.append_file(progName);
59 if (FilePath.setDirectory(std::string(PathStr,Colon))) {
60 FilePath.appendFile(progName);
6161 if (FilePath.executable())
6262 return FilePath; // Found the executable!
6363 }
3636 if (progName.length() == 0) // no program
3737 return Path();
3838 Path temp;
39 if (!temp.set_file(progName)) // invalid name
39 if (!temp.setFile(progName)) // invalid name
4040 return Path();
4141 if (temp.executable()) // already executable as is
4242 return temp;
5656
5757 // Check to see if this first directory contains the executable...
5858 Path FilePath;
59 if (FilePath.set_directory(std::string(PathStr,Colon))) {
60 FilePath.append_file(progName);
59 if (FilePath.setDirectory(std::string(PathStr,Colon))) {
60 FilePath.appendFile(progName);
6161 if (FilePath.executable())
6262 return FilePath; // Found the executable!
6363 }
110110
111111 if (DirectoriesToRemove != 0)
112112 while (!DirectoriesToRemove->empty()) {
113 DirectoriesToRemove->back().destroy_directory(true);
113 DirectoriesToRemove->back().destroyDirectory(true);
114114 DirectoriesToRemove->pop_back();
115115 }
116116
145145
146146 // RemoveDirectoryOnSignal - The public API
147147 void sys::RemoveDirectoryOnSignal(const llvm::sys::Path& path) {
148 if (!path.is_directory())
148 if (!path.isDirectory())
149149 return;
150150
151151 if (DirectoriesToRemove == 0)
110110
111111 if (DirectoriesToRemove != 0)
112112 while (!DirectoriesToRemove->empty()) {
113 DirectoriesToRemove->back().destroy_directory(true);
113 DirectoriesToRemove->back().destroyDirectory(true);
114114 DirectoriesToRemove->pop_back();
115115 }
116116
145145
146146 // RemoveDirectoryOnSignal - The public API
147147 void sys::RemoveDirectoryOnSignal(const llvm::sys::Path& path) {
148 if (!path.is_directory())
148 if (!path.isDirectory())
149149 return;
150150
151151 if (DirectoriesToRemove == 0)
3333 namespace sys {
3434
3535 bool
36 Path::is_valid() const {
36 Path::isValid() const {
3737 if (path.empty())
3838 return false;
3939
8080 throw std::string("Can't determine temporary directory");
8181
8282 Path result;
83 result.set_directory(pathname);
83 result.setDirectory(pathname);
8484
8585 // Append a subdirectory passed on our process id so multiple LLVMs don't
8686 // step on each other's toes.
8787 sprintf(pathname, "LLVM_%u", GetCurrentProcessId());
88 result.append_directory(pathname);
88 result.appendDirectory(pathname);
8989
9090 // If there's a directory left over from a previous LLVM execution that
9191 // happened to have the same process id, get rid of it.
92 result.destroy_directory(true);
92 result.destroyDirectory(true);
9393
9494 // And finally (re-)create the empty directory.
95 result.create_directory(false);
95 result.createDirectory(false);
9696 TempDirectory = new Path(result);
9797 return *TempDirectory;
9898 }
103103 FlipBackSlashes(path);
104104 if (unverified_path.empty())
105105 return;
106 if (this->is_valid())
106 if (this->isValid())
107107 return;
108108 // oops, not valid.
109109 path.clear();
114114 Path
115115 Path::GetRootDirectory() {
116116 Path result;
117 result.set_directory("/");
117 result.setDirectory("/");
118118 return result;
119119 }
120120
124124 }
125125
126126 static inline bool IsLibrary(Path& path, const std::string& basename) {
127 if (path.append_file(std::string("lib") + basename)) {
128 if (path.append_suffix(Path::GetDLLSuffix()) && path.readable())
129 return true;
130 else if (path.elide_suffix() && path.append_suffix("a") && path.readable())
131 return true;
132 else if (path.elide_suffix() && path.append_suffix("o") && path.readable())
133 return true;
134 else if (path.elide_suffix() && path.append_suffix("bc") && path.readable())
135 return true;
136 } else if (path.elide_file() && path.append_file(basename)) {
137 if (path.append_suffix(Path::GetDLLSuffix()) && path.readable())
138 return true;
139 else if (path.elide_suffix() && path.append_suffix("a") && path.readable())
140 return true;
141 else if (path.elide_suffix() && path.append_suffix("o") && path.readable())
142 return true;
143 else if (path.elide_suffix() && path.append_suffix("bc") && path.readable())
127 if (path.appendFile(std::string("lib") + basename)) {
128 if (path.appendSuffix(Path::GetDLLSuffix()) && path.readable())
129 return true;
130 else if (path.elideSuffix() && path.appendSuffix("a") && path.readable())
131 return true;
132 else if (path.elideSuffix() && path.appendSuffix("o") && path.readable())
133 return true;
134 else if (path.elideSuffix() && path.appendSuffix("bc") && path.readable())
135 return true;
136 } else if (path.elideFile() && path.appendFile(basename)) {
137 if (path.appendSuffix(Path::GetDLLSuffix()) && path.readable())
138 return true;
139 else if (path.elideSuffix() && path.appendSuffix("a") && path.readable())
140 return true;
141 else if (path.elideSuffix() && path.appendSuffix("o") && path.readable())
142 return true;
143 else if (path.elideSuffix() && path.appendSuffix("bc") && path.readable())
144144 return true;
145145 }
146146 path.clear();
155155 // Try the paths provided
156156 for (std::vector::const_iterator I = LibPaths.begin(),
157157 E = LibPaths.end(); I != E; ++I ) {
158 if (result.set_directory(*I) && IsLibrary(result,basename))
158 if (result.setDirectory(*I) && IsLibrary(result,basename))
159159 return result;
160160 }
161161
162162 // Try the LLVM lib directory in the LLVM install area
163 //if (result.set_directory(LLVM_LIBDIR) && IsLibrary(result,basename))
163 //if (result.setDirectory(LLVM_LIBDIR) && IsLibrary(result,basename))
164164 // return result;
165165
166166 // Try /usr/lib
167 if (result.set_directory("/usr/lib/") && IsLibrary(result,basename))
167 if (result.setDirectory("/usr/lib/") && IsLibrary(result,basename))
168168 return result;
169169
170170 // Try /lib
171 if (result.set_directory("/lib/") && IsLibrary(result,basename))
171 if (result.setDirectory("/lib/") && IsLibrary(result,basename))
172172 return result;
173173
174174 // Can't find it, give up and return invalid path.
201201 const char* home = getenv("HOME");
202202 if (home) {
203203 Path result;
204 if (result.set_directory(home))
204 if (result.setDirectory(home))
205205 return result;
206206 }
207207 return GetRootDirectory();
209209 // FIXME: the above set of functions don't map to Windows very well.
210210
211211 bool
212 Path::is_file() const {
213 return (is_valid() && path[path.length()-1] != '/');
214 }
215
216 bool
217 Path::is_directory() const {
218 return (is_valid() && path[path.length()-1] == '/');
212 Path::isFile() const {
213 return (isValid() && path[path.length()-1] != '/');
214 }
215
216 bool
217 Path::isDirectory() const {
218 return (isValid() && path[path.length()-1] == '/');
219219 }
220220
221221 std::string
222 Path::get_basename() const {
222 Path::getBasename() const {
223223 // Find the last slash
224224 size_t slash = path.rfind('/');
225225 if (slash == std::string::npos)
230230 return path.substr(slash, path.rfind('.'));
231231 }
232232
233 bool Path::has_magic_number(const std::string &Magic) const {
233 bool Path::hasMagicNumber(const std::string &Magic) const {
234234 size_t len = Magic.size();
235235 char *buf = reinterpret_cast(_alloca(len+1));
236236 std::ifstream f(path.c_str());
240240 }
241241
242242 bool
243 Path::is_bytecode_file() const {
243 Path::isBytecodeFile() const {
244244 if (readable()) {
245 return has_magic_number("llvm");
245 return hasMagicNumber("llvm");
246246 }
247247 return false;
248248 }
249249
250250 bool
251 Path::is_archive() const {
251 Path::isArchive() const {
252252 if (readable()) {
253 return has_magic_number("!\012");
253 return hasMagicNumber("!\012");
254254 }
255255 return false;
256256 }
305305 }
306306
307307 bool
308 Path::set_directory(const std::string& a_path) {
308 Path::setDirectory(const std::string& a_path) {
309309 if (a_path.size() == 0)
310310 return false;
311311 Path save(*this);
314314 size_t last = a_path.size() -1;
315315 if (last != 0 && a_path[last] != '/')
316316 path += '/';
317 if (!is_valid()) {
317 if (!isValid()) {
318318 path = save.path;
319319 return false;
320320 }
322322 }
323323
324324 bool
325 Path::set_file(const std::string& a_path) {
325 Path::setFile(const std::string& a_path) {
326326 if (a_path.size() == 0)
327327 return false;
328328 Path save(*this);
332332 while (last > 0 && a_path[last] == '/')
333333 last--;
334334 path.erase(last+1);
335 if (!is_valid()) {
335 if (!isValid()) {
336336 path = save.path;
337337 return false;
338338 }
340340 }
341341
342342 bool
343 Path::append_directory(const std::string& dir) {
344 if (is_file())
343 Path::appendDirectory(const std::string& dir) {
344 if (isFile())
345345 return false;
346346 Path save(*this);
347347 path += dir;
348348 path += "/";
349 if (!is_valid()) {
349 if (!isValid()) {
350350 path = save.path;
351351 return false;
352352 }
354354 }
355355
356356 bool
357 Path::elide_directory() {
358 if (is_file())
357 Path::elideDirectory() {
358 if (isFile())
359359 return false;
360360 size_t slashpos = path.rfind('/',path.size());
361361 if (slashpos == 0 || slashpos == std::string::npos)
369369 }
370370
371371 bool
372 Path::append_file(const std::string& file) {
373 if (!is_directory())
372 Path::appendFile(const std::string& file) {
373 if (!isDirectory())
374374 return false;
375375 Path save(*this);
376376 path += file;
377 if (!is_valid()) {
377 if (!isValid()) {
378378 path = save.path;
379379 return false;
380380 }
382382 }
383383
384384 bool
385 Path::elide_file() {
386 if (is_directory())
385 Path::elideFile() {
386 if (isDirectory())
387387 return false;
388388 size_t slashpos = path.rfind('/',path.size());
389389 if (slashpos == std::string::npos)
393393 }
394394
395395 bool
396 Path::append_suffix(const std::string& suffix) {
397 if (is_directory())
396 Path::appendSuffix(const std::string& suffix) {
397 if (isDirectory())
398398 return false;
399399 Path save(*this);
400400 path.append(".");
401401 path.append(suffix);
402 if (!is_valid()) {
402 if (!isValid()) {
403403 path = save.path;
404404 return false;
405405 }
407407 }
408408
409409 bool
410 Path::elide_suffix() {
411 if (is_directory()) return false;
410 Path::elideSuffix() {
411 if (isDirectory()) return false;
412412 size_t dotpos = path.rfind('.',path.size());
413413 size_t slashpos = path.rfind('/',path.size());
414414 if (slashpos != std::string::npos && dotpos != std::string::npos &&
421421
422422
423423 bool
424 Path::create_directory( bool create_parents) {
424 Path::createDirectory( bool create_parents) {
425425 // Make sure we're dealing with a directory
426 if (!is_directory()) return false;
426 if (!isDirectory()) return false;
427427
428428 // Get a writeable copy of the path name
429429 char *pathname = reinterpret_cast(_alloca(path.length()+1));
472472 }
473473
474474 bool
475 Path::create_file() {
475 Path::createFile() {
476476 // Make sure we're dealing with a file
477 if (!is_file()) return false;
477 if (!isFile()) return false;
478478
479479 // Create the file
480480 HANDLE h = CreateFile(path.c_str(), GENERIC_WRITE, 0, NULL, CREATE_NEW,
487487 }
488488
489489 bool
490 Path::destroy_directory(bool remove_contents) {
490 Path::destroyDirectory(bool remove_contents) {
491491 // Make sure we're dealing with a directory
492 if (!is_directory()) return false;
492 if (!isDirectory()) return false;
493493
494494 // If it doesn't exist, we're done.
495495 if (!exists()) return true;
516516 }
517517
518518 bool
519 Path::destroy_file() {
520 if (!is_file()) return false;
519 Path::destroyFile() {
520 if (!isFile()) return false;
521521
522522 DWORD attr = GetFileAttributes(path.c_str());
523523
3333 namespace sys {
3434
3535 bool
36 Path::is_valid() const {
36 Path::isValid() const {
3737 if (path.empty())
3838 return false;
3939
8080 throw std::string("Can't determine temporary directory");
8181
8282 Path result;
83 result.set_directory(pathname);
83 result.setDirectory(pathname);
8484
8585 // Append a subdirectory passed on our process id so multiple LLVMs don't
8686 // step on each other's toes.
8787 sprintf(pathname, "LLVM_%u", GetCurrentProcessId());
88 result.append_directory(pathname);
88 result.appendDirectory(pathname);
8989
9090 // If there's a directory left over from a previous LLVM execution that
9191 // happened to have the same process id, get rid of it.
92 result.destroy_directory(true);
92 result.destroyDirectory(true);
9393
9494 // And finally (re-)create the empty directory.
95 result.create_directory(false);
95 result.createDirectory(false);
9696 TempDirectory = new Path(result);
9797 return *TempDirectory;
9898 }
103103 FlipBackSlashes(path);
104104 if (unverified_path.empty())
105105 return;
106 if (this->is_valid())
106 if (this->isValid())
107107 return;
108108 // oops, not valid.
109109 path.clear();
114114 Path
115115 Path::GetRootDirectory() {
116116 Path result;
117 result.set_directory("/");
117 result.setDirectory("/");
118118 return result;
119119 }
120120
124124 }
125125
126126 static inline bool IsLibrary(Path& path, const std::string& basename) {
127 if (path.append_file(std::string("lib") + basename)) {
128 if (path.append_suffix(Path::GetDLLSuffix()) && path.readable())
129 return true;
130 else if (path.elide_suffix() && path.append_suffix("a") && path.readable())
131 return true;
132 else if (path.elide_suffix() && path.append_suffix("o") && path.readable())
133 return true;
134 else if (path.elide_suffix() && path.append_suffix("bc") && path.readable())
135 return true;
136 } else if (path.elide_file() && path.append_file(basename)) {
137 if (path.append_suffix(Path::GetDLLSuffix()) && path.readable())
138 return true;
139 else if (path.elide_suffix() && path.append_suffix("a") && path.readable())
140 return true;
141 else if (path.elide_suffix() && path.append_suffix("o") && path.readable())
142 return true;
143 else if (path.elide_suffix() && path.append_suffix("bc") && path.readable())
127 if (path.appendFile(std::string("lib") + basename)) {
128 if (path.appendSuffix(Path::GetDLLSuffix()) && path.readable())
129 return true;
130 else if (path.elideSuffix() && path.appendSuffix("a") && path.readable())
131 return true;
132 else if (path.elideSuffix() && path.appendSuffix("o") && path.readable())
133 return true;
134 else if (path.elideSuffix() && path.appendSuffix("bc") && path.readable())
135 return true;
136 } else if (path.elideFile() && path.appendFile(basename)) {
137 if (path.appendSuffix(Path::GetDLLSuffix()) && path.readable())
138 return true;
139 else if (path.elideSuffix() && path.appendSuffix("a") && path.readable())
140 return true;
141 else if (path.elideSuffix() && path.appendSuffix("o") && path.readable())
142 return true;
143 else if (path.elideSuffix() && path.appendSuffix("bc") && path.readable())
144144 return true;
145145 }
146146 path.clear();
155155 // Try the paths provided
156156 for (std::vector::const_iterator I = LibPaths.begin(),
157157 E = LibPaths.end(); I != E; ++I ) {
158 if (result.set_directory(*I) && IsLibrary(result,basename))
158 if (result.setDirectory(*I) && IsLibrary(result,basename))
159159 return result;
160160 }
161161
162162 // Try the LLVM lib directory in the LLVM install area
163 //if (result.set_directory(LLVM_LIBDIR) && IsLibrary(result,basename))
163 //if (result.setDirectory(LLVM_LIBDIR) && IsLibrary(result,basename))
164164 // return result;
165165
166166 // Try /usr/lib
167 if (result.set_directory("/usr/lib/") && IsLibrary(result,basename))
167 if (result.setDirectory("/usr/lib/") && IsLibrary(result,basename))
168168 return result;
169169
170170 // Try /lib
171 if (result.set_directory("/lib/") && IsLibrary(result,basename))
171 if (result.setDirectory("/lib/") && IsLibrary(result,basename))
172172 return result;
173173
174174 // Can't find it, give up and return invalid path.
201201 const char* home = getenv("HOME");
202202 if (home) {
203203 Path result;
204 if (result.set_directory(home))
204 if (result.setDirectory(home))
205205 return result;
206206 }
207207 return GetRootDirectory();
209209 // FIXME: the above set of functions don't map to Windows very well.
210210
211211 bool
212 Path::is_file() const {
213 return (is_valid() && path[path.length()-1] != '/');
214 }
215
216 bool
217 Path::is_directory() const {
218 return (is_valid() && path[path.length()-1] == '/');
212 Path::isFile() const {
213 return (isValid() && path[path.length()-1] != '/');
214 }
215
216 bool
217 Path::isDirectory() const {
218 return (isValid() && path[path.length()-1] == '/');
219219 }
220220
221221 std::string
222 Path::get_basename() const {
222 Path::getBasename() const {
223223 // Find the last slash
224224 size_t slash = path.rfind('/');
225225 if (slash == std::string::npos)
230230 return path.substr(slash, path.rfind('.'));
231231 }
232232
233 bool Path::has_magic_number(const std::string &Magic) const {
233 bool Path::hasMagicNumber(const std::string &Magic) const {
234234 size_t len = Magic.size();
235235 char *buf = reinterpret_cast(_alloca(len+1));
236236 std::ifstream f(path.c_str());
240240 }
241241
242242 bool
243 Path::is_bytecode_file() const {
243 Path::isBytecodeFile() const {
244244 if (readable()) {
245 return has_magic_number("llvm");
245 return hasMagicNumber("llvm");
246246 }
247247 return false;
248248 }
249249
250250 bool
251 Path::is_archive() const {
251 Path::isArchive() const {
252252 if (readable()) {
253 return has_magic_number("!\012");
253 return hasMagicNumber("!\012");
254254 }
255255 return false;
256256 }
305305 }
306306
307307 bool
308 Path::set_directory(const std::string& a_path) {
308 Path::setDirectory(const std::string& a_path) {
309309 if (a_path.size() == 0)
310310 return false;
311311 Path save(*this);
314314 size_t last = a_path.size() -1;
315315 if (last != 0 && a_path[last] != '/')
316316 path += '/';
317 if (!is_valid()) {
317 if (!isValid()) {
318318 path = save.path;
319319 return false;
320320 }
322322 }
323323
324324 bool
325 Path::set_file(const std::string& a_path) {
325 Path::setFile(const std::string& a_path) {
326326 if (a_path.size() == 0)
327327 return false;
328328 Path save(*this);
332332 while (last > 0 && a_path[last] == '/')
333333 last--;
334334 path.erase(last+1);
335 if (!is_valid()) {
335 if (!isValid()) {
336336 path = save.path;
337337 return false;
338338 }
340340 }
341341
342342 bool
343 Path::append_directory(const std::string& dir) {
344 if (is_file())
343 Path::appendDirectory(const std::string& dir) {
344 if (isFile())
345345 return false;
346346 Path save(*this);
347347 path += dir;
348348 path += "/";
349 if (!is_valid()) {
349 if (!isValid()) {
350350 path = save.path;
351351 return false;
352352 }
354354 }
355355
356356 bool
357 Path::elide_directory() {
358 if (is_file())
357 Path::elideDirectory() {
358 if (isFile())
359359 return false;
360360 size_t slashpos = path.rfind('/',path.size());
361361 if (slashpos == 0 || slashpos == std::string::npos)
369369 }
370370
371371 bool
372 Path::append_file(const std::string& file) {
373 if (!is_directory())
372 Path::appendFile(const std::string& file) {
373 if (!isDirectory())
374374 return false;
375375 Path save(*this);
376376 path += file;
377 if (!is_valid()) {
377 if (!isValid()) {
378378 path = save.path;
379379 return false;
380380 }
382382 }
383383
384384 bool
385 Path::elide_file() {
386 if (is_directory())
385 Path::elideFile() {
386 if (isDirectory())
387387 return false;
388388 size_t slashpos = path.rfind('/',path.size());
389389 if (slashpos == std::string::npos)
393393 }
394394
395395 bool
396 Path::append_suffix(const std::string& suffix) {
397 if (is_directory())
396 Path::appendSuffix(const std::string& suffix) {
397 if (isDirectory())
398398 return false;
399399 Path save(*this);
400400 path.append(".");
401401 path.append(suffix);
402 if (!is_valid()) {
402 if (!isValid()) {
403403 path = save.path;
404404 return false;
405405 }
407407 }
408408
409409 bool
410 Path::elide_suffix() {
411 if (is_directory()) return false;
410 Path::elideSuffix() {
411 if (isDirectory()) return false;
412412 size_t dotpos = path.rfind('.',path.size());
413413 size_t slashpos = path.rfind('/',path.size());
414414 if (slashpos != std::string::npos && dotpos != std::string::npos &&
421421
422422
423423 bool
424 Path::create_directory( bool create_parents) {
424 Path::createDirectory( bool create_parents) {
425425 // Make sure we're dealing with a directory
426 if (!is_directory()) return false;
426 if (!isDirectory()) return false;
427427
428428 // Get a writeable copy of the path name
429429 char *pathname = reinterpret_cast(_alloca(path.length()+1));
472472 }
473473
474474 bool
475 Path::create_file() {
475 Path::createFile() {
476476 // Make sure we're dealing with a file
477 if (!is_file()) return false;
477 if (!isFile()) return false;
478478
479479 // Create the file
480480 HANDLE h = CreateFile(path.c_str(), GENERIC_WRITE, 0, NULL, CREATE_NEW,
487487 }
488488
489489 bool
490 Path::destroy_directory(bool remove_contents) {
490 Path::destroyDirectory(bool remove_contents) {
491491 // Make sure we're dealing with a directory
492 if (!is_directory()) return false;
492 if (!isDirectory()) return false;
493493
494494 // If it doesn't exist, we're done.
495495 if (!exists()) return true;
516516 }
517517
518518 bool
519 Path::destroy_file() {
520 if (!is_file()) return false;
519 Path::destroyFile() {
520 if (!isFile()) return false;
521521
522522 DWORD attr = GetFileAttributes(path.c_str());
523523
3131 if (progName.length() == 0) // no program
3232 return Path();
3333 Path temp;
34 if (!temp.set_file(progName)) // invalid name
34 if (!temp.setFile(progName)) // invalid name
3535 return Path();
3636 if (temp.executable()) // already executable as is
3737 return temp;
3131 if (progName.length() == 0) // no program
3232 return Path();
3333 Path temp;
34 if (!temp.set_file(progName)) // invalid name
34 if (!temp.setFile(progName)) // invalid name
3535 return Path();
3636 if (temp.executable()) // already executable as is
3737 return temp;
9292 if (CleanupExecuted)
9393 throw std::string("Process terminating -- cannot register for removal");
9494
95 if (path.is_directory()) {
95 if (path.isDirectory()) {
9696 if (DirectoriesToRemove == NULL)
9797 DirectoriesToRemove = new std::vector;
9898
123123 if (FilesToRemove != NULL)
124124 while (!FilesToRemove->empty()) {
125125 try {
126 FilesToRemove->back().destroy_file();
126 FilesToRemove->back().destroyFile();
127127 } catch (...) {
128128 }
129129 FilesToRemove->pop_back();
132132 if (DirectoriesToRemove != NULL)
133133 while (!DirectoriesToRemove->empty()) {
134134 try {
135 DirectoriesToRemove->back().destroy_directory(true);
135 DirectoriesToRemove->back().destroyDirectory(true);
136136 } catch (...) {
137137 }
138138 DirectoriesToRemove->pop_back();
9292 if (CleanupExecuted)
9393 throw std::string("Process terminating -- cannot register for removal");
9494
95 if (path.is_directory()) {
95 if (path.isDirectory()) {
9696 if (DirectoriesToRemove == NULL)
9797 DirectoriesToRemove = new std::vector;
9898
123123 if (FilesToRemove != NULL)
124124 while (!FilesToRemove->empty()) {
125125 try {
126 FilesToRemove->back().destroy_file();
126 FilesToRemove->back().destroyFile();
127127 } catch (...) {
128128 }
129129 FilesToRemove->pop_back();
132132 if (DirectoriesToRemove != NULL)
133133 while (!DirectoriesToRemove->empty()) {
134134 try {
135 DirectoriesToRemove->back().destroy_directory(true);
135 DirectoriesToRemove->back().destroyDirectory(true);
136136 } catch (...) {
137137 }
138138 DirectoriesToRemove->pop_back();
945945 // If the source library's module id is in the dependent library list of the
946946 // destination library, remove it since that module is now linked in.
947947 sys::Path modId;
948 modId.set_file(Src->getModuleIdentifier());
949 if (!modId.is_empty())
950 Dest->removeLibrary(modId.get_basename());
948 modId.setFile(Src->getModuleIdentifier());
949 if (!modId.isEmpty())
950 Dest->removeLibrary(modId.getBasename());
951951
952952 return false;
953953 }
4444 bool SharedObjectOnly) {
4545 // Determine if the pathname can be found as it stands.
4646 sys::Path FilePath;
47 if (FilePath.set_file(Filename) && FilePath.readable())
47 if (FilePath.setFile(Filename) && FilePath.readable())
4848 return Filename;
4949
5050 // Ask the System Path object to locate the library. This ensures that
4646 //
4747 static inline std::auto_ptr LoadFile(const std::string &FN) {
4848 sys::Path Filename;
49 if (!Filename.set_file(FN)) {
49 if (!Filename.setFile(FN)) {
5050 std::cerr << "Invalid file name: '" << FN << "'\n";
5151 return std::auto_ptr();
5252 }
133133 StringVector::const_iterator E = paths.end();
134134 while (I != E) {
135135 sys::Path tmp;
136 tmp.set_directory(*I);
136 tmp.setDirectory(*I);
137137 IncludePaths.push_back(tmp);
138138 ++I;
139139 }
148148 StringVector::const_iterator E = paths.end();
149149 while (I != E) {
150150 sys::Path tmp;
151 tmp.set_directory(*I);
151 tmp.setDirectory(*I);
152152 LibraryPaths.push_back(tmp);
153153 ++I;
154154 }
156156
157157 virtual void addLibraryPath( const sys::Path& libPath ) {
158158 LibraryPaths.push_back(libPath);
159 }
160
161 virtual void addToolPath( const sys::Path& toolPath ) {
162 ToolPaths.push_back(toolPath);
159163 }
160164
161165 virtual void setfPassThrough(const StringVector& fOpts) {
181185
182186 void cleanup() {
183187 if (!isSet(KEEP_TEMPS_FLAG)) {
184 if (TempDir.is_directory() && TempDir.writable())
185 TempDir.destroy_directory(/*remove_contents=*/true);
188 if (TempDir.isDirectory() && TempDir.writable())
189 TempDir.destroyDirectory(/*remove_contents=*/true);
186190 } else {
187191 std::cout << "Temporary files are in " << TempDir.get() << "\n";
188192 }
191195 sys::Path MakeTempFile(const std::string& basename,
192196 const std::string& suffix ) {
193197 sys::Path result(TempDir);
194 if (!result.append_file(basename))
198 if (!result.appendFile(basename))
195199 throw basename + ": can't use this file name";
196 if (!result.append_suffix(suffix))
200 if (!result.appendSuffix(suffix))
197201 throw suffix + ": can't use this file suffix";
198202 return result;
199203 }
372376 if (!isSet(DRY_RUN_FLAG)) {
373377 sys::Path progpath = sys::Program::FindProgramByName(
374378 action->program.get());
375 if (progpath.is_empty())
379 if (progpath.isEmpty())
376380 throw std::string("Can't find program '"+progpath.get()+"'");
377381 else if (progpath.executable())
378382 action->program = progpath;
403407 const sys::Path& dir,
404408 bool native = false) {
405409 sys::Path fullpath(dir);
406 fullpath.append_file(link_item);
410 fullpath.appendFile(link_item);
407411 if (native) {
408 fullpath.append_suffix("a");
412 fullpath.appendSuffix("a");
409413 } else {
410 fullpath.append_suffix("bc");
414 fullpath.appendSuffix("bc");
411415 if (fullpath.readable())
412416 return fullpath;
413 fullpath.elide_suffix();
414 fullpath.append_suffix("o");
417 fullpath.elideSuffix();
418 fullpath.appendSuffix("o");
415419 if (fullpath.readable())
416420 return fullpath;
417421 fullpath = dir;
418 fullpath.append_file(std::string("lib") + link_item);
419 fullpath.append_suffix("a");
422 fullpath.appendFile(std::string("lib") + link_item);
423 fullpath.appendSuffix("a");
420424 if (fullpath.readable())
421425 return fullpath;
422 fullpath.elide_suffix();
423 fullpath.append_suffix("so");
426 fullpath.elideSuffix();
427 fullpath.appendSuffix("so");
424428 if (fullpath.readable())
425429 return fullpath;
426430 }
445449 // on the command line.
446450 PathVector::iterator PI = LibraryPaths.begin();
447451 PathVector::iterator PE = LibraryPaths.end();
448 while (PI != PE && fullpath.is_empty()) {
452 while (PI != PE && fullpath.isEmpty()) {
449453 fullpath = GetPathForLinkageItem(link_item.get(),*PI);
450454 ++PI;
451455 }
452456
453457 // If we didn't find the file in any of the library search paths
454458 // so we have to bail. No where else to look.
455 if (fullpath.is_empty()) {
459 if (fullpath.isEmpty()) {
456460 err =
457461 std::string("Can't find linkage item '") + link_item.get() + "'";
458462 return false;
465469 set.insert(fullpath);
466470
467471 // If its an LLVM bytecode file ...
468 if (fullpath.is_bytecode_file()) {
472 if (fullpath.isBytecodeFile()) {
469473 // Process the dependent libraries recursively
470474 Module::LibraryListType modlibs;
471475 if (GetBytecodeDependentLibraries(fullpath.get(),modlibs)) {
529533 // If they are asking for linking and didn't provide an output
530534 // file then its an error (no way for us to "make up" a meaningful
531535 // file name based on the various linker input files).
532 if (finalPhase == LINKING && Output.is_empty())
536 if (finalPhase == LINKING && Output.isEmpty())
533537 throw std::string(
534538 "An output file name must be specified for linker output");
535539
536540 // If they are not asking for linking, provided an output file and
537541 // there is more than one input file, its an error
538 if (finalPhase != LINKING && !Output.is_empty() && InpList.size() > 1)
542 if (finalPhase != LINKING && !Output.isEmpty() && InpList.size() > 1)
539543 throw std::string("An output file name cannot be specified ") +
540544 "with more than one input file name when not linking";
541545
580584
581585 // Initialize the input and output files
582586 sys::Path InFile(I->first);
583 sys::Path OutFile(I->first.get_basename());
587 sys::Path OutFile(I->first.getBasename());
584588
585589 // PRE-PROCESSING PHASE
586590 Action& action = cd->PreProcessor;
587591
588592 // Get the preprocessing action, if needed, or error if appropriate
589 if (!action.program.is_empty()) {
593 if (!action.program.isEmpty()) {
590594 if (action.isSet(REQUIRED_FLAG) || finalPhase == PREPROCESSING) {
591595 if (finalPhase == PREPROCESSING) {
592 OutFile.append_suffix("E");
596 OutFile.appendSuffix("E");
593597 actions.push_back(GetAction(cd,InFile,OutFile,PREPROCESSING));
594598 } else {
595 sys::Path TempFile(MakeTempFile(I->first.get_basename(),"E"));
599 sys::Path TempFile(MakeTempFile(I->first.getBasename(),"E"));
596600 actions.push_back(GetAction(cd,InFile,TempFile,
597601 PREPROCESSING));
598602 InFile = TempFile;
613617 action = cd->Translator;
614618
615619 // Get the translation action, if needed, or error if appropriate
616 if (!action.program.is_empty()) {
620 if (!action.program.isEmpty()) {
617621 if (action.isSet(REQUIRED_FLAG) || finalPhase == TRANSLATION) {
618622 if (finalPhase == TRANSLATION) {
619 OutFile.append_suffix("o");
623 OutFile.appendSuffix("o");
620624 actions.push_back(GetAction(cd,InFile,OutFile,TRANSLATION));
621625 } else {
622 sys::Path TempFile(MakeTempFile(I->first.get_basename(),"trans"));
626 sys::Path TempFile(MakeTempFile(I->first.getBasename(),"trans"));
623627 actions.push_back(GetAction(cd,InFile,TempFile,TRANSLATION));
624628 InFile = TempFile;
625629 }
629633 /// The output of the translator is an LLVM Assembly program
630634 /// We need to translate it to bytecode
631635 Action* action = new Action();
632 action->program.set_file("llvm-as");
636 action->program.setFile("llvm-as");
633637 action->args.push_back(InFile.get());
634638 action->args.push_back("-o");
635 InFile.append_suffix("bc");
639 InFile.appendSuffix("bc");
636640 action->args.push_back(InFile.get());
637641 actions.push_back(action);
638642 }
652656
653657 // Get the optimization action, if needed, or error if appropriate
654658 if (!isSet(EMIT_RAW_FLAG)) {
655 if (!action.program.is_empty()) {
659 if (!action.program.isEmpty()) {
656660 if (action.isSet(REQUIRED_FLAG) || finalPhase == OPTIMIZATION) {
657661 if (finalPhase == OPTIMIZATION) {
658 OutFile.append_suffix("o");
662 OutFile.appendSuffix("o");
659663 actions.push_back(GetAction(cd,InFile,OutFile,OPTIMIZATION));
660664 } else {
661 sys::Path TempFile(MakeTempFile(I->first.get_basename(),"opt"));
665 sys::Path TempFile(MakeTempFile(I->first.getBasename(),"opt"));
662666 actions.push_back(GetAction(cd,InFile,TempFile,OPTIMIZATION));
663667 InFile = TempFile;
664668 }
667671 /// The output of the optimizer is an LLVM Assembly program
668672 /// We need to translate it to bytecode with llvm-as
669673 Action* action = new Action();
670 action->program.set_file("llvm-as");
674 action->program.setFile("llvm-as");
671675 action->args.push_back(InFile.get());
672676 action->args.push_back("-f");
673677 action->args.push_back("-o");
674 InFile.append_suffix("bc");
678 InFile.appendSuffix("bc");
675679 action->args.push_back(InFile.get());
676680 actions.push_back(action);
677681 }
694698 if (isSet(EMIT_NATIVE_FLAG)) {
695699 // Use llc to get the native assembly file
696700 Action* action = new Action();
697 action->program.set_file("llc");
701 action->program.setFile("llc");
698702 action->args.push_back(InFile.get());
699703 action->args.push_back("-f");
700704 action->args.push_back("-o");
701 OutFile.append_suffix("s");
705 OutFile.appendSuffix("s");
702706 action->args.push_back(OutFile.get());
703707 } else {
704708 // Just convert back to llvm assembly with llvm-dis
705709 Action* action = new Action();
706 action->program.set_file("llvm-dis");
710 action->program.setFile("llvm-dis");
707711 action->args.push_back(InFile.get());
708712 action->args.push_back("-f");
709713 action->args.push_back("-o");
710 OutFile.append_suffix("ll");
714 OutFile.appendSuffix("ll");
711715 action->args.push_back(OutFile.get());
712716 actions.push_back(action);
713717 }
742746
743747 // Set up the linking action with llvm-ld
744748 Action* link = new Action();
745 link->program.set_file("llvm-ld");
749 link->program.setFile("llvm-ld");
746750
747751 // Add in the optimization level requested
748752 switch (optLevel) {
833837 std::string machine; ///< Target machine name
834838 PathVector LibraryPaths; ///< -L options
835839 PathVector IncludePaths; ///< -I options
840 PathVector ToolPaths; ///< -B options
836841 StringVector Defines; ///< -D options
837842 sys::Path TempDir; ///< Name of the temporary directory.
838843 StringTable AdditionalArgs; ///< The -Txyz options
160160 /// @brief Set the output machine name.
161161 virtual void setOutputMachine(const std::string& machineName) = 0;
162162
163 /// @brief Set Preprocessor specific options
163 /// @brief Set the options for a given phase.
164164 virtual void setPhaseArgs(Phases phase, const StringVector& opts) = 0;
165165
166166 /// @brief Set Library Paths
172172 /// @brief Set Library Paths
173173 virtual void setLibraryPaths(const StringVector& paths) = 0;
174174
175 /// @brief Set the list of library paths to be searched for
176 /// libraries.
175 /// @brief Add a path to the list of library paths
177176 virtual void addLibraryPath( const sys::Path& libPath ) = 0;
177
178 /// @brief Add a path to the list of paths in which to find tools
179 virtual void addToolPath( const sys::Path& toolPath) = 0;
178180
179181 /// @brief Set the list of -f options to be passed through
180182 virtual void setfPassThrough(const StringVector& fOpts) = 0;
232232 action.args.clear();
233233 } else {
234234 if (token == STRING || token == OPTION) {
235 action.program.set_file(ConfigLexerState.StringVal);
235 action.program.setFile(ConfigLexerState.StringVal);
236236 } else {
237237 error("Expecting a program name");
238238 }
420420 LLVMC_ConfigDataProvider::ReadConfigData(const std::string& ftype) {
421421 CompilerDriver::ConfigData* result = 0;
422422 sys::Path confFile;
423 if (configDir.is_empty()) {
423 if (configDir.isEmpty()) {
424424 // Try the environment variable
425425 const char* conf = getenv("LLVM_CONFIG_DIR");
426426 if (conf) {
427 confFile.set_directory(conf);
428 confFile.append_file(ftype);
427 confFile.setDirectory(conf);
428 confFile.appendFile(ftype);
429429 if (!confFile.readable())
430430 throw std::string("Configuration file for '") + ftype +
431431 "' is not available.";
432432 } else {
433433 // Try the user's home directory
434434 confFile = sys::Path::GetUserHomeDirectory();
435 if (!confFile.is_empty()) {
436 confFile.append_directory(".llvm");
437 confFile.append_directory("etc");
438 confFile.append_file(ftype);
435 if (!confFile.isEmpty()) {
436 confFile.appendDirectory(".llvm");
437 confFile.appendDirectory("etc");
438 confFile.appendFile(ftype);
439439 if (!confFile.readable())
440440 confFile.clear();
441441 }
442 if (!confFile.is_empty()) {
442 if (!confFile.isEmpty()) {
443443 // Okay, try the LLVM installation directory
444444 confFile = sys::Path::GetLLVMConfigDir();
445 confFile.append_file(ftype);
445 confFile.appendFile(ftype);
446446 if (!confFile.readable()) {
447447 // Okay, try the "standard" place
448448 confFile = sys::Path::GetLLVMDefaultConfigDir();
449 confFile.append_file(ftype);
449 confFile.appendFile(ftype);
450450 if (!confFile.readable()) {
451451 throw std::string("Configuration file for '") + ftype +
452452 "' is not available.";
456456 }
457457 } else {
458458 confFile = configDir;
459 confFile.append_file(ftype);
459 confFile.appendFile(ftype);
460460 if (!confFile.readable())
461461 throw std::string("Configuration file for '") + ftype +
462462 "' is not available.";
110110 cl::desc("Pass through -W options to compiler tools"),
111111 cl::value_desc("warnings category"));
112112
113 cl::list BOpt("B", cl::ZeroOrMore, cl::Prefix,
114 cl::desc("Indicate where llvmc sub-tools are installed"),
115 cl::value_desc("directory path containing bin and lib directories"));
116
113117 //===------------------------------------------------------------------------===
114118 //=== INPUT OPTIONS
115119 //===------------------------------------------------------------------------===