summaryrefslogtreecommitdiffstats
path: root/llvm/tools
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2005-07-07 23:21:43 +0000
committerReid Spencer <rspencer@reidspencer.com>2005-07-07 23:21:43 +0000
commitc9c0473fa5cc6490859410b3bb055d4f6e7cbc00 (patch)
treebe5711878cf0da37f08d6cd1934155e833e016ac /llvm/tools
parent4ed40f7c6f13bcb1ef0487392413c6d78dd6790d (diff)
downloadbcm5719-llvm-c9c0473fa5cc6490859410b3bb055d4f6e7cbc00.tar.gz
bcm5719-llvm-c9c0473fa5cc6490859410b3bb055d4f6e7cbc00.zip
For PR495:
Get rid of the difference between file paths and directory paths. The Path class now simply stores a path that can refer to either a file or a directory. This required various changes in the implementation and interface of the class with the corresponding impact to its users. Doxygen comments were also updated to reflect these changes. Interface changes are: appendDirectory -> appendComponent appendFile -> appendComponent elideDirectory -> eraseComponent elideFile -> eraseComponent elideSuffix -> eraseSuffix renameFile -> rename setDirectory -> set setFile -> set Changes pass Dejagnu and llvm-test/SingleSource tests. llvm-svn: 22349
Diffstat (limited to 'llvm/tools')
-rw-r--r--llvm/tools/bugpoint/CrashDebugger.cpp4
-rw-r--r--llvm/tools/bugpoint/ExecutionDriver.cpp11
-rw-r--r--llvm/tools/bugpoint/Miscompilation.cpp10
-rw-r--r--llvm/tools/bugpoint/OptimizerDriver.cpp4
-rw-r--r--llvm/tools/gccld/GenerateCode.cpp14
-rw-r--r--llvm/tools/gccld/gccld.cpp8
-rw-r--r--llvm/tools/llvm-ar/llvm-ar.cpp6
-rw-r--r--llvm/tools/llvm-ld/llvm-ld.cpp4
-rw-r--r--llvm/tools/llvm-link/llvm-link.cpp2
-rw-r--r--llvm/tools/llvm-ranlib/llvm-ranlib.cpp2
-rw-r--r--llvm/tools/llvmc/CompilerDriver.cpp30
-rw-r--r--llvm/tools/llvmc/Configuration.cpp18
12 files changed, 55 insertions, 58 deletions
diff --git a/llvm/tools/bugpoint/CrashDebugger.cpp b/llvm/tools/bugpoint/CrashDebugger.cpp
index 6f0e3de0f4c..2ede20fad7a 100644
--- a/llvm/tools/bugpoint/CrashDebugger.cpp
+++ b/llvm/tools/bugpoint/CrashDebugger.cpp
@@ -58,7 +58,7 @@ ReducePassList::doTest(std::vector<const PassInfo*> &Prefix,
if (BD.runPasses(Prefix, PfxOutput))
return KeepPrefix;
- PrefixOutput.setFile(PfxOutput);
+ PrefixOutput.set(PfxOutput);
OrigProgram = BD.Program;
BD.Program = ParseInputFile(PrefixOutput.toString());
@@ -67,7 +67,7 @@ ReducePassList::doTest(std::vector<const PassInfo*> &Prefix,
<< PrefixOutput << "'!\n";
exit(1);
}
- PrefixOutput.destroyFile();
+ PrefixOutput.destroy();
}
std::cout << "Checking to see if these passes crash: "
diff --git a/llvm/tools/bugpoint/ExecutionDriver.cpp b/llvm/tools/bugpoint/ExecutionDriver.cpp
index 972338acad8..936f54682dd 100644
--- a/llvm/tools/bugpoint/ExecutionDriver.cpp
+++ b/llvm/tools/bugpoint/ExecutionDriver.cpp
@@ -281,7 +281,7 @@ std::string BugDriver::compileSharedObject(const std::string &BytecodeFile) {
exit(1);
// Remove the intermediate C file
- OutputCFile.destroyFile();
+ OutputCFile.destroy();
return "./" + SharedObjectFile;
}
@@ -302,9 +302,9 @@ bool BugDriver::diffProgram(const std::string &BytecodeFile,
// If we're checking the program exit code, assume anything nonzero is bad.
if (CheckProgramExitCode && ProgramExitedNonzero) {
- Output.destroyFile();
+ Output.destroy();
if (RemoveBytecode)
- sys::Path(BytecodeFile).destroyFile();
+ sys::Path(BytecodeFile).destroy();
return true;
}
@@ -321,10 +321,11 @@ bool BugDriver::diffProgram(const std::string &BytecodeFile,
}
// Remove the generated output.
- Output.destroyFile();
+ Output.destroy();
// Remove the bytecode file if we are supposed to.
- if (RemoveBytecode) sys::Path(BytecodeFile).destroyFile();
+ if (RemoveBytecode)
+ sys::Path(BytecodeFile).destroy();
return FilesDifferent;
}
diff --git a/llvm/tools/bugpoint/Miscompilation.cpp b/llvm/tools/bugpoint/Miscompilation.cpp
index 860b9b4a35f..4caf0d43e4b 100644
--- a/llvm/tools/bugpoint/Miscompilation.cpp
+++ b/llvm/tools/bugpoint/Miscompilation.cpp
@@ -99,7 +99,7 @@ ReduceMiscompilingPasses::doTest(std::vector<const PassInfo*> &Prefix,
// If the prefix maintains the predicate by itself, only keep the prefix!
if (BD.diffProgram(BytecodeResult)) {
std::cout << " nope.\n";
- sys::Path(BytecodeResult).destroyFile();
+ sys::Path(BytecodeResult).destroy();
return KeepPrefix;
}
std::cout << " yup.\n"; // No miscompilation!
@@ -113,7 +113,7 @@ ReduceMiscompilingPasses::doTest(std::vector<const PassInfo*> &Prefix,
<< BytecodeResult << "'!\n";
exit(1);
}
- sys::Path(BytecodeResult).destroyFile(); // No longer need the file on disk
+ sys::Path(BytecodeResult).destroy(); // No longer need the file on disk
// Don't check if there are no passes in the suffix.
if (Suffix.empty())
@@ -775,9 +775,9 @@ static bool TestCodeGenerator(BugDriver &BD, Module *Test, Module *Safe) {
std::cerr << ": still failing!\n";
else
std::cerr << ": didn't fail.\n";
- TestModuleBC.destroyFile();
- SafeModuleBC.destroyFile();
- sys::Path(SharedObject).destroyFile();
+ TestModuleBC.destroy();
+ SafeModuleBC.destroy();
+ sys::Path(SharedObject).destroy();
return Result;
}
diff --git a/llvm/tools/bugpoint/OptimizerDriver.cpp b/llvm/tools/bugpoint/OptimizerDriver.cpp
index 5de70be2916..c6e58fdc340 100644
--- a/llvm/tools/bugpoint/OptimizerDriver.cpp
+++ b/llvm/tools/bugpoint/OptimizerDriver.cpp
@@ -161,7 +161,7 @@ bool BugDriver::runPasses(const std::vector<const PassInfo*> &Passes,
// If we are supposed to delete the bytecode file or if the passes crashed,
// remove it now. This may fail if the file was never created, but that's ok.
if (DeleteOutput || !ExitedOK)
- sys::Path(OutputFilename).destroyFile();
+ sys::Path(OutputFilename).destroy();
#ifndef PLATFORMINDEPENDENT
if (!Quiet) {
@@ -214,6 +214,6 @@ Module *BugDriver::runPassesOn(Module *M,
<< BytecodeResult << "'!\n";
exit(1);
}
- sys::Path(BytecodeResult).destroyFile(); // No longer need the file on disk
+ sys::Path(BytecodeResult).destroy(); // No longer need the file on disk
return Ret;
}
diff --git a/llvm/tools/gccld/GenerateCode.cpp b/llvm/tools/gccld/GenerateCode.cpp
index 020d883a6bc..f6a08ce8cb0 100644
--- a/llvm/tools/gccld/GenerateCode.cpp
+++ b/llvm/tools/gccld/GenerateCode.cpp
@@ -152,15 +152,11 @@ static bool isBytecodeLibrary(const sys::Path &FullPath) {
static bool isBytecodeLPath(const std::string &LibPath) {
bool isBytecodeLPath = false;
- // Make sure the -L path has a '/' character
- // because llvm-g++ passes them without the ending
- // '/' char and sys::Path doesn't think it is a
- // directory (see: sys::Path::isDirectory) without it
- std::string dir = LibPath;
- if ( dir[dir.length()-1] != '/' )
- dir.append("/");
-
- sys::Path LPath(dir);
+ sys::Path LPath(LibPath);
+
+ // Make sure its a directory
+ if (!LPath.isDirectory())
+ return isBytecodeLPath;
// Grab the contents of the -L path
std::set<sys::Path> Files;
diff --git a/llvm/tools/gccld/gccld.cpp b/llvm/tools/gccld/gccld.cpp
index 6d49466c199..7a4dec329a0 100644
--- a/llvm/tools/gccld/gccld.cpp
+++ b/llvm/tools/gccld/gccld.cpp
@@ -313,9 +313,9 @@ int main(int argc, char **argv, char **envp ) {
if (!SaveTemps) {
// Remove the assembly language file.
- AssemblyFile.destroyFile();
+ AssemblyFile.destroy();
// Remove the bytecode language file.
- sys::Path(RealBytecodeOutput).destroyFile();
+ sys::Path(RealBytecodeOutput).destroy();
}
} else if (NativeCBE) {
@@ -345,9 +345,9 @@ int main(int argc, char **argv, char **envp ) {
if (!SaveTemps) {
// Remove the assembly language file.
- CFile.destroyFile();
+ CFile.destroy();
// Remove the bytecode language file.
- sys::Path(RealBytecodeOutput).destroyFile();
+ sys::Path(RealBytecodeOutput).destroy();
}
} else if (!LinkAsLibrary) {
diff --git a/llvm/tools/llvm-ar/llvm-ar.cpp b/llvm/tools/llvm-ar/llvm-ar.cpp
index cc3d2d8ec73..3725a17883d 100644
--- a/llvm/tools/llvm-ar/llvm-ar.cpp
+++ b/llvm/tools/llvm-ar/llvm-ar.cpp
@@ -293,7 +293,7 @@ std::set<sys::Path> recurseDirectories(const sys::Path& path) {
void buildPaths(bool checkExistence = true) {
for (unsigned i = 0; i < Members.size(); i++) {
sys::Path aPath;
- if (!aPath.setFile(Members[i]))
+ if (!aPath.set(Members[i]))
throw std::string("File member name invalid: ") + Members[i];
if (checkExistence) {
if (!aPath.exists())
@@ -431,7 +431,7 @@ void doExtract() {
// Make sure the intervening directories are created
if (I->hasPath()) {
sys::Path dirs(I->getPath());
- dirs.elideFile();
+ dirs.eraseComponent();
dirs.createDirectory(/*create_parents=*/true);
}
@@ -669,7 +669,7 @@ int main(int argc, char **argv) {
// Check the path name of the archive
sys::Path ArchivePath;
- if (!ArchivePath.setFile(ArchiveName))
+ if (!ArchivePath.set(ArchiveName))
throw std::string("Archive name invalid: ") + ArchiveName;
// Create or open the archive object.
diff --git a/llvm/tools/llvm-ld/llvm-ld.cpp b/llvm/tools/llvm-ld/llvm-ld.cpp
index ccd643e1736..23efb48cfa3 100644
--- a/llvm/tools/llvm-ld/llvm-ld.cpp
+++ b/llvm/tools/llvm-ld/llvm-ld.cpp
@@ -480,7 +480,7 @@ int main(int argc, char **argv, char **envp) {
gcc, envp);
// Remove the assembly language file.
- AssemblyFile.destroyFile();
+ AssemblyFile.destroy();
} else if (NativeCBE) {
sys::Path CFile (OutputFilename);
CFile.appendSuffix("cbe.c");
@@ -505,7 +505,7 @@ int main(int argc, char **argv, char **envp) {
GenerateNative(OutputFilename, CFile.toString(), Libraries, gcc, envp);
// Remove the assembly language file.
- CFile.destroyFile();
+ CFile.destroy();
} else {
EmitShellScript(argv);
diff --git a/llvm/tools/llvm-link/llvm-link.cpp b/llvm/tools/llvm-link/llvm-link.cpp
index 9db18909d55..eb14c1762e3 100644
--- a/llvm/tools/llvm-link/llvm-link.cpp
+++ b/llvm/tools/llvm-link/llvm-link.cpp
@@ -50,7 +50,7 @@ static cl::opt<bool> NoCompress("disable-compression", cl::init(false),
//
static inline std::auto_ptr<Module> LoadFile(const std::string &FN) {
sys::Path Filename;
- if (!Filename.setFile(FN)) {
+ if (!Filename.set(FN)) {
std::cerr << "Invalid file name: '" << FN << "'\n";
return std::auto_ptr<Module>();
}
diff --git a/llvm/tools/llvm-ranlib/llvm-ranlib.cpp b/llvm/tools/llvm-ranlib/llvm-ranlib.cpp
index e2fbf7d55d5..d7d47149808 100644
--- a/llvm/tools/llvm-ranlib/llvm-ranlib.cpp
+++ b/llvm/tools/llvm-ranlib/llvm-ranlib.cpp
@@ -59,7 +59,7 @@ int main(int argc, char **argv) {
// Check the path name of the archive
sys::Path ArchivePath;
- if (!ArchivePath.setFile(ArchiveName))
+ if (!ArchivePath.set(ArchiveName))
throw std::string("Archive name invalid: ") + ArchiveName;
// Make sure it exists, we don't create empty archives
diff --git a/llvm/tools/llvmc/CompilerDriver.cpp b/llvm/tools/llvmc/CompilerDriver.cpp
index 34e4038c139..659af169a83 100644
--- a/llvm/tools/llvmc/CompilerDriver.cpp
+++ b/llvm/tools/llvmc/CompilerDriver.cpp
@@ -134,7 +134,7 @@ public:
StringVector::const_iterator E = paths.end();
while (I != E) {
sys::Path tmp;
- tmp.setDirectory(*I);
+ tmp.set(*I);
IncludePaths.push_back(tmp);
++I;
}
@@ -149,7 +149,7 @@ public:
StringVector::const_iterator E = paths.end();
while (I != E) {
sys::Path tmp;
- tmp.setDirectory(*I);
+ tmp.set(*I);
LibraryPaths.push_back(tmp);
++I;
}
@@ -188,7 +188,7 @@ private:
void cleanup() {
if (!isSet(KEEP_TEMPS_FLAG)) {
if (TempDir.isDirectory() && TempDir.canWrite())
- TempDir.destroyDirectory(/*remove_contents=*/true);
+ TempDir.destroy(/*remove_contents=*/true);
} else {
std::cout << "Temporary files are in " << TempDir << "\n";
}
@@ -197,7 +197,7 @@ private:
sys::Path MakeTempFile(const std::string& basename,
const std::string& suffix) {
sys::Path result(TempDir);
- if (!result.appendFile(basename))
+ if (!result.appendComponent(basename))
throw basename + ": can't use this file name";
if (!result.appendSuffix(suffix))
throw suffix + ": can't use this file suffix";
@@ -448,13 +448,13 @@ private:
llvm::sys::Path GetPathForLinkageItem(const std::string& link_item,
bool native = false) {
sys::Path fullpath;
- fullpath.setFile(link_item);
+ fullpath.set(link_item);
if (fullpath.canRead())
return fullpath;
for (PathVector::iterator PI = LibraryPaths.begin(),
PE = LibraryPaths.end(); PI != PE; ++PI) {
- fullpath.setDirectory(PI->toString());
- fullpath.appendFile(link_item);
+ fullpath.set(PI->toString());
+ fullpath.appendComponent(link_item);
if (fullpath.canRead())
return fullpath;
if (native) {
@@ -463,16 +463,16 @@ private:
fullpath.appendSuffix("bc");
if (fullpath.canRead())
return fullpath;
- fullpath.elideSuffix();
+ fullpath.eraseSuffix();
fullpath.appendSuffix("o");
if (fullpath.canRead())
return fullpath;
fullpath = *PI;
- fullpath.appendFile(std::string("lib") + link_item);
+ fullpath.appendComponent(std::string("lib") + link_item);
fullpath.appendSuffix("a");
if (fullpath.canRead())
return fullpath;
- fullpath.elideSuffix();
+ fullpath.eraseSuffix();
fullpath.appendSuffix("so");
if (fullpath.canRead())
return fullpath;
@@ -693,7 +693,7 @@ public:
/// The output of the translator is an LLVM Assembly program
/// We need to translate it to bytecode
Action* action = new Action();
- action->program.setFile("llvm-as");
+ action->program.set("llvm-as");
action->args.push_back(InFile.toString());
action->args.push_back("-o");
InFile.appendSuffix("bc");
@@ -735,7 +735,7 @@ public:
/// The output of the optimizer is an LLVM Assembly program
/// We need to translate it to bytecode with llvm-as
Action* action = new Action();
- action->program.setFile("llvm-as");
+ action->program.set("llvm-as");
action->args.push_back(InFile.toString());
action->args.push_back("-f");
action->args.push_back("-o");
@@ -764,7 +764,7 @@ public:
Action* action = new Action();
if (isSet(EMIT_NATIVE_FLAG)) {
// Use llc to get the native assembly file
- action->program.setFile("llc");
+ action->program.set("llc");
action->args.push_back(InFile.toString());
action->args.push_back("-f");
action->args.push_back("-o");
@@ -777,7 +777,7 @@ public:
actions.push_back(action);
} else {
// Just convert back to llvm assembly with llvm-dis
- action->program.setFile("llvm-dis");
+ action->program.set("llvm-dis");
action->args.push_back(InFile.toString());
action->args.push_back("-f");
action->args.push_back("-o");
@@ -820,7 +820,7 @@ public:
// Set up the linking action with llvm-ld
Action* link = new Action();
- link->program.setFile("llvm-ld");
+ link->program.set("llvm-ld");
// Add in the optimization level requested
switch (optLevel) {
diff --git a/llvm/tools/llvmc/Configuration.cpp b/llvm/tools/llvmc/Configuration.cpp
index 27b1b3fb309..bc538ca9c84 100644
--- a/llvm/tools/llvmc/Configuration.cpp
+++ b/llvm/tools/llvmc/Configuration.cpp
@@ -318,7 +318,7 @@ namespace {
{
std::string progname;
if (parseProgramName(progname))
- action.program.setFile(progname);
+ action.program.set(progname);
else
error("Expecting a program name");
@@ -547,8 +547,8 @@ LLVMC_ConfigDataProvider::ReadConfigData(const std::string& ftype) {
// Try the environment variable
const char* conf = getenv("LLVM_CONFIG_DIR");
if (conf) {
- confFile.setDirectory(conf);
- confFile.appendFile(ftype);
+ confFile.set(conf);
+ confFile.appendComponent(ftype);
if (!confFile.canRead())
throw std::string("Configuration file for '") + ftype +
"' is not available.";
@@ -556,20 +556,20 @@ LLVMC_ConfigDataProvider::ReadConfigData(const std::string& ftype) {
// Try the user's home directory
confFile = sys::Path::GetUserHomeDirectory();
if (!confFile.isEmpty()) {
- confFile.appendDirectory(".llvm");
- confFile.appendDirectory("etc");
- confFile.appendFile(ftype);
+ confFile.appendComponent(".llvm");
+ confFile.appendComponent("etc");
+ confFile.appendComponent(ftype);
if (!confFile.canRead())
confFile.clear();
}
if (confFile.isEmpty()) {
// Okay, try the LLVM installation directory
confFile = sys::Path::GetLLVMConfigDir();
- confFile.appendFile(ftype);
+ confFile.appendComponent(ftype);
if (!confFile.canRead()) {
// Okay, try the "standard" place
confFile = sys::Path::GetLLVMDefaultConfigDir();
- confFile.appendFile(ftype);
+ confFile.appendComponent(ftype);
if (!confFile.canRead()) {
throw std::string("Configuration file for '") + ftype +
"' is not available.";
@@ -579,7 +579,7 @@ LLVMC_ConfigDataProvider::ReadConfigData(const std::string& ftype) {
}
} else {
confFile = configDir;
- confFile.appendFile(ftype);
+ confFile.appendComponent(ftype);
if (!confFile.canRead())
throw std::string("Configuration file for '") + ftype +
"' is not available.";
OpenPOWER on IntegriCloud